[Tizen] Update contents of webview when frame is rendered.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view / web-view-impl.h
old mode 100644 (file)
new mode 100755 (executable)
index c41be87..d10a888
  */
 
 // EXTERNAL INCLUDES
+#include <memory>
 #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>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
 #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>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 
 namespace Dali
 {
@@ -35,6 +38,10 @@ namespace Toolkit
 
 class KeyEvent;
 class TouchEvent;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
 class WebView;
 
 namespace Internal
@@ -48,6 +55,8 @@ protected:
 
   WebView( const std::string& locale, const std::string& timezoneId );
 
+  WebView( int argc, char** argv );
+
   virtual ~WebView();
 
 public:
@@ -63,6 +72,43 @@ public:
   static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
 
   /**
+   * @brief Get settings of WebEngine.
+   */
+  Dali::Toolkit::WebSettings* GetSettings() const;
+
+  /**
+   * @brief Get context of WebEngine.
+   */
+  Dali::Toolkit::WebContext* GetContext() const;
+
+  /**
+   * @brief Get cookie manager of WebEngine.
+   */
+  Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+  /**
+   * @brief Get WebBackForwardList of WebEngine.
+   */
+  Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::New( int, char** )
+   */
+  static Toolkit::WebView New( int argc, char** argv );
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::GetPlugin()
+   */
+  Dali::WebEnginePlugin* GetPlugin() const;
+
+  /**
+   * @brief Get favicon of web page.
+   *
+   * @return Handle to a favicon
+   */
+  Dali::Toolkit::ImageView GetFavicon() const;
+
+  /**
    * @copydoc Dali::Toolkit::WebView::LoadUrl()
    */
   void LoadUrl( const std::string& url );
@@ -70,7 +116,7 @@ public:
   /**
    * @copydoc Dali::WebEngine::LoadHTMLString()
    */
-  void LoadHTMLString( const std::string& htmlString );
+  void LoadHtmlString( const std::string& htmlString );
 
   /**
    * @copydoc Dali::Toolkit::WebView::Reload()
@@ -93,6 +139,11 @@ public:
   void Resume();
 
   /**
+   * @copydoc Dali::Toolkit::WebView::ScrollBy()
+   */
+  void ScrollBy( int deltaX, int deltaY );
+
+  /**
    * @copydoc Dali::Toolkit::WebView::CanGoForward()
    */
   bool CanGoForward();
@@ -115,12 +166,17 @@ public:
   /**
    * @copydoc Dali::Toolkit::WebView::EvaluateJavaScript()
    */
-  void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler );
+  void EvaluateJavaScript( const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler );
 
   /**
    * @copydoc Dali::Toolkit::WebView::AddJavaScriptMessageHandler()
    */
-  void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler );
+  void AddJavaScriptMessageHandler( const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler );
+
+  /**
+   * @brief Clears all tiles resources of Web.
+   */
+  void ClearAllTilesResources();
 
   /**
    * @copydoc Dali::Toolkit::WebView::ClearHistory()
@@ -128,29 +184,49 @@ public:
   void ClearHistory();
 
   /**
-   * @copydoc Dali::Toolkit::WebView::ClearCache()
+   * @copydoc Dali::Toolkit::WebView::SetTtsFocus()
    */
-  void ClearCache();
+  void SetTtsFocus(bool focused);
 
   /**
-   * @copydoc Dali::Toolkit::WebView::ClearCookies()
+   * @copydoc Dali::Toolkit::WebView::RegisterPageLoadStartedCallback()
    */
-  void ClearCookies();
+  void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback);
 
   /**
-   * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
+   * @copydoc Dali::Toolkit::WebView::RegisterPageLoadFinishedCallback()
    */
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadStartedSignal();
+  void RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback);
 
   /**
-   * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal()
+   * @copydoc Dali::Toolkit::WebView::RegisterPageLoadErrorCallback()
    */
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadFinishedSignal();
+  void RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback);
 
   /**
-   * @copydoc Dali::Toolkit::WebView::PageLoadErrorSignal()
+   * @copydoc Dali::Toolkit::WebView::RegisterScrollEdgeReachedCallback()
    */
