Add some APIs into web view. 50/254550/10
authorhuayong.xu <huayong.xu@samsung.com>
Thu, 4 Mar 2021 09:42:24 +0000 (17:42 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Mon, 29 Mar 2021 07:54:32 +0000 (15:54 +0800)
This patch is to add some APIs into web view, such as
GetScreenshot, GetScreenshotAsynchronously, FindText, etc.

Change-Id: I6bf4e68c11a408ec5f191b69a4a47d5c72657e29

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
dali-toolkit/devel-api/controls/web-view/web-view.cpp [changed mode: 0644->0755]
dali-toolkit/devel-api/controls/web-view/web-view.h
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.h [changed mode: 0755->0644]

index 5b0f13d..4c8ffb3 100755 (executable)
@@ -29,6 +29,7 @@
 #include <dali/public-api/object/any.h>
 #include <dali/public-api/object/base-object.h>
 #include <memory>
+#include <string.h>
 #include <toolkit-application.h>
 
 namespace Dali
@@ -58,6 +59,9 @@ bool OnJavaScriptAlert();
 bool OnJavaScriptConfirm();
 bool OnJavaScriptPrompt();
 bool OnScrollEdge();
+bool OnScreenshotCaptured();
+bool OnVideoPlaying();
+bool OnGeolocationPermission();
 bool OnClearHistory();
 
 static void ConnectToGlobalSignal( bool ( *func )() )
@@ -466,9 +470,6 @@ class WebEngine: public Dali::BaseObject
 public:
 
   using JavaScriptEvaluatedResultCallback = std::function<void(const std::string&)>;
-  using JavaScriptAlertCallback = std::function<bool(const std::string&)>;
-  using JavaScriptConfirmCallback = std::function<bool(const std::string&)>;
-  using JavaScriptPromptCallback = std::function<bool(const std::string&, const std::string&)>;
 
   WebEngine()
     : mUrl()
@@ -650,6 +651,16 @@ public:
     }
   }
 
+  bool ScrollEdgeBy( int dx, int dy )
+  {
+    mScrollPosition += Dali::Vector2( dx, dy );
+    if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
+    {
+      ConnectToGlobalSignal( &OnScrollEdge );
+    }
+    return true;
+  }
+
   void SetScrollPosition( int x, int y )
   {
     mScrollPosition.x = x;
@@ -668,7 +679,81 @@ public:
 
   Dali::Vector2 GetContentSize() const
   {
-    return  mContentSize;
+    return mContentSize;
+  }
+
+  void SetPageZoomFactor(float zoomFactor)
+  {
+    mPageZoomFactor = zoomFactor;
+  }
+
+  float GetPageZoomFactor() const
+  {
+    return mPageZoomFactor;
+  }
+
+  void SetTextZoomFactor(float zoomFactor)
+  {
+    mTextZoomFactor = zoomFactor;
+  }
+
+  float GetTextZoomFactor() const
+  {
+    return mTextZoomFactor;
+  }
+
+  float GetLoadProgressPercentage() const
+  {
+    return 0.5f;
+  }
+
+  void SetScaleFactor(float scaleFactor, Dali::Vector2 point)
+  {
+    mScaleFactor = scaleFactor;
+  }
+
+  float GetScaleFactor() const
+  {
+    return mScaleFactor;
+  }
+
+  Dali::PixelData GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
+  {
+    uint32_t bufferSize = viewArea.width * viewArea.height * 4 ;
+    uint8_t* pixel = new uint8_t[ bufferSize ];
+    memset(pixel, 0xff, bufferSize);
+    return Dali::PixelData::New( pixel, bufferSize, viewArea.width, viewArea.height,
+                                 Dali::Pixel::Format::RGBA8888,
+                                 Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+  }
+
+  bool GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
+  {
+    if ( callback )
+    {
+      ConnectToGlobalSignal( &OnScreenshotCaptured );
+      mScreenshotCapturedCallback = callback;
+    }
+    return true;
+  }
+
+  bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
+  {
+    if ( callback )
+    {
+      ConnectToGlobalSignal( &OnVideoPlaying );
+      mVideoPlayingCallback = callback;
+    }
+    return true;
+  }
+
+  void RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
+  {
+    if ( callback )
+    {
+      ConnectToGlobalSignal( &OnGeolocationPermission );
+      mGeolocationPermissionCallback = callback;
+    }
   }
 
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
@@ -721,6 +806,9 @@ public:
   Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType    mPageLoadErrorSignal;
   std::vector<JavaScriptEvaluatedResultCallback>             mResultCallbacks;
   bool                                                       mEvaluating;
+  float                                                      mPageZoomFactor;
+  float                                                      mTextZoomFactor;
+  float                                                      mScaleFactor;
 
   Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType  mScrollEdgeReachedSignal;
   Dali::Vector2                                                mScrollPosition;
@@ -734,9 +822,12 @@ public:
   Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType mFormRepostDecisionSignal;
   Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType      mFrameRenderedSignal;
 
-  JavaScriptAlertCallback                                     mJavaScriptAlertCallback;
-  JavaScriptConfirmCallback                                   mJavaScriptConfirmCallback;
-  JavaScriptPromptCallback                                    mJavaScriptPromptCallback;
+  Dali::WebEnginePlugin::JavaScriptAlertCallback              mJavaScriptAlertCallback;
+  Dali::WebEnginePlugin::JavaScriptConfirmCallback            mJavaScriptConfirmCallback;
+  Dali::WebEnginePlugin::JavaScriptPromptCallback             mJavaScriptPromptCallback;
+  Dali::WebEnginePlugin::ScreenshotCapturedCallback           mScreenshotCapturedCallback;
+  Dali::WebEnginePlugin::VideoPlayingCallback                 mVideoPlayingCallback;
+  Dali::WebEnginePlugin::GeolocationPermissionCallback        mGeolocationPermissionCallback;
 };
 
 
@@ -846,6 +937,41 @@ bool OnJavaScriptPrompt()
   return false;
 }
 
