[Tizen] Add API for 'url,changed' event.
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine-plugin.h
old mode 100644 (file)
new mode 100755 (executable)
index 215ea0d..ad72e6e
@@ -2,7 +2,7 @@
 #define DALI_WEB_ENGINE_PLUGIN_H
 
 /*
- * Copyright (c) 2018 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.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/images/native-image-interface.h>
+#include <dali/public-api/math/rect.h>
 #include <dali/public-api/signals/dali-signal.h>
+
 #include <functional>
+#include <memory>
 
 namespace Dali
 {
-
 class KeyEvent;
-class TouchData;
+class PixelData;
+class TouchEvent;
+class WebEngineBackForwardList;
+class WebEngineContext;
+class WebEngineCookieManager;
+class WebEnginePolicyDecision;
+class WebEngineSettings;
 
 /**
  * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
@@ -36,22 +44,64 @@ class TouchData;
 class WebEnginePlugin
 {
 public:
+  /**
+   * @brief WebEngine callback related with page loading.
+   */
+  using WebEnginePageLoadCallback = std::function<void(const std::string&)>;
 
-  typedef Signal< void( const std::string& ) > WebEngineSignalType;
+  /**
+   * @brief WebView callback related with page loading error.
+   */
+  using WebEnginePageLoadErrorCallback = std::function<void(const std::string&, int)>;
+
+  // forward declaration.
+  enum class ScrollEdge;
 
   /**
-   * @brief Constructor.
+   * @brief WebView callback related with scroll edge reached.
    */
-  WebEnginePlugin()
+  using WebEngineScrollEdgeReachedCallback = std::function<void(const ScrollEdge)>;
+
+  /**
+   * @brief The callback to be called when the web engine received a plain text of current web page.
+   */
+  using PlainTextReceivedCallback = std::function<void(const std::string&)>;
+
+  /**
+   * @brief Message result callback when JavaScript is executed with a message.
+   */
+  using JavaScriptMessageHandlerCallback = std::function<void(const std::string&)>;
+
+  /**
+   * @brief WebView callback related with page url changed.
+   */
+  using WebEngineUrlChangedCallback = std::function<void(const std::string&)>;
+
+  /**
+   * @brief WebView callback related with navigation policy would be decided.
+   */
+  using WebEngineNavigationPolicyDecidedCallback = std::function<void(std::unique_ptr<Dali::WebEnginePolicyDecision>)>;
+
+  /**
+   * @brief Enumeration for the scroll edge.
+   */
+  enum class ScrollEdge
   {
-  }
+    LEFT,   ///< Left edge reached.
+    RIGHT,  ///< Right edge reached.
+    TOP,    ///< Top edge reached.
+    BOTTOM, ///< Bottom edge reached.
+  };
+
+  /**
+   * @brief Constructor.
+   */
+  WebEnginePlugin() = default;
 
   /**
    * @brief Destructor.
    */
-  virtual ~WebEnginePlugin()
-  {
-  }
+  virtual ~WebEnginePlugin() = default;
 
   /**
    * @brief Creates WebEngine instance.
@@ -61,7 +111,17 @@ public:
    * @param [in] locale The locale of Web
    * @param [in] timezoneId The timezoneID of Web
    */
-  virtual void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) = 0;
+  virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
+
+  /**
+   * @brief Creates WebEngine instance.
+   *
+   * @param [in] width The width of Web
+   * @param [in] height The height of Web
+   * @param [in] argc The count of application arguments
+   * @param [in] argv The string array of application arguments
+   */
+  virtual void Create(int width, int height, int argc, char** argv) = 0;
 
   /**
    * @brief Destroys WebEngine instance.
@@ -69,11 +129,45 @@ public:
   virtual void Destroy() = 0;
 
   /**
+   * @brief Get settings of WebEngine.
+   */
+  virtual WebEngineSettings& GetSettings() const = 0;
+
+  /**
+   * @brief Get context of WebEngine.
+   */
+  virtual WebEngineContext& GetContext() const = 0;
+
+  /**
+   * @brief Get cookie manager of WebEngine.
+   */
+  virtual WebEngineCookieManager& GetCookieManager() const = 0;
+
+  /**
+   * @brief Get back-forward list of WebEngine.
+   */
+  virtual WebEngineBackForwardList& GetBackForwardList() const = 0;
+
+  /**
    * @brief Loads a web page based on a given URL.
    *
    * @param [in] url The URL of the resource to load
    */
-  virtual void LoadUrl( const std::string& url ) = 0;
+  virtual void LoadUrl(const std::string& url) = 0;
+
+  /**
+   * @brief Returns the title of the Web.
+   *
+   * @return The title of web page
+   */
+  virtual std::string GetTitle() const = 0;
+
+  /**
+   * @brief Returns the Favicon of the Web.
+   *
+   * @return Favicon of Dali::PixelData& type
+   */
+  virtual Dali::PixelData GetFavicon() const = 0;
 
   /**
    * @brief Gets image to render.
@@ -92,7 +186,7 @@ public:
    *
    * @param [in] htmlString The string to use as the contents of the web page
    */