-  Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+  void RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterUrlChangedCallback()
+   */
+  void RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterNavigationPolicyDecidedCallback()
+   */
+  void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::RegisterNewWindowCreatedCallback()
+   */
+  void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::GetPlainTextAsynchronously()
+   */
+  void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
 
 public: // Properties
 
@@ -172,17 +248,6 @@ public: // Properties
    */
   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
 
   /**
@@ -196,11 +261,6 @@ private: // From Control
   Vector3 GetNaturalSize() override;
 
   /**
-   * @copydoc Toolkit::Control::OnRelayout()
-   */
-  void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
-
-  /**
    * Signal occurs when the Web View has been touched.
    * @param[in] actor The Actor Touched
    * @param[in] touch The Touch Data.
@@ -213,136 +273,120 @@ private: // From Control
    */
   bool OnKeyEvent( const Dali::KeyEvent& event ) override;
 
-private:
-
-  // Undefined
-  WebView( const WebView& webView );
-
-  WebView& operator=( const WebView& webView );
-
   /**
-   * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
-   * @see Toolkit::WebView::CacheModel::Type
+   * @copydoc Toolkit::Control::OnKeyInputFocusGained()
    */
-  Toolkit::WebView::CacheModel::Type GetCacheModel() const;
+  void OnKeyInputFocusGained() override;
 
   /**
-   * @brief Set cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
-   * @param[in] cacheModel The cache model option
-   * @see Toolkit::WebView::CacheModel::Type
+   * @copydoc Toolkit::Control::OnKeyInputFocusLost()
    */
-  void SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel );
+  void OnKeyInputFocusLost() override;
 
   /**
-   * @brief Gets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
-   * @see Toolkit::WebView::CookieAcceptPolicy::Type
+   * @brief Callback for notifying frame rendered.
    */
-  Toolkit::WebView::CookieAcceptPolicy::Type GetCookieAcceptPolicy() const;
+  void OnFrameRendered();
 
   /**
-   * @brief Sets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
-   * @param[in] policy The cookie acceptance policy
-   * @see Toolkit::WebView::CookieAcceptPolicy::Type
+   * @brief Callback for updating display area of web view.
+   * @param[in] source The soource triggers Notification.
    */
-  void SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy );
+  void OnDisplayAreaUpdated(Dali::PropertyNotification& source);
 
   /**
-   * @brief Get user agent string.
-   * @return The string value of user agent
+   * @copydoc Toolkit::Control::OnSceneConnection()
    */
-  const std::string& GetUserAgent() const;
+  void OnSceneConnection( int depth ) override;
 
-  /**
-   * @brief Set user agent string.
-   * @param[in] userAgent The string value of user agent
-   */
-  void SetUserAgent( const std::string& userAgent );
+private:
 
-  /**
-   * @brief Returns whether JavaScript can be executable. The default is true.
-   *
-   * @return true if JavaScript executing is enabled, false otherwise
-   */
-  bool IsJavaScriptEnabled() const;
+  // Undefined
+  WebView( const WebView& webView );
+
+  WebView& operator=( const WebView& webView );
 
   /**
-   * @brief Enables/disables JavaScript executing. The default is enabled.
-   *
-   * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+   * @brief Sets an absolute scroll of the given view.
+   * @param[in] x The coordinate x of scroll
+   * @param[in] y The coordinate y of scroll
    */
-  void EnableJavaScript( bool enabled );
+  void SetScrollPosition( int x, int y );
 
   /**
-   * @brief Returns whether images can be loaded automatically. The default is true.
-   *
-   * @return true if images are loaded automatically, false otherwise
+   * @brief Gets the current scroll position of the given view.
+   * @param[out] x The coordinate x of scroll
+   * @param[out] y The coordinate y of scroll
    */
