[Tizen] Add an API for 'create,window' event.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / web-view / web-view.h
old mode 100644 (file)
new mode 100755 (executable)
index 83b5ebd..c65e412
 #include <functional>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
 #include <dali-toolkit/public-api/controls/control.h>
 
 namespace Dali
 {
 namespace Toolkit
 {
+class ImageView;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
+
 namespace Internal DALI_INTERNAL
 {
 class WebView;
@@ -49,59 +56,6 @@ class WebView;
 class DALI_TOOLKIT_API WebView : public Control
 {
 public:
-  /**
-   * @brief A structure used to contain the cache model enumeration.
-   */
-  struct CacheModel
-  {
-    /**
-     * @brief Enumeration for cache model options.
-     */
-    enum Type
-    {
-      /**
-       * @brief Use the smallest cache capacity.
-       */
-      DOCUMENT_VIEWER,
-
-      /**
-       * @brief Use the bigger cache capacity than DocumentBrowser.
-       */
-      DOCUMENT_BROWSER,
-
-      /**
-       * @brief Use the biggest cache capacity.
-       */
-      PRIMARY_WEB_BROWSER
-    };
-  };
-
-  /**
-   * @brief A structure used to contain the cookie acceptance policy enumeration.
-   */
-  struct CookieAcceptPolicy
-  {
-    /**
-     * @brief Enumeration for the cookies accept policies.
-     */
-    enum Type
-    {
-      /**
-       * @brief Accepts every cookie sent from any page.
-       */
-      ALWAYS,
-
-      /**
-       * @brief Rejects all the cookies.
-       */
-      NEVER,
-
-      /**
-       * @brief Accepts only cookies set by the main document that is loaded.
-       */
-      NO_THIRD_PARTY
-    };
-  };
 
   /**
    * @brief Enumeration for the start and end property ranges for this control.
@@ -126,54 +80,44 @@ public:
       URL = PROPERTY_START_INDEX,
 
       /**
-       * @brief The cache model.
-       * @details Name "cacheModel", type WebView::CacheModel::Type (Property::INTEGER) or Property::STRING.
-       * @note Default is WebView::CacheModel::DOCUMENT_VIEWER.
-       * @see WebView::CacheModel::Type
-       */
-      CACHE_MODEL,
-
-      /**
-       * @brief The cookie acceptance policy.
-       * @details Name "cookieAcceptPolicy", type WebView::CookieAcceptPolicy::Type (Property::INTEGER) or Property::STRING.
-       * @note Default is WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
-       * @see WebView::CookieAcceptPolicy::Type
+       * @brief The user agent string.
+       * @details name "userAgent", type Property::STRING.
        */
-      COOKIE_ACCEPT_POLICY,
+      USER_AGENT,
 
       /**
-       * @brief The user agent string.
-       * @details Name "userAgent", type Property::STRING.
+       * @brief The current position of scroll.
+       * @details name "scrollPosition", type Property::VECTOR2.
        */
-      USER_AGENT,
+      SCROLL_POSITION,
 
       /**
-       * @brief Whether JavaScript is enabled.
-       * @details Name "enableJavaScript", type Property::BOOLEAN.
-       * @note Default is true.
+       * @brief The current size of scroll.
+       * @details name "scrollSize", type Property::VECTOR2.
+       * @note The value is read-only.
        */
-      ENABLE_JAVASCRIPT,
+      SCROLL_SIZE,
 
       /**
-       * @brief Whether images can be loaded automatically.
-       * @details Name "loadImagesAutomatically", type Property::BOOLEAN.
-       * @note Default is true.
+       * @brief The current size of content.
+       * @details name "contentSize", type Property::VECTOR2.
+       * @note The value is read-only.
        */
-      LOAD_IMAGES_AUTOMATICALLY,
+      CONTENT_SIZE,
 
       /**
-       * @brief The default text encoding name.
-       * @details Name "defaultTextEncodingName", type Property::STRING.
-       * @note If the value is not set, the web engine detects web page's text encoding.
+       * @brief The title of web page.
+       * @details name "title", type Property::STRING.
+       * @note The value is read-only.
        */
-      DEFAULT_TEXT_ENCODING_NAME,
+      TITLE,
 
       /**
-       * @brief The default font size in pixel.
-       * @details Name "defaultFontSize", type Property::INT.
-       * @note Default is 16.
+       * @brief Whether video hole is enabled or not.
+       * @details name "videoHoleEnabled", type Property::BOOLEAN.
+       * @note The value is read-only.
        */
-      DEFAULT_FONT_SIZE
+      VIDEO_HOLE_ENABLED,
     };
   };
 
@@ -182,92 +126,23 @@ public:
    */
   enum class LoadErrorCode
   {
-    /**
-     * @brief Unknown.
-     */
-    UNKNOWN = 0,
-
-    /**
-     * @brief User canceled.
-     */
-    CANCELED,
-
-    /**
-     * @brief Can't show the page for this MIME type.
-     */
-    CANT_SUPPORT_MIMETYPE,
-
-    /**
-     * @brief File IO error.
-     */
-    FAILED_FILE_IO,
-
-    /**
-     * @brief Cannot connect to the network.
-     */
-    CANT_CONNECT,
-
-    /**
-     * @brief Fail to look up host from the DNS.
-     */
-    CANT_LOOKUP_HOST,
-
-    /**
-     * @brief Fail to SSL/TLS handshake.
-     */
-    FAILED_TLS_HANDSHAKE,
-
-    /**
-     * @brief Received certificate is invalid.
-     */
-    INVALID_CERTIFICATE,
-
-    /**
-     * @brief Connection timeout.
-     */
-    REQUEST_TIMEOUT,
-
-    /**
-     * @brief Too many redirects.
-     */
-    TOO_MANY_REDIRECTS,
-
-    /**
-     * @brief Too many requests during this load.
-     */
-    TOO_MANY_REQUESTS,
-
-    /**
-     * @brief Malformed URL.
-     */
-    BAD_URL,
-
-    /**
-     * @brief Unsupported scheme.
-     */
-    UNSUPPORTED_SCHEME,
-
-    /**
-     * @brief User authentication failed on the server.
-     */
-    AUTHENTICATION,
-
-    /**
-     * @brief Web server has an internal server error.
-     */
-    INTERNAL_SERVER
+    UNKNOWN = 0,            ///< Unknown.
+    CANCELED,               ///< User canceled.
+    CANT_SUPPORT_MIMETYPE,  ///< Can't show the page for this MIME type.
+    FAILED_FILE_IO,         ///< File IO error.
+    CANT_CONNECT,           ///< Cannot connect to the network.
+    CANT_LOOKUP_HOST,       ///< Fail to look up host from the DNS.
+    FAILED_TLS_HANDSHAKE,   ///< Fail to SSL/TLS handshake.
+    INVALID_CERTIFICATE,    ///< Received certificate is invalid.
+    REQUEST_TIMEOUT,        ///< Connection timeout.
+    TOO_MANY_REDIRECTS,     ///< Too many redirects.
+    TOO_MANY_REQUESTS,      ///< Too many requests during this load.
+    BAD_URL,                ///< Malformed URL.
+    UNSUPPORTED_SCHEME,     ///< Unsupported scheme.
+    AUTHENTICATION,         ///< User authentication failed on the server.
+    INTERNAL_SERVER         ///< Web server has an internal server error.
   };
 
-  /**
-   * @brief WebView signal type related with page loading.
-   */
-  typedef Signal<void(WebView, const std::string&)> WebViewPageLoadSignalType;
-
-  /**
-   * @brief WebView signal type related with page loading error.
-   */
-  typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
-
 public:
   /**
    * @brief Creates an initialized WebView.
@@ -286,6 +161,14 @@ public:
   static WebView New(const std::string& locale, const std::string& timezoneId);
 
   /**
+   * @brief Creates an initialized WebView.
+   *
+   * @param [in] argc The count of arguments of Applications
+   * @param [in] argv The string array of arguments of Applications
+   */
+  static WebView New( int argc, char** argv );
+
+  /**
    * @brief Creates an uninitialized WebView.
    */
   WebView();
@@ -324,6 +207,38 @@ public:
   static WebView DownCast(BaseHandle handle);
 
   /**
+   * @brief Get WebSettings of WebEngine.
+   */
+  Dali::Toolkit::WebSettings* GetSettings() const;
+
+  /**
+   * @brief Get WebContext of WebEngine.
+   */
+  Dali::Toolkit::WebContext* GetContext() const;
+
+  /**
+   * @brief Get CookieManager of WebEngine.
+   */
+  Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+  /**
+   * @brief Get WebBackForwardList of WebEngine.
+   */
+  Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+  /**
+   * @brief Gets web engine plugin.
+   */
+  Dali::WebEnginePlugin* GetPlugin() const;
+
+  /**
+   * @brief Get favicon of web page.
+   *
+   * @return Handle to a favicon
+   */
+  Dali::Toolkit::ImageView GetFavicon() const;
+
+  /**
    * @brief Loads a web page based on a given URL.
    *
    * @param [in] url The URL of the resource to load
@@ -335,7 +250,7 @@ public:
    *
    * @param [in] htmlString The string to use as the contents of the web page
    */
-  void LoadHTMLString(const std::string& htmlString);
+  void LoadHtmlString(const std::string& htmlString);
 
   /**
    * @brief Reloads the Web.
@@ -358,6 +273,13 @@ public:
   void Resume();
 
   /**
+   * @brief Scrolls the webpage 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 Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -387,7 +309,7 @@ public:
    * @param[in] script The JavaScript code
    * @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);
+  void EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler);
 
   /**
    * @brief Evaluates JavaScript code represented as a string.
@@ -420,7 +342,12 @@ public:
    * @param[in] exposedObjectName The name of exposed object
    * @param[in] handler The callback function
    */
-  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();
 
   /**
    * @brief Clears the history of Web.
@@ -428,35 +355,67 @@ public:
   void ClearHistory();
 
   /**
-   * @brief Clears the cache of Web.
+   * @brief Set or unset TTS focus of the webview.
+   * @param[in] focused True if it is gained, false lost.
+   * @note It only works when the webview does not have keyinput focus. If it has keyinput focus, the TTS focus is set automatically.
+   */
+  void SetTtsFocus(bool focused);
+
+  /**
+   * @brief Callback to be called when page loading is started.
+   *
+   * @param[in] callback
+   */
+  void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback);
+
+  /**
+   * @brief Callback to be called when page loading is finished.
+   *
+   * @param[in] callback
+   */
+  void RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback);
+
+  /**
+   * @brief Callback to be called when an error occurs in page loading.
+   *
+   * @param[in] callback
    */
-  void ClearCache();
+  void RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback);
 
   /**
-   * @brief Clears all the cookies of Web.
+   * @brief Callback to be called when scroll edge is reached.
+   *
+   * @param[in] callback
+   */
+  void RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback);
+
+  /**
+   * @brief Callback to be called when url is changed.
+   *
+   * @param[in] callback
    */
-  void ClearCookies();
+  void RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when page loading is started.
+   * @brief Callback to be called when navigation policy would be decided.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewPageLoadSignalType& PageLoadStartedSignal();
+  void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when page loading is finished.
+   * @brief Callback to be called when a new window would be created.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewPageLoadSignalType& PageLoadFinishedSignal();
+  void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when an error occurs in page loading.
+   * @brief Get a plain text of current web page asynchronously.
    *
-   * @return A signal object to connect with.
+   * @param[in] callback The callback function called asynchronously.
    */
-  WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+  void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
 
 public: // Not intended for application developers
   /// @cond internal