-  virtual void LoadHTMLString( const std::string& htmlString ) = 0;
+  virtual void LoadHtmlString(const std::string& htmlString) = 0;
 
   /**
    * @brief Reloads the Web.
@@ -105,6 +199,41 @@ public:
   virtual void StopLoading() = 0;
 
   /**
+   * @brief Suspends the operation associated with the view.
+   */
+  virtual void Suspend() = 0;
+
+  /**
+   * @brief Resumes the operation associated with the view object after calling Suspend().
+   */
+  virtual void Resume() = 0;
+
+  /**
+   * @brief Scrolls the webpage of view by deltaX and deltaY.
+   */
+  virtual void ScrollBy(int deltaX, int deltaY) = 0;
+
+  /**
+   * @brief Scroll to the specified position of the given view.
+   */
+  virtual void SetScrollPosition(int x, int y) = 0;
+
+  /**
+   * @brief Gets the current scroll position of the given view.
+   */
+  virtual void GetScrollPosition(int& x, int& y) const = 0;
+
+  /**
+   * @brief Gets the possible scroll size of the given view.
+   */
+  virtual void GetScrollSize(int& width, int& height) const = 0;
+
+  /**
+   * @brief Gets the last known content's size.
+   */
+  virtual void GetContentSize(int& width, int& height) const = 0;
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -129,28 +258,25 @@ public:
   virtual void GoBack() = 0;
 
   /**
-    * @brief Evaluates JavaScript code represented as a string.
-    *
-    * @param[in] script The JavaScript code
-    */
-  virtual void EvaluateJavaScript( const std::string& script ) = 0;
+   * @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.
+   */
+  virtual void EvaluateJavaScript(const std::string& script, JavaScriptMessageHandlerCallback resultHandler) = 0;
 
   /**
-    * @brief Adds a JavaScript interface.
-    *
-    * @param[in] exposedObjectName The name of exposed object
-    * @param[in] jsFunctionName The name of JavaScript function
-    * @param[in] cb The callback function
-    */
-  virtual void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb ) = 0;
+   * @brief Add a message handler into JavaScript.
+   *
+   * @param[in] exposedObjectName The name of exposed object
+   * @param[in] handler The callback function
+   */
+  virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, JavaScriptMessageHandlerCallback handler) = 0;
 
   /**
-    * @brief Removes a JavaScript interface.
-    *
-    * @param[in] exposedObjectName The name of exposed object
-    * @param[in] jsFunctionName The name of JavaScript function
-    */
-  virtual void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName ) = 0;
+   * @brief Clears all tiles resources of Web.
+   */
+  virtual void ClearAllTilesResources() = 0;
 
   /**
    * @brief Clears the history of Web.
@@ -158,41 +284,101 @@ public:
   virtual void ClearHistory() = 0;
 
   /**
-   * @brief Clears the cache of Web.
+   * @brief Get user agent string.
+   *
+   * @return The string value of user agent
+   */
+  virtual const std::string& GetUserAgent() const = 0;
+
+  /**
+   * @brief Set user agent string.
+   *
+   * @param[in] userAgent The string value of user agent
    */
-  virtual void ClearCache() = 0;
+  virtual void SetUserAgent(const std::string& userAgent) = 0;
 
   /**
    * @brief Sets size of Web Page.
    */
-  virtual void SetSize( int width, int height ) = 0;
+  virtual void SetSize(int width, int height) = 0;
 
   /**
    * @brief Sends Touch Events.
    */
-  virtual bool SendTouchEvent( const TouchData& touch ) = 0;
+  virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
 
   /**
    * @brief Sends Key Events.
    */
-  virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
+  virtual bool SendKeyEvent(const KeyEvent& event) = 0;
 
   /**
-   * @brief Connects to this signal to be notified when page loading is started.
+   * @brief Sets focus.
+   */
+  virtual void SetFocus(bool focused) = 0;
+
+  /**
+   * @brief Update display area.
+   * @param[in] displayArea The display area need be updated.
+   */
+  virtual void UpdateDisplayArea(Dali::Rect<int> displayArea) = 0;
+
+  /**
+   * @brief Enable video hole.
+   * @param[in] enabled True if enabled, false othewise.
+   */
+  virtual void EnableVideoHole(bool enabled) = 0;
+
+  /**
+   * @brief Callback to be called when page loading is started.
+   *
+   * @param[in] callback
+   */
+  virtual void RegisterPageLoadStartedCallback(WebEnginePageLoadCallback callback) = 0;
+
+  /**
+   * @brief Callback to be called when page loading is finished.
+   *
+   * @param[in] callback
+   */
+  virtual void RegisterPageLoadFinishedCallback(WebEnginePageLoadCallback callback) = 0;
+
+  /**
+   * @brief Callback to be called when an error occurs in page loading.
+   *
+   * @param[in] callback
+   */
+  virtual void RegisterPageLoadErrorCallback(WebEnginePageLoadErrorCallback callback) = 0;
+
+  /**
+   * @brief Callback to be called when scroll edge is reached.
    *
-   * @return A signal object to connect with.
+   * @param[in] callback
    */
-  virtual WebEngineSignalType& PageLoadStartedSignal() = 0;
+  virtual void RegisterScrollEdgeReachedCallback(WebEngineScrollEdgeReachedCallback callback) = 0;
 
   /**
-   * @brief Connects to this signal to be notified when page loading is finished.
+   * @brief Callback to be called when url is changed.
    *
-   * @return A signal object to connect with.
+   * @param[in] callback
    */
-  virtual WebEngineSignalType& PageLoadFinishedSignal() = 0;
+  virtual void RegisterUrlChangedCallback(WebEngineUrlChangedCallback callback) = 0;
 
+  /**
+   * @brief Callback to be called when navigation policy would be decided.
+   *
+   * @param[in] callback
+   */
+  virtual void RegisterNavigationPolicyDecidedCallback(WebEngineNavigationPolicyDecidedCallback callback) = 0;
+
+  /**
+   * @brief Get a plain text of current web page asynchronously.
+   *
+   * @param[in] callback The callback function called asynchronously.
+   */
+  virtual void GetPlainTextAsynchronously(PlainTextReceivedCallback callback) = 0;
 };
 
-} // namespace Dali;
+} // namespace Dali
 
 #endif