+bool OnScreenshotCaptured()
+{
+  DisconnectFromGlobalSignal( &OnScreenshotCaptured );
+  if ( gInstance )
+  {
+    uint8_t* pixel = new uint8_t[ 2 * 2 * 4 ];
+    memset(pixel, 0xff, 2 * 2 * 4);
+    Dali::PixelData data = Dali::PixelData::New( pixel, 2 * 2 * 4, 2, 2,
+                                 Dali::Pixel::Format::RGBA8888,
+                                 Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+    gInstance->mScreenshotCapturedCallback( data );
+  }
+  return false;
+}
+
+bool OnVideoPlaying()
+{
+  DisconnectFromGlobalSignal( &OnVideoPlaying );
+  if ( gInstance )
+  {
+    gInstance->mVideoPlayingCallback( true );
+  }
+  return false;
+}
+
+bool OnGeolocationPermission()
+{
+  DisconnectFromGlobalSignal( &OnGeolocationPermission );
+  if ( gInstance )
+  {
+    gInstance->mGeolocationPermissionCallback( "", "" );
+  }
+  return false;
+}
+
 bool OnClearHistory()
 {
   DisconnectFromGlobalSignal( &OnClearHistory );
@@ -980,10 +1106,25 @@ void WebEngine::LoadHtmlString( const std::string& htmlString )
 {
 }
 
+bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
+{
+  return true;
+}
+
+bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
+{
+  return true;
+}
+
 void WebEngine::Reload()
 {
 }
 
+bool WebEngine::ReloadWithoutCache()
+{
+  return true;
+}
+
 void WebEngine::StopLoading()
 {
 }
@@ -996,6 +1137,34 @@ void WebEngine::Resume()
 {
 }
 
+void WebEngine::SuspendNetworkLoading()
+{
+}
+
+void WebEngine::ResumeNetworkLoading()
+{
+}
+
+bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
+{
+  return true;
+}
+
+bool WebEngine::RemoveCustomHeader(const std::string& name)
+{
+  return true;
+}
+
+uint32_t WebEngine::StartInspectorServer(uint32_t port)
+{
+  return port;
+}
+
+bool WebEngine::StopInspectorServer()
+{
+  return true;
+}
+
 bool WebEngine::CanGoForward()
 {
   return Internal::Adaptor::GetImplementation( *this ).CanGoForward();
@@ -1061,6 +1230,49 @@ void WebEngine::ClearHistory()
   Internal::Adaptor::GetImplementation( *this ).ClearHistory();
 }
 
+void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
+{
+  Internal::Adaptor::GetImplementation( *this ).SetScaleFactor(scaleFactor, point);
+}
+
+float WebEngine::GetScaleFactor() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetScaleFactor();
+}
+
+void WebEngine::ActivateAccessibility(bool activated)
+{
+}
+
+bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
+{
+  return true;
+}
+
+void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
+{
+}
+
+Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetScreenshot(viewArea, scaleFactor);
+}
+
+bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
+}
+
+bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
+{
+  return Internal::Adaptor::GetImplementation( *this ).CheckVideoPlayingAsynchronously(callback);
+}
+
+void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
+{
+  Internal::Adaptor::GetImplementation( *this ).RegisterGeolocationPermissionCallback(callback);
+}
+
 const std::string& WebEngine::GetUserAgent() const
 {
   return Internal::Adaptor::GetImplementation( *this ).GetUserAgent();
@@ -1076,6 +1288,11 @@ void WebEngine::ScrollBy( int dx, int dy )
   Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
 }
 
+bool WebEngine::ScrollEdgeBy( int dx, int dy )
+{
+  return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeBy( dx, dy );
+}
+
 void WebEngine::SetScrollPosition( int x, int y )
 {
   Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
@@ -1145,6 +1362,31 @@ void WebEngine::SetFocus( bool focused )
 {
 }
 
+void WebEngine::SetPageZoomFactor(float zoomFactor)
+{
+  Internal::Adaptor::GetImplementation( *this ).SetPageZoomFactor(zoomFactor);
+}
+
+float WebEngine::GetPageZoomFactor() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetPageZoomFactor();
+}
+
+void WebEngine::SetTextZoomFactor(float zoomFactor)
+{
+  Internal::Adaptor::GetImplementation( *this ).SetTextZoomFactor(zoomFactor);
+}
+
+float WebEngine::GetTextZoomFactor() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetTextZoomFactor();
+}
+
+float WebEngine::GetLoadProgressPercentage() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetLoadProgressPercentage();
+}
+
 void WebEngine::UpdateDisplayArea( Dali::Rect< int > displayArea )
 {
 }
index 4d42e96..6058fdb 100755 (executable)
@@ -55,6 +55,9 @@ static int gEvaluateJavaScriptCallbackCalled = 0;
 static int gJavaScriptAlertCallbackCalled = 0;
 static int gJavaScriptConfirmCallbackCalled = 0;
 static int gJavaScriptPromptCallbackCalled = 0;
+static int gScreenshotCapturedCallbackCalled = 0;
+static int gVideoPlayingCallbackCalled = 0;
+static int gGeolocationPermissionCallbackCalled = 0;
 static bool gTouched = false;
 static bool gHovered = false;
 static bool gWheelEventHandled = false;
@@ -128,6 +131,22 @@ static bool OnJavaScriptPrompt( const std::string& meesage1, const std::string&
   return true;
 }
 
+static void OnScreenshotCaptured(Dali::Toolkit::ImageView)
+{
+  gScreenshotCapturedCallbackCalled++;\r
+}
+
+static void OnVideoPlaying(bool isPlaying)
+{
+  gVideoPlayingCallbackCalled++;
+}
+
+static bool OnGeolocationPermission(const std::string&, const std::string&)
+{
+  gGeolocationPermissionCallbackCalled++;
+  return true;
+}
+
 static bool OnTouched( Actor actor, const Dali::TouchEvent& touch )
 {
   gTouched = true;
@@ -365,6 +384,82 @@ int UtcDaliWebViewFocusGainedAndLost(void)
   END_TEST;
 }
 
