Updates following web-engine devel header location change
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / web-view / web-view.h
index 716132e..55908e8 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_WEB_VIEW_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -24,7 +24,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control.h>
-#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
+#include <dali/devel-api/adaptor-framework/web-engine/web-engine-plugin.h>
 
 namespace Dali
 {
@@ -34,7 +34,6 @@ class ImageView;
 class WebBackForwardList;
 class WebContext;
 class WebCookieManager;
-class WebFormRepostDecision;
 class WebSettings;
 
 namespace Internal DALI_INTERNAL
@@ -116,7 +115,7 @@ public:
       /**
        * @brief Whether video hole is enabled or not.
        * @details name "videoHoleEnabled", type Property::BOOLEAN.
-       * @note The value is read-only.
+       * @note False by default.
        */
       VIDEO_HOLE_ENABLED,
 
@@ -187,65 +186,13 @@ public:
   };
 
   /**
-   * @brief Enumeration for indicating error code of page loading.
-   */
-  enum class LoadErrorCode
-  {
-    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 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&)>;
-
-  /**
-   * @brief WebView signal type related with page loading error.
-   */
-  using WebViewPageLoadErrorSignalType = Signal<void(WebView, const std::string&, LoadErrorCode)>;
-
-  /**
-   * @brief WebView signal type related with scroll edge reached.
-   */
-  using WebViewScrollEdgeReachedSignalType = Signal<void(WebView, Dali::WebEnginePlugin::ScrollEdge)>;
-
-  /**
-   * @brief WebView signal type related with url changed.
-   */
-  using WebViewUrlChangedSignalType = Signal<void(WebView, const std::string&)>;
-
-  /**
-   * @brief WebView signal type related with form repost decision.
-   */
-  using WebViewFormRepostDecisionSignalType = Signal<void(WebView, std::shared_ptr<Dali::Toolkit::WebFormRepostDecision>)>;
-
-  /**
-   * @brief WebView signal type related with frame rendered.
-   */
-  using WebViewFrameRenderedSignalType = Signal<void(WebView)>;
-
 public:
   /**
-   * @brief Creates an initialized WebView.
+   * @brief Create an initialized WebView.
    * @return A handle to a newly allocated Dali WebView
    *
    * @note WebView will not display anything
@@ -253,7 +200,7 @@ public:
   static WebView New();
 
   /**
-   * @brief Creates an initialized WebView.
+   * @brief Create an initialized WebView.
    *
    * @param [in] locale The locale of Web
    * @param [in] timezoneId The timezoneId of Web
@@ -261,15 +208,15 @@ public:
   static WebView New(const std::string& locale, const std::string& timezoneId);
 
   /**
-   * @brief Creates an initialized WebView.
+   * @brief Create 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);
+  static WebView New(uint32_t argc, char** argv);
 
   /**
-   * @brief Creates an uninitialized WebView.
+   * @brief Create an uninitialized WebView.
    */
   WebView();
 
@@ -296,7 +243,7 @@ public:
   WebView& operator=(const WebView& WebView);
 
   /**
-   * @brief Downcasts a handle to WebView handle.
+   * @brief Downcast a handle to WebView handle.
    *
    * If handle points to a WebView, the downcast produces valid handle.
    * If not, the returned handle is left uninitialized.
@@ -327,21 +274,21 @@ public:
   Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
 
   /**
-   * @brief Get Favicon of web page.
+   * @brief Get favicon of web page.
    *
-   * @return Handle to a fav icon
+   * @return Handle to a favicon
    */
-  Dali::Toolkit::ImageView& GetFavicon();
+  Dali::Toolkit::ImageView GetFavicon() const;
 
   /**
-   * @brief Loads a web page based on a given URL.
+   * @brief Load 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 Loads a given string as web contents.
+   * @brief Load a given string as web contents.
    *
    * @param [in] htmlString The string to use as the contents of the web page
    */
@@ -359,7 +306,7 @@ public:
   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
+   * @brief Request 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)
@@ -372,27 +319,27 @@ public:
   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.
+   * @brief Reload the Web.
    */
   void Reload();
 
   /**
-   * @brief Reloads the current page's document without cache
+   * @brief Reload the current page's document without cache
    */
   bool ReloadWithoutCache();
 
   /**
-   * @brief Stops loading web contents on the current page.
+   * @brief Stop loading web contents on the current page.
    */
   void StopLoading();
 
   /**
-   * @brief Suspends the operation associated with the view.
+   * @brief Suspend the operation associated with the view.
    */
   void Suspend();
 
   /**
-   * @brief Resumes the operation associated with the view object after calling Suspend().
+   * @brief Resume the operation associated with the view object after calling Suspend().
    */
   void Resume();
 
