Support mouse & wheel events in web view.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / web-view / web-view.h
old mode 100755 (executable)
new mode 100644 (file)
index 53dfb5a..d347824
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_WEB_VIEW_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -22,8 +22,8 @@
 #include <functional>
 
 // INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
 #include <dali-toolkit/public-api/controls/control.h>
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
 
 namespace Dali
 {
@@ -56,7 +56,6 @@ class WebView;
 class DALI_TOOLKIT_API WebView : public Control
 {
 public:
-
   /**
    * @brief Enumeration for the start and end property ranges for this control.
    */
@@ -81,34 +80,57 @@ public:
 
       /**
        * @brief The user agent string.
-       * @details Name "userAgent", type Property::STRING.
+       * @details name "userAgent", type Property::STRING.
        */
       USER_AGENT,
 
       /**
        * @brief The current position of scroll.
-       * @details Name "scrollPosition", type Property::VECTOR2.
+       * @details name "scrollPosition", type Property::VECTOR2.
        */
       SCROLL_POSITION,
 
       /**
-       * @brief The current position of scroll.
-       * @details Name "scrollSize", type Property::VECTOR2. Read-only.
+       * @brief The current size of scroll.
+       * @details name "scrollSize", type Property::VECTOR2.
+       * @note The value is read-only.
        */
       SCROLL_SIZE,
 
       /**
-       * @brief The current position of scroll.
-       * @details Name "contentSize", type Property::VECTOR2. Read-only.
+       * @brief The current size of content.
+       * @details name "contentSize", type Property::VECTOR2.
+       * @note The value is read-only.
        */
       CONTENT_SIZE,
 
       /**
        * @brief The title of web page.
-       * @details Name "title", type Property::STRING.
+       * @details name "title", type Property::STRING.
        * @note The value is read-only.
        */
       TITLE,
+
+      /**
+       * @brief Whether video hole is enabled or not.
+       * @details name "videoHoleEnabled", type Property::BOOLEAN.
+       * @note The value is read-only.
+       */
+      VIDEO_HOLE_ENABLED,
+
+      /**
+       * @brief Whether mouse event is enabled.
+       * @details name "mouseEventsEnabled", type Property::BOOLEAN.
+       * @note Default is true.
+       */
+      MOUSE_EVENTS_ENABLED,
+
+      /**
+       * @brief Whether key event is enabled.
+       * @details name "keyEventsEnabled", type Property::BOOLEAN.
+       * @note Default is true.
+       */
+      KEY_EVENTS_ENABLED,
     };
   };
 
@@ -117,96 +139,42 @@ 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;
+  using WebViewPageLoadSignalType = Signal<void(WebView, const std::string&)>;
 
   /**
    * @brief WebView signal type related with page loading error.
    */
-  typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
+  using WebViewPageLoadErrorSignalType = Signal<void(WebView, const std::string&, LoadErrorCode)>;
 
   /**
    * @brief WebView signal type related with scroll edge reached.
    */
-  typedef Signal<void(WebView, Dali::WebEnginePlugin::ScrollEdge)> WebViewScrollEdgeReachedSignalType;
+  using WebViewScrollEdgeReachedSignalType = Signal<void(WebView, Dali::WebEnginePlugin::ScrollEdge)>;
+
+  /**
+   * @brief WebView signal type related with url changed.
+   */
+  using WebViewUrlChangedSignalType = Signal<void(WebView, const std::string&)>;
 
 public:
   /**
@@ -231,7 +199,7 @@ public:
    * @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 );
+  static WebView New(int argc, char** argv);
 
   /**
    * @brief Creates an uninitialized WebView.
@@ -337,7 +305,7 @@ public:
    * @param[in] deltaX The delta x of scroll
    * @param[in] deltaY The delta y of scroll
    */
-  void ScrollBy( int deltaX, int deltaY );
+  void ScrollBy(int deltaX, int deltaY);
 
   /**
    * @brief Returns whether forward is possible.
@@ -405,9 +373,42 @@ public:
   void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
 
   /**
-   * @brief Clears all tiles resources of Web.
+   * @brief Register alert callback for javascript.
+   *
+   * @param[in] callback The callback function to be called by the JavaScript runtime.
    */
-  void ClearAllTilesResources();
+  void RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback);
+
+  /**
+   * @brief Reply for JavaScript alert.
+   */
+  void JavaScriptAlertReply();
+
+  /**
+   * @brief Register confirm callback for javascript.
+   *
+   * @param[in] callback The callback function to be called by the JavaScript runtime.
+   */
+  void RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback);
+
+  /**
+   * @brief Reply for JavaScript confirm.
+   * @param[in] confirmed True if confirmed, false otherwise
+   */
+  void JavaScriptConfirmReply(bool confirmed);
+
+  /**
+   * @brief Register prompt callback for javascript.
+   *
+   * @param[in] callback The callback function to be called by the JavaScript runtime.
+   */
+  void RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback);
+
+  /**
+   * @brief Reply for JavaScript prompt.
+   * @param[in] result The result from input-field of prompt popup.
+   */
+  void JavaScriptPromptReply(const std::string& result);
 
   /**
    * @brief Clears the history of Web.
@@ -415,6 +416,11 @@ public:
   void ClearHistory();
 
   /**
+   * @brief Clears all tiles resources of Web.
+   */
+  void ClearAllTilesResources();
+
+  /**
    * @brief Connects to this signal to be notified when page loading is started.
    *
    * @return A signal object to connect with
@@ -422,6 +428,13 @@ public:
   WebViewPageLoadSignalType& PageLoadStartedSignal();
 
   /**
+   * @brief Connects to this signal to be notified when page loading is in progress.
+   *
+   * @return A signal object to connect with.
+   */
+  WebViewPageLoadSignalType& PageLoadInProgressSignal();
+
+  /**
    * @brief Connects to this signal to be notified when page loading is finished.
    *
    * @return A signal object to connect with
@@ -442,6 +455,13 @@ public:
    */
   WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
 
+  /**
+   * @brief Connects to this signal to be notified when url is changed.
+   *
+   * @return A signal object to connect with.
+   */
+  WebViewUrlChangedSignalType& UrlChangedSignal();
+
 public: // Not intended for application developers
   /// @cond internal
   /**