+int UtcDaliWebViewPropertyPageZoomFactor(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.5f);
+  float zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
+  DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
+
+  view.SetProperty( WebView::Property::PAGE_ZOOM_FACTOR, 1.0f);
+  zoomFactor = view.GetProperty<float>( WebView::Property::PAGE_ZOOM_FACTOR );
+  DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewPropertyTextZoomFactor(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.5f);
+  float zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
+  DALI_TEST_EQUALS( zoomFactor, 1.5f, TEST_LOCATION );
+
+  view.SetProperty( WebView::Property::TEXT_ZOOM_FACTOR, 1.0f);
+  zoomFactor = view.GetProperty<float>( WebView::Property::TEXT_ZOOM_FACTOR );
+  DALI_TEST_EQUALS( zoomFactor, 1.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewPropertyLoadProgressPercentage(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  float percentage = view.GetProperty<float>( WebView::Property::LOAD_PROGRESS_PERCENTAGE );
+  DALI_TEST_EQUALS( percentage, 0.5f, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliWebViewMove(void)
 {
   ToolkitTestApplication application;
@@ -767,6 +862,107 @@ int UtcDaliWebViewScrollBy(void)
   DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
   DALI_TEST_CHECK( signal1 );
 
+  // scroll by and trigger scrollEdgeReached event.
+  bool result = view.ScrollEdgeBy( 50, 50 );
+  DALI_TEST_CHECK( result );
+  Test::EmitGlobalTimerSignal();
+
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_CHECK( output.x == 200 && output.y == 200 );
+  DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 2, TEST_LOCATION );
+  DALI_TEST_CHECK( signal1 );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewSetGetScaleFactorActivateAccessibility(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  view.ActivateAccessibility(true);
+  view.AddDynamicCertificatePath("host", "test/to/path");
+  bool found = view.HighlightText("test", Dali::WebEnginePlugin::FindOption::CASE_INSENSITIVE, 2);
+  DALI_TEST_CHECK( found );
+
+  view.SetScaleFactor(1.5f, Dali::Vector2(0.0f, 0.0f));
+  float result = view.GetScaleFactor();
+  DALI_TEST_EQUALS( result, 1.5f, TEST_LOCATION );
+
+  view.SetScaleFactor(1.0f, Dali::Vector2(0.0f, 0.0f));
+  result = view.GetScaleFactor();
+  DALI_TEST_EQUALS( result, 1.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewGetScreenshotSyncAndAsync(void)
+{
+  // SCROLL_POSITION
+  ToolkitTestApplication application;
+
+  char argv[] = "--test";
+  WebView view = WebView::New( 1, (char**)&argv );
+  DALI_TEST_CHECK( view );
+
+  // Check GetScreenshot
+  Dali::Rect<int> viewArea;
+  viewArea.x = 100;
+  viewArea.y = 100;
+  viewArea.width = 10;
+  viewArea.height = 10;
+  Dali::Toolkit::ImageView screenshot = view.GetScreenshot(viewArea, 1.0f);
+  DALI_TEST_CHECK( screenshot );
+  Dali::Vector3 shotsize = screenshot.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
+  DALI_TEST_CHECK( ( int )shotsize.width == viewArea.width && ( int )shotsize.height == viewArea.height );
+
+  // Check GetScreenshotAsynchronously
+  viewArea.x = 100;
+  viewArea.y = 100;
+  viewArea.width = 100;
+  viewArea.height = 100;
+  bool result = view.GetScreenshotAsynchronously(viewArea, 1.0f, &OnScreenshotCaptured);
+  DALI_TEST_CHECK( result );
+
+  Test::EmitGlobalTimerSignal();
+
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS( gScreenshotCapturedCallbackCalled, 1, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewVideoPlayingGeolocationPermission(void)
+{
+  // SCROLL_POSITION
+  ToolkitTestApplication application;
+
+  char argv[] = "--test";
+  WebView view = WebView::New( 1, (char**)&argv );
+  DALI_TEST_CHECK( view );
+
+  // Check CheckVideoPlayingAsynchronously
+  bool result = view.CheckVideoPlayingAsynchronously(&OnVideoPlaying);
+  DALI_TEST_CHECK( result );
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS( gVideoPlayingCallbackCalled, 1, TEST_LOCATION );
+
+  // Check RegisterGeolocationPermissionCallback
+  view.RegisterGeolocationPermissionCallback(&OnGeolocationPermission);
+  Test::EmitGlobalTimerSignal();
+  DALI_TEST_EQUALS( gGeolocationPermissionCallbackCalled, 1, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -813,6 +1009,71 @@ int UtcDaliWebViewJavaScriptAlertConfirmPrompt(void)
   END_TEST;
 }
 
+int UtcDaliWebViewLoadHtmlStringOverrideCurrentEntryAndContents(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+  DALI_TEST_CHECK( view );
+
+  std::string html("<body>Hello World!</body>");
+  std::string basicUri("http://basicurl");
+  std::string unreachableUrl("http://unreachableurl");
+  bool result = view.LoadHtmlStringOverrideCurrentEntry( html, basicUri, unreachableUrl );
+  DALI_TEST_CHECK( result );
+
+  application.SendNotification();
+  application.Render();
+  Test::EmitGlobalTimerSignal();
+
+  result = view.LoadContents( html, html.length(), "html/text", "utf-8", basicUri );
+  DALI_TEST_CHECK( result );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewReloadSuspendResumeNetworkLoadingCustomHeader(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_CHECK( view );
+
+  view.LoadUrl( "http://test.html" );
+  bool result = view.AddCustomHeader("key", "value");
+  DALI_TEST_CHECK( result );
+
+  result = view.ReloadWithoutCache();
+  DALI_TEST_CHECK( result );
+
+  uint32_t portNumber = view.StartInspectorServer(5000);
+  DALI_TEST_EQUALS( portNumber, 5000, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+  Test::EmitGlobalTimerSignal();
+
+  result = view.StopInspectorServer();
+  DALI_TEST_CHECK( result );
+
+  view.SuspendNetworkLoading();
+
+  result = view.RemoveCustomHeader("key");
+  DALI_TEST_CHECK( result );
+
+  view.ResumeNetworkLoading();
+
+  END_TEST;
+}
+
 int UtcDaliWebViewMethodsForCoverage(void)
 {
   ToolkitTestApplication application;
old mode 100644 (file)
new mode 100755 (executable)
index c10358a..d87468c
@@ -104,11 +104,26 @@ void WebView::LoadHtmlString(const std::string& htmlString)
   Dali::Toolkit::GetImpl(*this).LoadHtmlString(htmlString);
 }
 
+bool WebView::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
+{
+  return Dali::Toolkit::GetImpl(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
+}
+
+bool WebView::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
+{
+  return Dali::Toolkit::GetImpl(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
+}
+
 void WebView::Reload()
 {
   Dali::Toolkit::GetImpl(*this).Reload();
 }
 
+bool WebView::ReloadWithoutCache()
+{
+  return Dali::Toolkit::GetImpl(*this).ReloadWithoutCache();
+}
+
 void WebView::StopLoading()
 {
   Dali::Toolkit::GetImpl(*this).StopLoading();
@@ -124,11 +139,46 @@ void WebView::Resume()
   Dali::Toolkit::GetImpl(*this).Resume();
 }
 
+void WebView::SuspendNetworkLoading()
+{
+  Dali::Toolkit::GetImpl(*this).SuspendNetworkLoading();
+}
+
+void WebView::ResumeNetworkLoading()
+{
+  Dali::Toolkit::GetImpl(*this).ResumeNetworkLoading();
+}
+
+bool WebView::AddCustomHeader(const std::string& name, const std::string& value)
+{
+  return Dali::Toolkit::GetImpl(*this).AddCustomHeader(name, value);
+}
+
+bool WebView::RemoveCustomHeader(const std::string& name)
+{
+  return Dali::Toolkit::GetImpl(*this).RemoveCustomHeader(name);
+}
+
+uint32_t WebView::StartInspectorServer(uint32_t port)
+{
+  return Dali::Toolkit::GetImpl(*this).StartInspectorServer(port);
+}
+
+bool WebView::StopInspectorServer()
+{
+  return Dali::Toolkit::GetImpl(*this).StopInspectorServer();
+}
+
 void WebView::ScrollBy(int deltaX, int deltaY)
 {
   Dali::Toolkit::GetImpl(*this).ScrollBy(deltaX, deltaY);
 }
 
+bool WebView::ScrollEdgeBy(int deltaX, int deltaY)
+{
+  return Dali::Toolkit::GetImpl(*this).ScrollEdgeBy(deltaX, deltaY);
+}
+
 bool WebView::CanGoForward()
 {
   return Dali::Toolkit::GetImpl(*this).CanGoForward();
@@ -204,6 +254,51 @@ void WebView::ClearAllTilesResources()
   Dali::Toolkit::GetImpl(*this).ClearAllTilesResources();
 }
 
+void WebView::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
+{
+  Dali::Toolkit::GetImpl(*this).SetScaleFactor(scaleFactor, point);
+}
+
+float WebView::GetScaleFactor() const
+{
+  return Dali::Toolkit::GetImpl(*this).GetScaleFactor();
+}
+
+void WebView::ActivateAccessibility(bool activated)
+{
+  Dali::Toolkit::GetImpl(*this).ActivateAccessibility(activated);
+}
+
+bool WebView::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
+{
+  return Dali::Toolkit::GetImpl(*this).HighlightText(text, options, maxMatchCount);
+}
+
+void WebView::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
+{
+  Dali::Toolkit::GetImpl(*this).AddDynamicCertificatePath(host, certPath);
+}
+
+Dali::Toolkit::ImageView WebView::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
+{
+  return Dali::Toolkit::GetImpl(*this).GetScreenshot(viewArea, scaleFactor);
+}
+
+bool WebView::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback callback)
+{
+  return Dali::Toolkit::GetImpl(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
+}
+
+bool WebView::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
+{
+  return Dali::Toolkit::GetImpl(*this).CheckVideoPlayingAsynchronously(callback);
+}
+
+void WebView::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
+{
+  Dali::Toolkit::GetImpl(*this).RegisterGeolocationPermissionCallback(callback);
+}
+
 WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
 {
   return Dali::Toolkit::GetImpl(*this).PageLoadStartedSignal();
index 75c911d..716132e 100755 (executable)
@@ -164,6 +164,25 @@ public:
        * @note The value is read-only.
        */
       SELECTED_TEXT,
+
+      /**
+       * @brief Zoom factor of web page.
+       * @details name "pageZoomFactor", type Property::FLOAT.
+       */
+      PAGE_ZOOM_FACTOR,
+
+      /**
+       * @brief Zoom factor of text.
+       * @details name "textZoomFactor", type Property::FLOAT.
+       */
+      TEXT_ZOOM_FACTOR,
+
+      /**
+       * @brief progress percentage of loading a web page.
+       * @details name "loadProgressPercentage", type Property::FLOAT.
+       * @note The value is read-only.
+       */
+      LOAD_PROGRESS_PERCENTAGE,
     };
   };
 
@@ -190,6 +209,11 @@ public:
   };
 
   /**
+   * @brief WebView callback related with screen-shot captured.
+   */
+  using WebViewScreenshotCapturedCallback = std::function<void(Dali::Toolkit::ImageView)>;
+
+  /**
    * @brief WebView signal type related with page loading.
    */
   using WebViewPageLoadSignalType = Signal<void(WebView, const std::string&)>;
@@ -324,11 +348,40 @@ public:
   void LoadHtmlString(const std::string& htmlString);
 
   /**
+   * @brief Load the specified html string as the content of the view overriding current history entry
+   *
+   * @param[in] html HTML data to load
+   * @param[in] basicUri Base URL used for relative paths to external objects
+   * @param[in] unreachableUrl URL that could not be reached
+   *
+   * @return true if successfully loaded, false otherwise
+   */
+  bool LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl);
+
+  /**
+   * @brief Requests loading the given contents by MIME type into the view object
+   *
+   * @param[in] contents The content to load
+   * @param[in] contentSize The size of contents (in bytes)
+   * @param[in] mimeType The type of contents, if 0 is given "text/html" is assumed
+   * @param[in] encoding The encoding for contents, if 0 is given "UTF-8" is assumed
+   * @param[in] baseUri The base URI to use for relative resources
+   *
+   * @return true if successfully request, false otherwise
+   */
+  bool LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri);
+
+  /**
    * @brief Reloads the Web.
    */
   void Reload();
 
   /**
+   * @brief Reloads the current page's document without cache
+   */
+  bool ReloadWithoutCache();
+
+  /**
    * @brief Stops loading web contents on the current page.
    */
   void StopLoading();
@@ -344,13 +397,68 @@ public:
   void Resume();
 
   /**
-   * @brief Scrolls the webpage of view by deltaX and deltaY.
+   * @brief To suspend all url loading
+   */
+  void SuspendNetworkLoading();
+
+  /**
+   * @brief To resume new url network loading
+   */
+  void ResumeNetworkLoading();
+
+  /**
+   * @brief Add custom header
+   *
+   * @param[in] name custom header name to add the custom header
+   * @param[in] value custom header value to add the custom header
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool AddCustomHeader(const std::string& name, const std::string& value);
+
+  /**
+   * @brief Remove custom header
+   *
+   * @param[in] name custom header name to remove the custom header
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool RemoveCustomHeader(const std::string& name);
+
+  /**
+   * @brief Start the inspector server
+   *
+   * @param[in] port port number
+   *
+   * @return the port number
+   */
+  uint32_t StartInspectorServer(uint32_t port);
+
+  /**
+   * @brief Stop the inspector server
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool StopInspectorServer();
+
+  /**
+   * @brief Scrolls web page of view by deltaX and deltaY.
    * @param[in] deltaX The delta x of scroll
    * @param[in] deltaY The delta y of scroll
    */
   void ScrollBy(int deltaX, int deltaY);
 
   /**
+   * @brief Scrolls edge of view by deltaX and deltaY.
+   *
+   * @param[in] deltaX horizontal offset to scroll
+   * @param[in] deltaY vertical offset to scroll
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool ScrollEdgeBy(int deltaX, int deltaY);
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -378,7 +486,7 @@ public:
    * @brief Evaluates JavaScript code represented as a string.
    *
    * @param[in] script The JavaScript code
-   * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
+   * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result
    */
   void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler);
 
@@ -464,6 +572,79 @@ public:
   void ClearAllTilesResources();
 
   /**
+   * @brief Scales the current page, centered at the given point.
+   * @param[in] scaleFactor a new factor to be scaled.
+   * @param[in] point a center coordinate.
+   */
+  void SetScaleFactor(float scaleFactor, Dali::Vector2 point);
+
+  /**
+   * @brief Gets the current scale factor of the page.
+   * @return The current scale factor.
+   */
+  float GetScaleFactor() const;
+
+  /**
+   * @brief Request to activate/deactivate the accessibility usage set by web app.
+   * @param[in] activated Activate accessibility or not.
+   */
+  void ActivateAccessibility(bool activated);
+
+  /**
+   * @brief Searches and highlights the given string in the document.
+   * @param[in] text The text to find
+   * @param[in] options The options to find
+   * @param[in] maxMatchCount The maximum match count to find
+   *
+   * @return true if found & highlighted, false otherwise
+   */
+  bool HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount);
+
+  /**
+   * @brief Add dynamic certificate path.
+   * @param[in] host host that required client authentication
+   * @param[in] certPath the file path stored certificate
+   */
+  void AddDynamicCertificatePath(const std::string& host, const std::string& certPath);
+
+  /**
+   * @brief Get snapshot of the specified viewArea of page.
+   *
+   * @param[in] viewArea The rectangle of screen shot
+   * @param[in] scaleFactor The scale factor
+   *
+   * @return image view of screen shot
+   */
+  Dali::Toolkit::ImageView GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor);
+
+  /**
+   * @brief Request to get snapshot of the specified viewArea of page asynchronously.
+   *
+   * @param[in] viewArea The rectangle of screen shot
+   * @param[in] scaleFactor The scale factor
+   * @param[in] callback The callback for screen shot
+   *
+   * @return true if requested successfully, false otherwise
+   */
+  bool GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, WebViewScreenshotCapturedCallback callback);
+
+  /**
+   * @brief Asynchronous request to check if there is a video playing in the given view.
+   *
+   * @param[in] callback The callback called after checking if video is playing or not
+   *
+   * @return true if requested successfully, false otherwise
+   */
+  bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback);
+
+  /**
+   * @brief Sets callback which will be called upon geolocation permission request.
+   *
+   * @param[in] callback The callback for requesting geolocation permission
+   */
+  void RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback);
+
+  /**
    * @brief Connects to this signal to be notified when page loading is started.
    *
    * @return A signal object to connect with
@@ -473,7 +654,7 @@ public:
   /**
    * @brief Connects to this signal to be notified when page loading is in progress.
    *
-   * @return A signal object to connect with.
+   * @return A signal object to connect with
    */
   WebViewPageLoadSignalType& PageLoadInProgressSignal();
 
@@ -487,21 +668,21 @@ public:
   /**
    * @brief Connects to this signal to be notified when an error occurs in page loading.
    *
-   * @return A signal object to connect with.
+   * @return A signal object to connect with
    */
   WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
 
   /**
    * @brief Connects to this signal to be notified when scroll edge is reached.
    *
-   * @return A signal object to connect with.
+   * @return A signal object to connect with
    */
   WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
 
   /**
    * @brief Connects to this signal to be notified when url is changed.
    *
-   * @return A signal object to connect with.
+   * @return A signal object to connect with
    */
   WebViewUrlChangedSignalType& UrlChangedSignal();
 
index 3425c29..22ce395 100755 (executable)
@@ -75,6 +75,9 @@ DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "tilesClearedWhenHidden",  BOOLEAN,
 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "tileCoverAreaMultiplier", FLOAT,   TILE_COVER_AREA_MULTIPLIER)
 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "cursorEnabledByClient",   BOOLEAN, CURSOR_ENABLED_BY_CLIENT  )
 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "selectedText",            STRING,  SELECTED_TEXT             )
+DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "pageZoomFactor",          FLOAT,   PAGE_ZOOM_FACTOR          )
+DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "textZoomFactor",          FLOAT,   TEXT_ZOOM_FACTOR          )
+DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "loadProgressPercentage",  FLOAT,   LOAD_PROGRESS_PERCENTAGE  )
 
 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadStarted",    PAGE_LOAD_STARTED_SIGNAL    )
 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadInProgress", PAGE_LOAD_IN_PROGRESS_SIGNAL)
@@ -194,6 +197,7 @@ void WebView::OnInitialize()
   self.TouchedSignal().Connect(this, &WebView::OnTouchEvent);
   self.HoveredSignal().Connect(this, &WebView::OnHoverEvent);
   self.WheelEventSignal().Connect(this, &WebView::OnWheelEvent);
+  Dali::DevelActor::VisibilityChangedSignal(self).Connect(this, &WebView::OnVisibilityChanged);
 
   mPositionUpdateNotification = self.AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
   mSizeUpdateNotification     = self.AddPropertyNotification(Actor::Property::SIZE, StepCondition(1.0f, 1.0f));
@@ -245,10 +249,7 @@ Dali::Toolkit::ImageView& WebView::GetFavicon()
   if(mWebEngine)
   {
     Dali::PixelData pixelData = mWebEngine.GetFavicon();
-    std::string     url       = Dali::Toolkit::Image::GenerateUrl(pixelData);
-    mFaviconView              = Dali::Toolkit::ImageView::New(url);
-    mFaviconView.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
-    mFaviconView.SetProperty(Dali::Actor::Property::SIZE, Vector2(pixelData.GetWidth(), pixelData.GetHeight()));
+    mFaviconView              = CreateImageView(pixelData);
   }
   return mFaviconView;
 }