@@ -442,56 +389,56 @@ public:
   bool StopInspectorServer();
 
   /**
-   * @brief Scrolls web page of view by deltaX and deltaY.
+   * @brief Scroll 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);
+  void ScrollBy(int32_t deltaX, int32_t deltaY);
 
   /**
-   * @brief Scrolls edge of view by deltaX and deltaY.
+   * @brief Scroll 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);
+  bool ScrollEdgeBy(int32_t deltaX, int32_t deltaY);
 
   /**
-   * @brief Returns whether forward is possible.
+   * @brief Return whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
    */
   bool CanGoForward();
 
   /**
-   * @brief Goes forward in the navigation history.
+   * @brief Go forward in the navigation history.
    */
   void GoForward();
 
   /**
-   * @brief Returns whether backward is possible.
+   * @brief Return whether backward is possible.
    *
    * @return True if backward is possible, false otherwise
    */
   bool CanGoBack();
 
   /**
-   * @brief Goes back in the navigation history.
+   * @brief Go back in the navigation history.
    */
   void GoBack();
 
   /**
-   * @brief Evaluates JavaScript code represented as a string.
+   * @brief Evaluate 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 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.
+   * @brief Evaluate JavaScript code represented as a string.
    *
    * @param[in] script The JavaScript code
    */
@@ -521,7 +468,7 @@ 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 Register alert callback for javascript.
@@ -562,24 +509,47 @@ public:
   void JavaScriptPromptReply(const std::string& result);
 
   /**
-   * @brief Clears the history of Web.
+   * @brief Create a new hit test.
+   *
+   * @param[in] x the horizontal position to query
+   * @param[in] y the vertical position to query
+   * @param[in] mode the mode of hit test
+   *
+   * @return a new hit test object.
+   */
+  std::unique_ptr<Dali::WebEngineHitTest> CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode);
+
+  /**
+   * @brief Create a hit test asynchronously.
+   *
+   * @param[in] x the horizontal position to query
+   * @param[in] y the vertical position to query
+   * @param[in] mode the mode of hit test
+   * @param[in] callback The callback function
+   *
+   * @return true if succeeded, false otherwise.
+   */
+  bool CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback);
+
+  /**
+   * @brief Clear the history of Web.
    */
   void ClearHistory();
 
   /**
-   * @brief Clears all tiles resources of Web.
+   * @brief Clear all tiles resources of Web.
    */
   void ClearAllTilesResources();
 
   /**
-   * @brief Scales the current page, centered at the given point.
+   * @brief Scale 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.
+   * @brief Get the current scale factor of the page.
    * @return The current scale factor.
    */
   float GetScaleFactor() const;
@@ -591,7 +561,7 @@ public:
   void ActivateAccessibility(bool activated);
 
   /**
-   * @brief Searches and highlights the given string in the document.
+   * @brief Search 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
@@ -615,7 +585,7 @@ public:
    *
    * @return image view of screen shot
    */
-  Dali::Toolkit::ImageView GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor);
+  Dali::Toolkit::ImageView GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor);
 
   /**
    * @brief Request to get snapshot of the specified viewArea of page asynchronously.
@@ -626,7 +596,7 @@ public:
    *
    * @return true if requested successfully, false otherwise
    */
-  bool GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, WebViewScreenshotCapturedCallback callback);
+  bool GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, WebViewScreenshotCapturedCallback callback);
 
   /**
    * @brief Asynchronous request to check if there is a video playing in the given view.
@@ -638,79 +608,149 @@ public:
   bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback);
 
   /**
-   * @brief Sets callback which will be called upon geolocation permission request.
+   * @brief Set 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.
+   * @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 in progress.
+   *
+   * @param[in] callback
+   */
+  void RegisterPageLoadInProgressCallback(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 RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback);
+
+  /**
+   * @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 RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback);
+
+  /**
+   * @brief Callback to be called when form repost decision is requested.
+   *
+   * @param[in] callback
+   */
+  void RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback);
+
+  /**
+   * @brief Callback to be called when frame is rendered.
+   *
+   * @param[in] callback
+   */
+  void RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback);
+
+  /**
+   * @brief Callback to be called when console message will be logged.
+   *
+   * @param[in] callback
+   */
+  void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback);
+
+  /**
+   * @brief Callback to be called when response policy would be decided.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewPageLoadSignalType& PageLoadStartedSignal();
+  void RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when page loading is in progress.
+   * @brief Callback to be called when navigation policy would be decided.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewPageLoadSignalType& PageLoadInProgressSignal();
+  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 certificate need be confirmed.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewPageLoadSignalType& PageLoadFinishedSignal();
+  void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when an error occurs in page loading.
+   * @brief Callback to be called when ssl certificate is changed.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+  void RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when scroll edge is reached.
+   * @brief Callback to be called when http authentication need be confirmed.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+  void RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when url is changed.
+   * @brief Callback to be called when context menu would be shown.
    *
-   * @return A signal object to connect with
+   * @param[in] callback
    */
-  WebViewUrlChangedSignalType& UrlChangedSignal();
+  void RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when form repost decision is requested.
+   * @brief Callback to be called when context menu would be hidden.
    *
-   * @return A signal object to connect with.
+   * @param[in] callback
    */
-  WebViewFormRepostDecisionSignalType& FormRepostDecisionSignal();
+  void RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback);
 
   /**
-   * @brief Connects to this signal to be notified when frame is rendered.
+   * @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.
    */
-  WebViewFrameRenderedSignalType& FrameRenderedSignal();
+  void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);
 
 public: // Not intended for application developers
   /// @cond internal
   /**
-   * @brief Creates a handle using the Toolkit::Internal implementation.
+   * @brief Create 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.
+   * @brief Allow the creation of this WebView from an Internal::CustomActor pointer.
    *
    * @param[in] internal A pointer to the internal CustomActor
    */