[Tizen] Implement WebView Interface 10/189710/1
authorYoungsoo Son <ysoo.son@samsung.com>
Thu, 5 Jul 2018 01:23:37 +0000 (10:23 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Thu, 20 Sep 2018 04:22:45 +0000 (13:22 +0900)
A control for displaying web content.

Change-Id: Id05af42ea9cf89e64c20cca0321e7ffae25ccea4
Signed-off-by: Youngsoo Son <ysoo.son@samsung.com>
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp [new file with mode: 0755]
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp [new file with mode: 0644]
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/devel-api/controls/web-view/web-view.cpp [new file with mode: 0644]
dali-toolkit/devel-api/controls/web-view/web-view.h [new file with mode: 0644]
dali-toolkit/devel-api/file.list
dali-toolkit/internal/controls/web-view/web-view-impl.cpp [new file with mode: 0644]
dali-toolkit/internal/controls/web-view/web-view-impl.h [new file with mode: 0644]
dali-toolkit/internal/file.list

index 34f98a2..b303685 100755 (executable)
@@ -67,6 +67,7 @@ SET(TC_SOURCES
   utc-Dali-VisualFactory.cpp
   utc-Dali-ImageAtlas.cpp
   utc-Dali-VideoView.cpp
+  utc-Dali-WebView.cpp
   utc-Dali-AsyncImageLoader.cpp
   utc-Dali-SyncImageLoader.cpp
   utc-Dali-ControlWrapper.cpp
@@ -92,6 +93,7 @@ LIST(APPEND TC_SOURCES
   dali-toolkit-test-utils/toolkit-tts-player.cpp
   dali-toolkit-test-utils/toolkit-native-image-source.cpp
   dali-toolkit-test-utils/toolkit-video-player.cpp
+  dali-toolkit-test-utils/toolkit-web-engine.cpp
   dali-toolkit-test-utils/toolkit-trigger-event-factory.cpp
   dali-toolkit-test-utils/dali-test-suite-utils.cpp
   dali-toolkit-test-utils/dummy-control.cpp
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
new file mode 100755 (executable)
index 0000000..3f2797a
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "toolkit-timer.h"
+
+#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/images/native-image.h>
+#include <toolkit-application.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class WebEngine;
+
+namespace
+{
+static WebEngine* gInstance = NULL;
+static int gInstanceCount = 0;
+
+bool OnGoBack();
+bool OnGoForward();
+bool OnLoadUrl();
+bool OnClearHistory();
+
+static void ConnectToGlobalSignal( bool (*func)() )
+{
+  Dali::Timer timer = Dali::Timer::New( 0 );
+  timer.TickSignal().Connect( func );
+}
+
+static void DisconnectFromGlobalSignal( bool (*func)() )
+{
+  Dali::Timer timer = Dali::Timer::New( 0 );
+  timer.TickSignal().Disconnect( func );
+}
+}
+
+class WebEngine: public Dali::BaseObject
+{
+public:
+
+  WebEngine()
+    : mUrl()
+    , mCurrentPlusOnePos( 0 )
+  {
+    gInstanceCount++;
+    gInstance = this;
+  }
+
+  virtual ~WebEngine()
+  {
+    gInstanceCount--;
+    if ( !gInstanceCount )
+    {
+      gInstance = NULL;
+    }
+  }
+
+  void LoadUrl( const std::string& url )
+  {
+    mUrl = url;
+    ConnectToGlobalSignal( &OnLoadUrl );
+  }
+
+  const std::string& GetUrl() const
+  {
+    return mUrl;
+  }
+
+  bool CanGoForward() const
+  {
+    return mHistory.size() > mCurrentPlusOnePos;
+  }
+
+  void GoForward()
+  {
+    ConnectToGlobalSignal( &OnGoForward );
+  }
+
+  bool CanGoBack() const
+  {
+    return mCurrentPlusOnePos > 1;
+  }
+
+  void GoBack()
+  {
+    ConnectToGlobalSignal( &OnGoBack );
+  }
+
+  void ClearHistory()
+  {
+    ConnectToGlobalSignal( &OnClearHistory );
+  }
+
+  Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal()
+  {
+    return mPageLoadStartedSignal;
+  }
+
+  Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal()
+  {
+    return mPageLoadFinishedSignal;
+  }
+
+  std::string mUrl;
+  std::vector< std::string > mHistory;
+  size_t mCurrentPlusOnePos;
+  Dali::WebEnginePlugin::WebEngineSignalType mPageLoadStartedSignal;
+  Dali::WebEnginePlugin::WebEngineSignalType mPageLoadFinishedSignal;
+};
+
+inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
+{
+  DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+  BaseObject& handle = webEngine.GetBaseObject();
+  return static_cast< Internal::Adaptor::WebEngine& >( handle );
+}
+
+inline const WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
+{
+  DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+  const BaseObject& handle = webEngine.GetBaseObject();
+  return static_cast< const Internal::Adaptor::WebEngine& >( handle );
+}
+
+namespace
+{
+
+bool OnGoBack()
+{
+  DisconnectFromGlobalSignal( &OnGoBack );
+
+  if ( gInstance && gInstance->CanGoBack() )
+  {
+    gInstance->mCurrentPlusOnePos--;
+  }
+  return false;
+}
+
+bool OnGoForward()
+{
+  DisconnectFromGlobalSignal( &OnGoForward );
+
+  if ( gInstance && gInstance->CanGoForward() )
+  {
+    gInstance->mCurrentPlusOnePos++;
+  }
+  return false;
+}
+
+bool OnLoadUrl()
+{
+  DisconnectFromGlobalSignal( &OnLoadUrl );
+
+  if ( gInstance )
+  {
+    if ( gInstance->mHistory.size() > gInstance->mCurrentPlusOnePos )
+    {
+      gInstance->mHistory.erase( gInstance->mHistory.begin() + gInstance->mCurrentPlusOnePos, gInstance->mHistory.end() );
+    }
+    gInstance->mHistory.push_back( gInstance->mUrl );
+    gInstance->mCurrentPlusOnePos++;
+    gInstance->mPageLoadStartedSignal.Emit( gInstance->mUrl );
+    gInstance->mPageLoadFinishedSignal.Emit( gInstance->mUrl );
+  }
+
+  return false;
+}
+
+bool OnClearHistory()
+{
+  DisconnectFromGlobalSignal( &OnClearHistory );
+
+  if ( gInstance && gInstance->mCurrentPlusOnePos ) {
+    std::string url = gInstance->mHistory[ gInstance->mCurrentPlusOnePos - 1 ];
+    std::vector< std::string >().swap( gInstance->mHistory );
+    gInstance->mHistory.push_back( url );
+    gInstance->mCurrentPlusOnePos = 1;
+  }
+  return false;
+}
+} // namespace
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+
+// Dali::WebEngine Implementation
+WebEngine::WebEngine()
+{
+}
+
+WebEngine::WebEngine( Internal::Adaptor::WebEngine* internal )
+: BaseHandle( internal )
+{
+}
+
+WebEngine::~WebEngine()
+{
+}
+
+WebEngine WebEngine::New()
+{
+  Internal::Adaptor::WebEngine* baseObject = new Internal::Adaptor::WebEngine();
+
+  return WebEngine( baseObject );
+}
+
+WebEngine::WebEngine( const WebEngine& WebEngine )
+: BaseHandle( WebEngine )
+{
+}
+
+WebEngine& WebEngine::operator=( const WebEngine& webEngine )
+{
+  BaseHandle::operator=( webEngine );
+  return *this;
+}
+
+WebEngine WebEngine::DownCast( BaseHandle handle )
+{
+  return WebEngine( dynamic_cast< Internal::Adaptor::WebEngine* >( handle.GetObjectPtr() ) );
+}
+
+void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId )
+{
+}
+
+void WebEngine::Destroy()
+{
+}
+
+void WebEngine::LoadUrl( const std::string& url )
+{
+  return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
+}
+
+const std::string& WebEngine::GetUrl()
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetUrl();
+}
+
+NativeImageInterfacePtr WebEngine::GetNativeImageSource()
+{
+  Any source;
+  Dali::NativeImageSourcePtr sourcePtr = Dali::NativeImageSource::New( source );
+  return sourcePtr;
+}
+
+void WebEngine::LoadHTMLString( const std::string& htmlString )
+{
+}
+
+void WebEngine::Reload()
+{
+}
+
+void WebEngine::StopLoading()
+{
+}
+
+bool WebEngine::CanGoForward()
+{
+  return Internal::Adaptor::GetImplementation( *this ).CanGoForward();
+}
+
+void WebEngine::GoForward()
+{
+  Internal::Adaptor::GetImplementation( *this ).GoForward();
+}
+
+bool WebEngine::CanGoBack()
+{
+  return Internal::Adaptor::GetImplementation( *this ).CanGoBack();
+}
+
+void WebEngine::GoBack()
+{
+  Internal::Adaptor::GetImplementation( *this ).GoBack();
+}
+
+void WebEngine::EvaluateJavaScript( const std::string& script )
+{
+}
+
+void WebEngine::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb )
+{
+}
+
+void WebEngine::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+}
+
+void WebEngine::ClearHistory()
+{
+  Internal::Adaptor::GetImplementation( *this ).ClearHistory();
+}
+
+void WebEngine::ClearCache()
+{
+}
+
+void WebEngine::SetSize( int width, int height )
+{
+}
+
+bool WebEngine::SendTouchEvent( const TouchData& touch )
+{
+  return true;
+}
+
+bool WebEngine::SendKeyEvent( const KeyEvent& event )
+{
+  return true;
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal()
+{
+  return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal()
+{
+  return Internal::Adaptor::GetImplementation( *this ).PageLoadFinishedSignal();
+}
+
+} // namespace Dali;
+
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
new file mode 100644 (file)
index 0000000..f2a4f75
--- /dev/null
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include "dali-toolkit-test-utils/toolkit-timer.h"
+
+#include <dali.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+
+const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
+const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
+
+static int gPageLoadStartedCallbackCalled = 0;
+static int gPageLoadFinishedCallbackCalled = 0;
+static bool gTouched = false;
+
+struct CallbackFunctor
+{
+  CallbackFunctor(bool* callbackFlag)
+  : mCallbackFlag( callbackFlag )
+  {
+  }
+
+  void operator()()
+  {
+    *mCallbackFlag = true;
+  }
+  bool* mCallbackFlag;
+};
+
+static void OnPageLoadStarted( WebView view, const std::string& url )
+{
+  gPageLoadStartedCallbackCalled++;
+}
+
+static void OnPageLoadFinished( WebView view, const std::string& url )
+{
+  gPageLoadFinishedCallbackCalled++;
+}
+
+static bool OnTouched( Actor actor, const Dali::TouchData& touch )
+{
+  gTouched = true;
+  return true;
+}
+
+} // namespace
+
+void web_view_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void web_view_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliWebViewBasics(void)
+{
+  ToolkitTestApplication application;
+
+  // Copy and Assignment Test
+  tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  WebView copy( view );
+  DALI_TEST_CHECK( view == copy );
+
+  WebView assign;
+  DALI_TEST_CHECK( !assign );
+
+  assign = copy;
+  DALI_TEST_CHECK( assign == view );
+
+
+  // DownCast Test
+  tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
+  BaseHandle handle(view);
+
+  WebView view2 = WebView::DownCast( handle );
+  DALI_TEST_CHECK( view );
+  DALI_TEST_CHECK( view2 );
+  DALI_TEST_CHECK( view == view2 );
+
+
+  // TypeRegistry Test
+  tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+  DALI_TEST_CHECK( typeRegistry );
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
+  DALI_TEST_CHECK( typeInfo );
+
+  BaseHandle handle2 = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle2 );
+
+  WebView view3 = WebView::DownCast( handle2 );
+  DALI_TEST_CHECK( view3 );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewPageNavigation(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  view.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  view.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  view.SetPosition( 0, 0 );
+  view.SetSize( 800, 600 );
+  Stage::GetCurrent().Add( view );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_CHECK( view );
+
+  ConnectionTracker* testTracker = new ConnectionTracker();
+  view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
+  view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
+  bool signal1 = false;
+  bool signal2 = false;
+  bool signal3 = false;
+  view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
+  view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal2) );
+  view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal3) );
+  DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
+  DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
+
+
+  view.LoadUrl( TEST_URL1 );
+  view.GetNaturalSize();
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_CHECK( view.GetUrl().find( TEST_URL1 ) != std::string::npos );
+  DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
+  DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
+  DALI_TEST_CHECK( signal1 & signal2 );
+  DALI_TEST_CHECK( !signal3 );
+
+  view.LoadUrl( TEST_URL2 );
+  view.SetSize( 400, 300 );
+  application.SendNotification();
+  application.Render();
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_CHECK( view.GetUrl().find( TEST_URL2 ) != std::string::npos );
+  DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
+  DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
+  DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
+  DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
+
+  view.GoBack();
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_CHECK( !view.CanGoBack() );
+  DALI_TEST_CHECK( view.CanGoForward() );
+
+  view.GoForward();
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_CHECK( view.CanGoBack() );
+  DALI_TEST_CHECK( !view.CanGoForward() );
+
+  view.Reload();
+  view.StopLoading();
+  view.ClearHistory();
+  view.ClearCache();
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_CHECK( !view.CanGoBack() );
+  DALI_TEST_CHECK( !view.CanGoForward() );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewTouchAndKeys(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  view.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  view.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  view.SetPosition( 0, 0 );
+  view.SetSize( 800, 600 );
+
+  Stage::GetCurrent().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  view.GetNaturalSize();
+  view.TouchSignal().Connect( &OnTouched );
+
+  // Touch event
+  Dali::Integration::TouchEvent event;
+  Dali::Integration::Point pointDown, pointUp;
+
+  event = Dali::Integration::TouchEvent();
+  pointDown.SetState( PointState::DOWN );
+  pointDown.SetScreenPosition( Vector2( 10, 10 ) );
+  event.AddPoint( pointDown );
+  application.ProcessEvent( event );
+
+  event = Dali::Integration::TouchEvent();
+  pointUp.SetState( PointState::UP );
+  pointUp.SetScreenPosition( Vector2( 10, 10 ) );
+  event.AddPoint( pointUp );
+  application.ProcessEvent( event );
+
+  // Key event
+  Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
+  application.ProcessEvent( Integration::KeyEvent( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
+  application.SendNotification();
+
+  DALI_TEST_CHECK( gTouched );
+  DALI_TEST_CHECK( view );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewProperty1(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  std::string local;
+  view.SetProperty( WebView::Property::URL, TEST_URL1 );
+  Property::Value val = view.GetProperty( WebView::Property::URL );
+  DALI_TEST_CHECK( val.Get( local ) );
+  DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewMethodsForCoverage(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+  view.LoadHTMLString( "<body>Hello World!</body>" );
+  view.AddJavaScriptInterface( "jsObject", "jsFunction",
+    []( const std::string& arg ) -> std::string {
+      return arg + " World!";
+    }
+  );
+  view.EvaluateJavaScript( "jsObject.jsFunction('Hello')" );
+  view.RemoveJavascriptInterface( "jsObject", "jsFunction" );
+
+  DALI_TEST_CHECK( view );
+
+  END_TEST;
+}
index 0827bf4..687db13 100644 (file)
@@ -145,6 +145,7 @@ develapipopupdir =              $(develapicontrolsdir)/popup
 develapiscenedir =              $(develapicontrolsdir)/scene
 develapishadowviewdir =         $(develapicontrolsdir)/shadow-view
 develapisuperblurviewdir =      $(develapicontrolsdir)/super-blur-view
+develapiwebviewdir =            $(develapicontrolsdir)/web-view
 develapifocusmanagerdir =       $(develapidir)/focus-manager
 develapiimageloaderdir =        $(develapidir)/image-loader
 develapilayoutingdir =          $(develapidir)/layouting
@@ -185,6 +186,7 @@ develapishadowview_HEADERS =        $(devel_api_shadow_view_header_files)
 develapishadereffects_HEADERS =     $(devel_api_shader_effects_header_files)
 develapistyling_HEADERS =           $(devel_api_styling_header_files)
 develapisuperblurview_HEADERS =     $(devel_api_super_blur_view_header_files)
+develapiwebview_HEADERS =           $(devel_api_web_view_header_files)
 develapitoolbar_HEADERS =           $(devel_api_tool_bar_header_files)
 develapitooltip_HEADERS =           $(devel_api_tooltip_header_files)
 develapitransitioneffects_HEADERS = $(devel_api_transition_effects_header_files)
diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.cpp b/dali-toolkit/devel-api/controls/web-view/web-view.cpp
new file mode 100644 (file)
index 0000000..0b3698b
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/web-view/web-view-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+WebView::WebView()
+{
+}
+
+WebView::WebView( const WebView& WebView )
+: Control( WebView )
+{
+}
+
+WebView& WebView::operator=( const WebView& view )
+{
+  if( &view != this )
+  {
+    Control::operator=( view );
+  }
+
+  return *this;
+}
+
+WebView::~WebView()
+{
+}
+
+WebView WebView::New()
+{
+  return Internal::WebView::New();
+}
+
+WebView WebView::New( const std::string& locale, const std::string& timezoneId )
+{
+  return Internal::WebView::New( locale, timezoneId );
+}
+
+WebView WebView::DownCast( BaseHandle handle )
+{
+  return Control::DownCast< WebView, Internal::WebView >( handle );
+}
+
+void WebView::LoadUrl( const std::string& url )
+{
+  Dali::Toolkit::GetImpl( *this ).LoadUrl( url );
+}
+
+const std::string& WebView::GetUrl()
+{
+  return Dali::Toolkit::GetImpl( *this ).GetUrl();
+}
+
+void WebView::LoadHTMLString( const std::string& htmlString )
+{
+  Dali::Toolkit::GetImpl( *this ).LoadHTMLString( htmlString );
+}
+
+void WebView::Reload()
+{
+  Dali::Toolkit::GetImpl( *this ).Reload();
+}
+
+void WebView::StopLoading()
+{
+  Dali::Toolkit::GetImpl( *this ).StopLoading();
+}
+
+bool WebView::CanGoForward()
+{
+  return Dali::Toolkit::GetImpl( *this ).CanGoForward();
+}
+
+void WebView::GoForward()
+{
+  Dali::Toolkit::GetImpl( *this ).GoForward();
+}
+
+bool WebView::CanGoBack()
+{
+  return Dali::Toolkit::GetImpl( *this ).CanGoBack();
+}
+
+void WebView::GoBack()
+{
+  Dali::Toolkit::GetImpl( *this ).GoBack();
+}
+
+void WebView::EvaluateJavaScript( const std::string& script )
+{
+  Dali::Toolkit::GetImpl( *this ).EvaluateJavaScript( script );
+}
+
+void WebView::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback )
+{
+  Dali::Toolkit::GetImpl( *this ).AddJavaScriptInterface( exposedObjectName, jsFunctionName, callback );
+}
+
+void WebView::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+  Dali::Toolkit::GetImpl( *this ).RemoveJavascriptInterface( exposedObjectName, jsFunctionName );
+}
+
+void WebView::ClearHistory()
+{
+  Dali::Toolkit::GetImpl( *this ).ClearHistory();
+}
+
+void WebView::ClearCache()
+{
+  Dali::Toolkit::GetImpl( *this ).ClearCache();
+}
+
+WebView::WebViewSignalType& WebView::PageLoadStartedSignal()
+{
+  return Dali::Toolkit::GetImpl( *this ).PageLoadStartedSignal();
+}
+
+WebView::WebViewSignalType& WebView::PageLoadFinishedSignal()
+{
+  return Dali::Toolkit::GetImpl( *this ).PageLoadFinishedSignal();
+}
+
+WebView::WebView( Internal::WebView& implementation )
+: Control( implementation )
+{
+}
+
+WebView::WebView( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+  VerifyCustomActorPointer< Internal::WebView >( internal );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h
new file mode 100644 (file)
index 0000000..71d05d3
--- /dev/null
@@ -0,0 +1,269 @@
+#ifndef DALI_TOOLKIT_WEB_VIEW_H
+#define DALI_TOOLKIT_WEB_VIEW_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <functional>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+  class WebView;
+} // namespace Internal
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebView is a control for displaying web content.
+ *
+ * This enables embedding web pages in the application.
+ *
+ * For working WebView, a web engine plugin for a platform should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebView : public Control
+{
+public:
+
+  /**
+   * @brief Enumeration for the start and end property ranges for this control.
+   */
+  enum PropertyRange
+  {
+    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+    PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
+  };
+
+  /**
+   * @brief Enumeration for the instance of properties belonging to the WebView class.
+   */
+  struct Property
+  {
+    enum
+    {
+      /**
+       * @brief name "url", type string
+       *
+       * @details Sets the url to load
+       */
+      URL = PROPERTY_START_INDEX
+    };
+  };
+
+  typedef Signal< void ( WebView, const std::string& ) > WebViewSignalType;
+
+public:
+
+  /**
+   * @brief Creates an initialized WebView.
+   * @return A handle to a newly allocated Dali WebView
+   *
+   * @note WebView will not display anything
+   */
+  static WebView New();
+
+  /**
+   * @brief Creates an initialized WebView.
+   *
+   * @param [in] locale The locale of Web
+   * @param [in] timezoneId The timezoneId of Web
+   */
+  static WebView New( const std::string& locale, const std::string& timezoneId );
+
+  /**
+   * @brief Creates an uninitialized WebView.
+   */
+  WebView();
+
+  /**
+   * @brief Destructor.
+   *
+   * This is non-virtual since derived Handel types must not contain data or virtual methods.
+   */
+  ~WebView();
+
+  /*
+   * @brief Copy constructor.
+   *
+   * @param[in] WebView WebView to copy. The copied WebView will point at the same implementation
+   */
+  WebView( const WebView& WebView );
+
+  /**
+   * @brief Assignment operator.
+   *
+   * @param[in] WebView The WebView to assign from
+   * @return The updated WebView
+   */
+  WebView& operator=( const WebView& WebView );
+
+  /**
+   * @brief Downcasts a handle to WebView handle.
+   *
+   * If handle points to a WebView, the downcast produces valid handle.
+   * If not, the returned handle is left uninitialized.
+   *
+   * @param[in] handle Handle to an object
+   * @return Handle to a WebView or an uninitialized handle
+   */
+  static WebView DownCast( BaseHandle handle );
+
+  /**
+   * @brief Loads a web page based on a given URL.
+   *
+   * @param [in] url The URL of the resource to load
+   */
+  void LoadUrl( const std::string& url );
+
+  /**
+   * @brief Returns the URL of the Web.
+   *
+   * @return Url of string type
+   */
+  const std::string& GetUrl();
+
+  /**
+   * @brief Loads a given string as web contents.
+   *
+   * @param [in] htmlString The string to use as the contents of the web page
+   */
+  void LoadHTMLString( const std::string& htmlString );
+
+  /**
+   * @brief Reloads the Web.
+   */
+  void Reload();
+
+  /**
+   * @brief Stops loading web contents on the current page.
+   */
+  void StopLoading();
+
+  /**
+   * @brief Returns whether forward is possible.
+   *
+   * @return True if forward is possible, false otherwise
+   */
+  bool CanGoForward();
+
+  /**
+   * @brief Goes forward in the navigation history.
+   */
+  void GoForward();
+
+  /**
+   * @brief Returns whether backward is possible.
+   *
+   * @return True if backward is possible, false otherwise
+   */
+  bool CanGoBack();
+
+  /**
+   * @brief Goes back in the navigation history.
+   */
+  void GoBack();
+
+  /**
+    * @brief Evaluates JavaScript code represented as a string.
+    *
+    * @param[in] script The JavaScript code
+    */
+  void EvaluateJavaScript( const std::string& script );
+
+  /**
+    * @brief Adds a JavaScript interface.
+    *
+    * @param[in] exposedObjectName The name of exposed object
+    * @param[in] jsFunctionName The name of JavaScript function
+    * @param[in] callback The callback function
+    */
+  void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
+
+  /**
+    * @brief Removes a JavaScript interface.
+    *
+    * @param[in] exposedObjectName The name of exposed object
+    * @param[in] jsFunctionName The name of JavaScript function
+    */
+  void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+
+  /**
+   * @brief Clears the history of Web.
+   */
+  void ClearHistory();
+
+  /**
+   * @brief Clears the cache of Web.
+   */
+  void ClearCache();
+
+  /**
+   * @brief Connects to this signal to be notified when page loading is started.
+   *
+   * @return A signal object to connect with
+   */
+  WebViewSignalType& PageLoadStartedSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when page loading is finished.
+   *
+   * @return A signal object to connect with
+   */
+  WebViewSignalType& PageLoadFinishedSignal();
+
+public: // Not intended for application developers
+
+  /// @cond internal
+  /**
+   * @brief Creates a handle using the Toolkit::Internal implementation.
+   *
+   * @param[in] implementation The WebView implementation
+   */
+  DALI_INTERNAL WebView( Internal::WebView& implementation );
+
+  /**
+   * @brief Allows the creation of this WebView from an Internal::CustomActor pointer.
+   *
+   * @param[in] internal A pointer to the internal CustomActor
+   */
+  explicit DALI_INTERNAL WebView( Dali::Internal::CustomActor* internal );
+  /// @endcond
+
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_VIEW_H
index 056bca2..c47c73d 100755 (executable)
@@ -27,6 +27,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
   $(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.cpp \
   $(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
+  $(devel_api_src_dir)/controls/web-view/web-view.cpp \
   $(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
   $(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.cpp \
   $(devel_api_src_dir)/image-loader/async-image-loader-devel.cpp \
@@ -190,3 +191,6 @@ devel_api_transition_effects_header_files = \
 
 devel_api_gaussian_blur_view_header_files = \
   $(devel_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.h
+
+devel_api_web_view_header_files = \
+  $(devel_api_src_dir)/controls/web-view/web-view.h
diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp
new file mode 100644 (file)
index 0000000..7da5f9d
--- /dev/null
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "web-view-impl.h"
+
+// EXTERNAL INCLUDES
+#include <cstring>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+  return Toolkit::WebView::New();
+}
+
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create );
+
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL );
+
+DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL );
+DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL );
+
+DALI_TYPE_REGISTRATION_END()
+
+} // anonymous namepsace
+
+WebView::WebView( const std::string& locale, const std::string& timezoneId )
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+  mUrl(),
+  mWebViewSize( Stage::GetCurrent().GetSize() )
+{
+  mWebEngine = Dali::WebEngine::New();
+  if ( mWebEngine )
+  {
+    mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, locale, timezoneId );
+  }
+}
+
+WebView::WebView()
+: WebView( "", "" )
+{
+}
+
+WebView::~WebView()
+{
+}
+
+Toolkit::WebView WebView::New()
+{
+  WebView* impl = new WebView();
+  Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+  impl->Initialize();
+  return handle;
+}
+
+Toolkit::WebView WebView::New( const std::string& locale, const std::string& timezoneId )
+{
+  WebView* impl = new WebView( locale, timezoneId );
+  Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+  impl->Initialize();
+  return handle;
+}
+
+void WebView::OnInitialize()
+{
+  Self().SetKeyboardFocusable( true );
+  Self().TouchSignal().Connect( this, &WebView::OnTouchEvent );
+
+  if ( mWebEngine )
+  {
+    mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
+    mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
+  }
+}
+
+void WebView::LoadUrl( const std::string& url )
+{
+  mUrl = url;
+  if ( mWebEngine )
+  {
+    Dali::Image image = Dali::NativeImage::New( *mWebEngine.GetNativeImageSource() );
+    mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+
+    if ( mVisual )
+    {
+      // Clean up previously registered visual and add new one.
+      DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
+      mWebEngine.LoadUrl( url );
+    }
+  }
+}
+
+const std::string& WebView::GetUrl()
+{
+  return mWebEngine ? mWebEngine.GetUrl() : mUrl;
+}
+
+void WebView::LoadHTMLString( const std::string& htmlString )
+{
+  if ( mWebEngine )
+  {
+    Dali::Image image = Dali::NativeImage::New( *mWebEngine.GetNativeImageSource() );
+    mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+
+    if ( mVisual )
+    {
+      DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
+      mWebEngine.LoadHTMLString( htmlString );
+    }
+  }
+}
+
+void WebView::Reload()
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.Reload();
+  }
+}
+
+void WebView::StopLoading()
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.StopLoading();
+  }
+}
+
+bool WebView::CanGoForward()
+{
+  return mWebEngine ? mWebEngine.CanGoForward() : false;
+}
+
+void WebView::GoForward()
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.GoForward();
+  }
+}
+
+bool WebView::CanGoBack()
+{
+  return mWebEngine ? mWebEngine.CanGoBack() : false;
+}
+
+void WebView::GoBack()
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.GoBack();
+  }
+}
+
+void WebView::EvaluateJavaScript( const std::string& script )
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.EvaluateJavaScript( script );
+  }
+}
+
+void WebView::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback )
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.AddJavaScriptInterface( exposedObjectName, jsFunctionName, callback );
+  }
+}
+
+void WebView::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.RemoveJavascriptInterface( exposedObjectName, jsFunctionName );
+  }
+}
+
+void WebView::ClearHistory()
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.ClearHistory();
+  }
+}
+
+void WebView::ClearCache()
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.ClearCache();
+  }
+}
+
+Dali::Toolkit::WebView::WebViewSignalType& WebView::PageLoadStartedSignal()
+{
+  return mPageLoadStartedSignal;
+}
+
+Dali::Toolkit::WebView::WebViewSignalType& WebView::PageLoadFinishedSignal()
+{
+  return mPageLoadFinishedSignal;
+}
+
+void WebView::OnPageLoadStarted( const std::string& url )
+{
+  if( !mPageLoadStartedSignal.Empty() )
+  {
+    Dali::Toolkit::WebView handle( GetOwner() );
+    mPageLoadStartedSignal.Emit( handle, url );
+  }
+}
+
+void WebView::OnPageLoadFinished( const std::string& url )
+{
+  if( !mPageLoadFinishedSignal.Empty() )
+  {
+    Dali::Toolkit::WebView handle( GetOwner() );
+    mPageLoadFinishedSignal.Emit( handle, url );
+  }
+}
+
+bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+  Dali::BaseHandle handle( object );
+
+  bool connected = false;
+  Toolkit::WebView webView = Toolkit::WebView::DownCast( handle );
+
+  if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_STARTED_SIGNAL ) )
+  {
+    webView.PageLoadStartedSignal().Connect( tracker, functor );
+    connected = true;
+  }
+  else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL ) )
+  {
+    webView.PageLoadFinishedSignal().Connect( tracker, functor );
+    connected = true;
+  }
+
+  return connected;
+}
+
+Vector3 WebView::GetNaturalSize()
+{
+  if( mVisual )
+  {
+    Vector2 rendererNaturalSize;
+    mVisual.GetNaturalSize( rendererNaturalSize );
+    return Vector3( rendererNaturalSize );
+  }
+
+  return Vector3( mWebViewSize );
+}
+
+void WebView::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+  Control::OnRelayout( size, container );
+
+  if( size.width > 0 && size.height > 0 && mWebViewSize != size )
+  {
+    mWebViewSize = size;
+
+    if( mWebEngine )
+    {
+      mWebEngine.SetSize( size.width, size.height );
+    }
+  }
+}
+
+void WebView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+  Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
+
+  if( webView )
+  {
+    WebView& impl = GetImpl( webView );
+    switch( index )
+    {
+      case Toolkit::WebView::Property::URL:
+      {
+        std::string url;
+        if( value.Get( url ) )
+        {
+          impl.LoadUrl( url );
+        }
+        break;
+      }
+    }
+  }
+}
+
+Property::Value WebView::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+  Property::Value value;
+
+  Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
+
+  if( webView )
+  {
+    WebView& impl = GetImpl( webView );
+    switch( propertyIndex )
+    {
+      case Toolkit::WebView::Property::URL:
+      {
+        value = impl.GetUrl();
+        break;
+      }
+    }
+  }
+
+  return value;
+}
+
+bool WebView::OnTouchEvent( Actor actor, const Dali::TouchData& touch )
+{
+  bool result = false;
+
+  if ( mWebEngine )
+  {
+    result = mWebEngine.SendTouchEvent( touch );
+  }
+  return result;
+}
+
+bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
+{
+  bool result = false;
+
+  if ( mWebEngine )
+  {
+    result = mWebEngine.SendKeyEvent( event );
+  }
+  return result;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h
new file mode 100644 (file)
index 0000000..54a679f
--- /dev/null
@@ -0,0 +1,247 @@
+#ifndef DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
+#define DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/public-api/images/image-operations.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+class KeyEvent;
+class TouchData;
+class WebView;
+
+namespace Internal
+{
+
+class WebView : public Control
+{
+protected:
+
+  WebView();
+
+  WebView( const std::string& locale, const std::string& timezoneId );
+
+  virtual ~WebView();
+
+public:
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::New()
+   */
+  static Toolkit::WebView New();
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::New( const std::string&, const std::string& )
+   */
+  static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::LoadUrl()
+   */
+  void LoadUrl( const std::string& url );
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::GetUrl()
+   */
+  const std::string& GetUrl();
+
+  /**
+   * @copydoc Dali::WebEngine::LoadHTMLString()
+   */
+  void LoadHTMLString( const std::string& htmlString );
+
+  /**
+   * @copydoc Dali::WebEngine::Reload()
+   */
+  void Reload();
+
+  /**
+   * @copydoc Dali::WebEngine::StopLoading()
+   */
+  void StopLoading();
+
+  /**
+   * @copydoc Dali::WebEngine::CanGoForward()
+   */
+  bool CanGoForward();
+
+  /**
+   * @copydoc Dali::WebEngine::GoForward()
+   */
+  void GoForward();
+
+  /**
+   * @copydoc Dali::WebEngine::CanGoBack()
+   */
+  bool CanGoBack();
+
+  /**
+   * @copydoc Dali::WebEngine::GoBack()
+   */
+  void GoBack();
+
+  /**
+   * @copydoc Dali::WebEngine::EvaluateJavaScript()
+   */
+  void EvaluateJavaScript( const std::string& script );
+
+  /**
+   * @copydoc Dali::WebEngine::AddJavaScriptInterface()
+   */
+  void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
+
+  /**
+   * @copydoc Dali::WebEngine::RemoveJavascriptInterface()
+   */
+  void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+
+  /**
+   * @copydoc Dali::WebEngine::ClearHistory()
+   */
+  void ClearHistory();
+
+  /**
+   * @copydoc Dali::WebEngine::ClearCache()
+   */
+  void ClearCache();
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
+   */
+  Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal();
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal()
+   */
+  Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal();
+
+public: // Properties
+
+  /**
+   * @brief Called when a property of an object of this type is set.
+   *
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
+   */
+  static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
+
+  /**
+   * @brief Called to retrieve a property of an object of this type.
+   *
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
+   */
+  static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
+
+  /**
+   * Connects a callback function with the object's signals.
+   * @param[in] object The object providing the signal.
+   * @param[in] tracker Used to disconnect the signal.
+   * @param[in] signalName The signal to connect to.
+   * @param[in] functor A newly allocated FunctorDelegate.
+   * @return True if the signal was connected.
+   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
+   */
+  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+private: // From Control
+
+  /**
+   * @copydoc Toolkit::Control::OnInitialize()
+   */
+  virtual void OnInitialize();
+
+  /**
+   * @copydoc Toolkit::Control::GetNaturalSize
+   */
+  virtual Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Toolkit::Control::OnRelayout()
+   */
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+  /**
+   * Signal occurs when the Web View has been touched.
+   * @param[in] actor The Actor Touched
+   * @param[in] touch The Touch Data.
+   * @return Whether to consume event or not.
+   */
+  bool OnTouchEvent( Actor actor, const Dali::TouchData& touch );
+
+  /**
+   * @copydoc Toolkit::Control::OnKeyEvent()
+   */
+  virtual bool OnKeyEvent( const Dali::KeyEvent& event );
+
+private:
+
+  // Undefined
+  WebView( const WebView& webView );
+
+  WebView& operator=( const WebView& webView );
+
+  void OnPageLoadStarted( const std::string& url );
+
+  void OnPageLoadFinished( const std::string& url );
+
+private:
+
+  std::string mUrl;
+  Dali::Toolkit::Visual::Base mVisual;
+  Dali::Size mWebViewSize;
+  Dali::WebEngine mWebEngine;
+  Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal;
+  Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal;
+};
+
+} // namespace Internal
+
+inline Toolkit::Internal::WebView& GetImpl( Toolkit::WebView& handle )
+{
+  DALI_ASSERT_ALWAYS( handle );
+  Dali::RefObject& impl = handle.GetImplementation();
+  return static_cast< Toolkit::Internal::WebView& >( impl );
+}
+
+inline const Toolkit::Internal::WebView& GetImpl( const Toolkit::WebView& handle )
+{
+  DALI_ASSERT_ALWAYS( handle );
+  const Dali::RefObject& impl = handle.GetImplementation();
+  return static_cast< const Toolkit::Internal::WebView& >( impl );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
index a146e4d..1ab8230 100755 (executable)
@@ -104,6 +104,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \
    $(toolkit_src_dir)/controls/tooltip/tooltip.cpp \
    $(toolkit_src_dir)/controls/video-view/video-view-impl.cpp \
+   $(toolkit_src_dir)/controls/web-view/web-view-impl.cpp \
    $(toolkit_src_dir)/accessibility-manager/accessibility-manager-impl.cpp \
    \
    $(toolkit_src_dir)/feedback/feedback-style.cpp \