@@ -301,6 +302,56 @@ void WebView::LoadHtmlString(const std::string& htmlString)
   }
 }
 
+bool WebView::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
+{
+  if(!mWebEngine)
+    return false;
+
+  Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
+  const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
+  mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
+    {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
+     {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
+
+  bool result = false;
+  if(mVisual)
+  {
+    DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
+    result = mWebEngine.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
+  }
+
+  if(mVideoHoleEnabled)
+  {
+    EnableBlendMode(false);
+  }
+  return result;
+}
+
+bool WebView::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
+{
+  if(!mWebEngine)
+    return false;
+
+  Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
+  const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
+  mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
+    {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
+     {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
+
+  bool result = false;
+  if(mVisual)
+  {
+    DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
+    result = mWebEngine.LoadContents(contents, contentSize, mimeType, encoding, baseUri);
+  }
+
+  if(mVideoHoleEnabled)
+  {
+    EnableBlendMode(false);
+  }
+  return result;
+}
+
 void WebView::Reload()
 {
   if(mWebEngine)
@@ -309,6 +360,11 @@ void WebView::Reload()
   }
 }
 
+bool WebView::ReloadWithoutCache()
+{
+  return mWebEngine ? mWebEngine.ReloadWithoutCache() : false;
+}
+
 void WebView::StopLoading()
 {
   if(mWebEngine)
@@ -333,6 +389,42 @@ void WebView::Resume()
   }
 }
 
+void WebView::SuspendNetworkLoading()
+{
+  if(mWebEngine)
+  {
+    mWebEngine.SuspendNetworkLoading();
+  }
+}
+
+void WebView::ResumeNetworkLoading()
+{
+  if(mWebEngine)
+  {
+    mWebEngine.ResumeNetworkLoading();
+  }
+}
+
+bool WebView::AddCustomHeader(const std::string& name, const std::string& value)
+{
+  return mWebEngine ? mWebEngine.AddCustomHeader(name, value) : false;
+}
+
+bool WebView::RemoveCustomHeader(const std::string& name)
+{
+  return mWebEngine ? mWebEngine.RemoveCustomHeader(name) : false;
+}
+
+uint32_t WebView::StartInspectorServer(uint32_t port)
+{
+  return mWebEngine ? mWebEngine.StartInspectorServer(port) : false;
+}
+
+bool WebView::StopInspectorServer()
+{
+  return mWebEngine ? mWebEngine.StopInspectorServer() : false;
+}
+
 void WebView::ScrollBy(int deltaX, int deltaY)
 {
   if(mWebEngine)
@@ -341,6 +433,11 @@ void WebView::ScrollBy(int deltaX, int deltaY)
   }
 }
 
+bool WebView::ScrollEdgeBy(int deltaX, int deltaY)
+{
+  return mWebEngine ? mWebEngine.ScrollEdgeBy(deltaX, deltaY) : false;
+}
+
 bool WebView::CanGoForward()
 {
   return mWebEngine ? mWebEngine.CanGoForward() : false;
@@ -439,6 +536,78 @@ void WebView::ClearHistory()
   }
 }
 