-  bool AreImagesAutomaticallyLoaded() const;
+  void GetScrollPosition( int& x, int& y ) const;
 
   /**
-   * @brief Enables/disables auto loading of images. The default is enabled.
-   *
-   * @param[in] automatic True if images are loaded automatically, false otherwise
+   * @brief Gets the possible scroll size of the given view.
+   * @param[out] width The width of scroll size
+   * @param[out] height The height of scroll size
    */
-  void LoadImagesAutomatically( bool automatic );
+  void GetScrollSize( int& width, int& height ) const;
 
   /**
-   * @brief Gets the default text encoding name (e.g. UTF-8).
-   *
-   * @return The default text encoding name
+   * @brief Gets the last known content's size.
+   * @param[out] width The width of content's size
+   * @param[out] height The height of content's size
    */
-  const std::string& GetDefaultTextEncodingName() const;
+  void GetContentSize( int& width, int& height ) const;
 
   /**
-   * @brief Sets the default text encoding name (e.g. UTF-8).
-   *
-   * @param[in] defaultTextEncodingName The default text encoding name
+   * @brief Get current url.
+   * @return The string value of current url
    */
-  void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+  std::string GetUrl() const;
 
   /**
-   * @brief Returns the default font size in pixel. The default value is 16.
+   * @brief Returns the title of the Web.
    *
-   * @return The default font size
+   * @return The title of web page
    */
-  int GetDefaultFontSize() const;
+  std::string GetTitle() const;
 
   /**
-   * @brief Sets the default font size in pixel. The default value is 16.
-   *
-   * @param[in] defaultFontSize A new default font size to set
+   * @brief Get user agent string.
+   * @return The string value of user agent
    */
-  void SetDefaultFontSize( int defaultFontSize );
+  std::string GetUserAgent() const;
 
   /**
-   * @brief Callback function to be called when page load started.
-   * @param[in] url The url currently being loaded
+   * @brief Set user agent string.
+   * @param[in] userAgent The string value of user agent
    */
-  void OnPageLoadStarted( const std::string& url );
+  void SetUserAgent( const std::string& userAgent );
 
   /**
-   * @brief Callback function to be called when page load finished.
-   * @param[in] url The url currently being loaded
+   * @brief Enable/Disable video hole for video playing.
+   * @param[in] enabled True if video hole is enabled, false otherwise.
    */
-  void OnPageLoadFinished( const std::string& url );
+  void EnableVideoHole( bool enabled );
 
   /**
-   * @brief Callback function to be called when there is an error in page loading.
-   * @param[in] url The url currently being loaded
-   * @param[in] errorCode The error code
+   * @brief Enable blend mode.
+   * @param[in] blendEnabled True if turn on blend mode, false otherwise.
    */
-  void OnPageLoadError( const std::string& url, int errorCode );
+  void EnableBlendMode( bool blendEnabled );
 
 private:
 
-  std::string                                            mUrl;
-  Dali::Toolkit::Visual::Base                            mVisual;
-  Dali::Size                                             mWebViewSize;
-  Dali::WebEngine                                        mWebEngine;
+  Dali::Toolkit::Visual::Base                        mVisual;
+  Dali::Size                                         mWebViewSize;
+  Dali::WebEngine                                    mWebEngine;
+
+  std::unique_ptr<Dali::Toolkit::WebContext>         mWebContext;
+  std::unique_ptr<Dali::Toolkit::WebCookieManager>   mWebCookieManager;
+  std::unique_ptr<Dali::Toolkit::WebSettings>        mWebSettings;
+  std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
 
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType      mPageLoadStartedSignal;
-  Dali::Toolkit::WebView::WebViewPageLoadSignalType      mPageLoadFinishedSignal;
-  Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal;
+  Dali::PropertyNotification                         mPositionUpdateNotification;
+  Dali::PropertyNotification                         mSizeUpdateNotification;
+  Dali::PropertyNotification                         mScaleUpdateNotification;
+  bool                                               mVideoHoleEnabled;
+  Dali::Rect< int >                                  mWebViewArea;
 };
 
 } // namespace Internal