+void WebView::ClearAllTilesResources()
+{
+  if(mWebEngine)
+  {
+    mWebEngine.ClearAllTilesResources();
+  }
+}
+
+void WebView::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.SetScaleFactor(scaleFactor, point);
+  }
+}
+
+float WebView::GetScaleFactor() const
+{
+  return mWebEngine ? mWebEngine.GetScaleFactor() : 0.0f;
+}
+
+void WebView::ActivateAccessibility(bool activated)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.ActivateAccessibility(activated);
+  }
+}
+
+bool WebView::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
+{
+  return mWebEngine ? mWebEngine.HighlightText(text, options, maxMatchCount) : false;
+}
+
+void WebView::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.AddDynamicCertificatePath(host, certPath);
+  }
+}
+
+Dali::Toolkit::ImageView WebView::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
+{
+  Dali::Toolkit::ImageView imageView;
+  if(mWebEngine)
+  {
+    Dali::PixelData pixelData = mWebEngine.GetScreenshot(viewArea, scaleFactor);
+    imageView                 = CreateImageView(pixelData);
+  }
+  return imageView;
+}
+
+bool WebView::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback callback)
+{
+  mScreenshotCapturedCallback = callback;
+  return mWebEngine ? mWebEngine.GetScreenshotAsynchronously(viewArea, scaleFactor, std::bind(&WebView::OnScreenshotCaptured, this, std::placeholders::_1)) : false;
+}
+
+bool WebView::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
+{
+  return mWebEngine ? mWebEngine.CheckVideoPlayingAsynchronously(callback) : false;
+}
+
+void WebView::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.RegisterGeolocationPermissionCallback(callback);
+  }
+}
+
 void WebView::UpdateDisplayArea(Dali::PropertyNotification& /*source*/)
 {
   if(!mWebEngine)
@@ -492,12 +661,12 @@ void WebView::EnableBlendMode(bool blendEnabled)
   }
 }
 
-void WebView::ClearAllTilesResources()
+Dali::Toolkit::ImageView WebView::CreateImageView(Dali::PixelData pixel)
 {
-  if(mWebEngine)
-  {
-    mWebEngine.ClearAllTilesResources();
-  }
+  std::string              url       = Dali::Toolkit::Image::GenerateUrl(pixel);
+  Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url);
+  imageView.SetProperty(Dali::Actor::Property::SIZE, Vector2(pixel.GetWidth(), pixel.GetHeight()));
+  return imageView;
 }
 
 Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
@@ -613,6 +782,23 @@ void WebView::OnFrameRendered()
   }
 }
 
+void WebView::OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type)
+{
+  if(type == Dali::DevelActor::VisibilityChange::Type::SELF)
+  {
+    SetVisibility(isVisible);
+  }
+}
+
+void WebView::OnScreenshotCaptured(Dali::PixelData pixel)
+{
+  if(mScreenshotCapturedCallback)
+  {
+    Dali::Toolkit::ImageView imageView = CreateImageView(pixel);
+    mScreenshotCapturedCallback(imageView);
+  }
+}
+
 bool WebView::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
 {
   Dali::BaseHandle handle(object);
@@ -782,6 +968,26 @@ void WebView::SetProperty(BaseObject* object, Property::Index index, const Prope
         }
         break;
       }
+      case Toolkit::WebView::Property::PAGE_ZOOM_FACTOR:
+      {
+        float input;
+        if(value.Get(input))
+        {
+          impl.SetPageZoomFactor(input);
+        }
+        break;
+      }
+      case Toolkit::WebView::Property::TEXT_ZOOM_FACTOR:
+      {
+        float input;
+        if(value.Get(input))
+        {
+          impl.SetTextZoomFactor(input);
+        }
+        break;
+      }
+      default:
+        break;
     }
   }
 }
@@ -847,6 +1053,21 @@ Property::Value WebView::GetProperty(BaseObject* object, Property::Index propert
         value = impl.GetSelectedText();
         break;
       }
+      case Toolkit::WebView::Property::PAGE_ZOOM_FACTOR:
+      {
+        value = impl.GetPageZoomFactor();
+        break;
+      }
+      case Toolkit::WebView::Property::TEXT_ZOOM_FACTOR:
+      {
+        value = impl.GetTextZoomFactor();
+        break;
+      }
+      case Toolkit::WebView::Property::LOAD_PROGRESS_PERCENTAGE:
+      {
+        value = impl.GetLoadProgressPercentage();
+        break;
+      }
       default:
         break;
     }
@@ -1013,6 +1234,42 @@ void WebView::EnableKeyEvents(bool enabled)
   }
 }
 
+void WebView::SetPageZoomFactor(float zoomFactor)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.SetPageZoomFactor(zoomFactor);
+  }
+}
+
+float WebView::GetPageZoomFactor() const
+{
+  return mWebEngine ? mWebEngine.GetPageZoomFactor() : 0.0f;
+}
+
+void WebView::SetTextZoomFactor(float zoomFactor)
+{
+  if(mWebEngine)
+  {
+    mWebEngine.SetTextZoomFactor(zoomFactor);
+  }
+}
+
+float WebView::GetTextZoomFactor() const
+{
+  return mWebEngine ? mWebEngine.GetTextZoomFactor() : 0.0f;
+}
+
+float WebView::GetLoadProgressPercentage() const
+{
+  return mWebEngine ? mWebEngine.GetLoadProgressPercentage() : 0.0f;
+}
+
+bool WebView::SetVisibility(bool visible)
+{
+  return mWebEngine ? mWebEngine.SetVisibility(visible) : false;
+}
+
 #undef GET_ENUM_STRING
 #undef GET_ENUM_VALUE
 
old mode 100755 (executable)
new mode 100644 (file)
index 24eda62..6898afa
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/adaptor-framework/web-engine.h>
 #include <dali/public-api/images/image-operations.h>
 #include <dali/public-api/object/property-notification.h>
@@ -67,6 +68,11 @@ public:
   static Toolkit::WebView New(const std::string& locale, const std::string& timezoneId);
 
   /**
+   * @copydoc Dali::Toolkit::WebView::New( int, char** )
+   */
+  static Toolkit::WebView New(int argc, char** argv);
+
+  /**
    * @brief Get settings of WebEngine.
    */
   Dali::Toolkit::WebSettings* GetSettings() const;
@@ -87,11 +93,6 @@ public:
   Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
 
   /**
-   * @copydoc Dali::Toolkit::WebView::New( int, char** )
-   */
-  static Toolkit::WebView New(int argc, char** argv);
-
-  /**
    * @brief Get Favicon of web page.
    *
    * @return Handle to a fav icon
@@ -109,11 +110,26 @@ public:
   void LoadHtmlString(const std::string& htmlString);
 
   /**
+   * @copydoc Dali::WebEngine::LoadHtmlStringOverrideCurrentEntry()
+   */
+  bool LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl);
+
+  /**
+   * @copydoc Dali::WebEngine::LoadContents()
+   */
+  bool LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri);
+
+  /**
    * @copydoc Dali::Toolkit::WebView::Reload()
    */
   void Reload();
 
   /**
+   * @copydoc Dali::WebEngine::ReloadWithoutCache()
+   */
+  bool ReloadWithoutCache();
+
+  /**
    * @copydoc Dali::Toolkit::WebView::StopLoading()
    */
   void StopLoading();
@@ -129,11 +145,46 @@ public:
   void Resume();
 
   /**
+   * @copydoc Dali::WebEngine::SuspendNetworkLoading()
+   */
+  void SuspendNetworkLoading();
+
+  /**
+   * @copydoc Dali::WebEngine::ResumeNetworkLoading()
+   */
+  void ResumeNetworkLoading();
+
+  /**
+   * @copydoc Dali::WebEngine::AddCustomHeader()
+   */
+  bool AddCustomHeader(const std::string& name, const std::string& value);
+
+  /**
+   * @copydoc Dali::WebEngine::RemoveCustomHeader()
+   */
+  bool RemoveCustomHeader(const std::string& name);
+
+  /**
+   * @copydoc Dali::WebEngine::StartInspectorServer()
+   */
+  uint32_t StartInspectorServer(uint32_t port);
+
+  /**
+   * @copydoc Dali::WebEngine::StopInspectorServer()
+   */
+  bool StopInspectorServer();
+
+  /**
    * @copydoc Dali::Toolkit::WebView::ScrollBy()
    */
   void ScrollBy(int deltaX, int deltaY);
 
   /**
+   * @copydoc Dali::WebEngine::ScrollEdgeBy()
+   */
+  bool ScrollEdgeBy(int deltaX, int deltaY);
+
+  /**
    * @copydoc Dali::Toolkit::WebView::CanGoForward()
    */
   bool CanGoForward();
@@ -204,6 +255,51 @@ public:
   void ClearAllTilesResources();
 
   /**
+   * @copydoc Dali::Toolkit::WebView::SetScaleFactor()
+   */
+  void SetScaleFactor(float scaleFactor, Dali::Vector2 point);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::GetScaleFactor()
+   */
+  float GetScaleFactor() const;
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::ActivateAccessibility()
+   */
+  void ActivateAccessibility(bool activated);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::HighlightText()
+   */
+  bool HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::AddDynamicCertificatePath()
+   */
+  void AddDynamicCertificatePath(const std::string& host, const std::string& certPath);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::GetScreenshot()
+   */
+  Dali::Toolkit::ImageView GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::GetScreenshotAsynchronously()
+   */
+  bool GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::CheckVideoPlayingAsynchronously()
+   */
+  bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterGeolocationPermissionCallback()
+   */
+  void RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback);
+
+  /**
    * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
    */
   Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadStartedSignal();
@@ -390,6 +486,44 @@ private:
   void SetUserAgent(const std::string& userAgent);
 
   /**
+   * @brief Sets zoom factor of the current page.
+   * @param[in] zoomFactor a new factor to be set.
+   */
+  void SetPageZoomFactor(float zoomFactor);
+
+  /**
+   * @brief Queries the current zoom factor of the page。
+   * @return The current page zoom factor.
+   */
+  float GetPageZoomFactor() const;
+
+  /**
+   * @brief Sets the current text zoom level。.
+   * @param[in] zoomFactor a new factor to be set.
+   */
+  void SetTextZoomFactor(float zoomFactor);
+
+  /**
+   * @brief Gets the current text zoom level.
+   * @return The current text zoom factor.
+   */
+  float GetTextZoomFactor() const;
+
+  /**
+   * @brief Gets the current load progress of the page.
+   * @return The load progress of the page.
+   */
+  float GetLoadProgressPercentage() const;
+
+  /**
+   * @brief Request to set the current page's visibility.
+   * @param[in] visible Visible or not.
+   *
+   * @return true if succeeded, false otherwise
+   */
+  bool SetVisibility(bool visible);
+
+  /**
    * @brief Updates display area of web view.
    * @param[in] source The soource triggers Notification.
    */
@@ -422,6 +556,13 @@ private:
   void EnableKeyEvents(bool enabled);
 
   /**
+   * @brief Create image view by pixel data.
+   * @param[in] pixel Pixel data
+   * @return The new image view
+   */
+  Dali::Toolkit::ImageView CreateImageView(Dali::PixelData pixel);
+
+  /**
    * @brief Callback function to be called when page load started.
    * @param[in] url The url currently being loaded
    */
@@ -493,18 +634,34 @@ private:
    */
   void OnFrameRendered();
 
+  /**
+   * @brief Callback function to be called when visibility is changed.
+   * @param[in] actor The actor, or child of actor, whose visibility has changed
+   * @param[in] isVisible Whether the actor is now visible or not
+   * @param[in] type, Whether the actor's visible property has changed or a parent's
+   */
+  void OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type);
+
+  /**
+   * @brief callback for screen shot captured.
+   * @param[in] pixel Pixel data of screen shot.
+   */
+  void OnScreenshotCaptured(Dali::PixelData pixel);
+
 private:
   std::string                 mUrl;
   Dali::Toolkit::Visual::Base mVisual;
   Dali::Size                  mWebViewSize;
   Dali::WebEngine             mWebEngine;
 
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType          mPageLoadStartedSignal;
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType          mPageLoadInProgressSignal;
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType          mPageLoadFinishedSignal;
-  Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType     mPageLoadErrorSignal;
-  Dali::Toolkit::WebView::WebViewUrlChangedSignalType        mUrlChangedSignal;
-  Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+  Dali::Toolkit::WebView::WebViewPageLoadSignalType           mPageLoadStartedSignal;
+  Dali::Toolkit::WebView::WebViewPageLoadSignalType           mPageLoadInProgressSignal;
+  Dali::Toolkit::WebView::WebViewPageLoadSignalType           mPageLoadFinishedSignal;
+  Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType      mPageLoadErrorSignal;
+  Dali::Toolkit::WebView::WebViewUrlChangedSignalType         mUrlChangedSignal;
+  Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType  mScrollEdgeReachedSignal;
+  Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType mFormRepostDecisionSignal;
+  Dali::Toolkit::WebView::WebViewFrameRenderedSignalType      mFrameRenderedSignal;
 
   std::unique_ptr<Dali::Toolkit::WebContext>         mWebContext;
   std::unique_ptr<Dali::Toolkit::WebCookieManager>   mWebCookieManager;
@@ -512,16 +669,15 @@ private:
   std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
   Dali::Toolkit::ImageView                           mFaviconView;
 
-  Dali::PropertyNotification                          mPositionUpdateNotification;
-  Dali::PropertyNotification                          mSizeUpdateNotification;
-  Dali::PropertyNotification                          mScaleUpdateNotification;
-  bool                                                mVideoHoleEnabled;
-  Dali::Rect<int>                                     mWebViewArea;
-  bool                                                mMouseEventsEnabled;
-  bool                                                mKeyEventsEnabled;
+  Dali::PropertyNotification mPositionUpdateNotification;
+  Dali::PropertyNotification mSizeUpdateNotification;
+  Dali::PropertyNotification mScaleUpdateNotification;
+  bool                       mVideoHoleEnabled;
+  Dali::Rect<int>            mWebViewArea;
+  bool                       mMouseEventsEnabled;
+  bool                       mKeyEventsEnabled;
 
-  Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType mFormRepostDecisionSignal;
-  Dali::Toolkit::WebView::WebViewFrameRenderedSignalType      mFrameRenderedSignal;
+  Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback mScreenshotCapturedCallback;
 };
 
 } // namespace Internal