Add callbacks for form repost decision and frame rendering.
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine.h
old mode 100644 (file)
new mode 100755 (executable)
index f3622ab..ad49b52
@@ -2,7 +2,7 @@
 #define DALI_WEB_ENGINE_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.
@@ -97,6 +97,16 @@ public:
   void Create(int width, int height, const std::string& locale, const std::string& timezoneId);
 
   /**
+   * @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
+   */
+  void Create(int width, int height, int argc, char** argv);
+
+  /**
    * @brief Destroys WebEngine instance.
    */
   void Destroy();
@@ -107,6 +117,26 @@ public:
   NativeImageInterfacePtr GetNativeImageSource();
 
   /**
+   * @brief Get settings of WebEngine.
+   */
+  Dali::WebEngineSettings& GetSettings() const;
+
+  /**
+   * @brief Get context of WebEngine.
+   */
+  Dali::WebEngineContext& GetContext() const;
+
+  /**
+   * @brief Get cookie manager of WebEngine.
+   */
+  Dali::WebEngineCookieManager& GetCookieManager() const;
+
+  /**
+   * @brief Get back-forward list of WebEngine.
+   */
+  Dali::WebEngineBackForwardList& GetBackForwardList() const;
+
+  /**
    * @brief Loads a web page based on a given URL.
    *
    * @param [in] url The URL of the resource to load
@@ -114,6 +144,20 @@ public:
   void LoadUrl(const std::string& url);
 
   /**
+   * @brief Returns the title of the Web.
+   *
+   * @return The title of web page
+   */
+  std::string GetTitle() const;
+
+  /**
+   * @brief Returns the Favicon of the Web.
+   *
+   * @return FavIcon of Dali::PixelData& type
+   */
+  Dali::PixelData GetFavicon() const;
+
+  /**
    * @brief Gets the url.
    */
   const std::string& GetUrl();
@@ -123,7 +167,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.
@@ -146,6 +190,31 @@ public:
   void Resume();
 
   /**
+   * @brief Scrolls the webpage of view by deltaX and deltaY.
+   */
+  void ScrollBy(int deltaX, int deltaY);
+
+  /**
+   * @brief Sets an absolute scroll of the given view.
+   */
+  void SetScrollPosition(int x, int y);
+
+  /**
+   * @brief Gets the current scroll position of the given view.
+   */
+  Dali::Vector2 GetScrollPosition() const;
+
+  /**
+   * @brief Gets the possible scroll size of the given view.
+   */
+  Dali::Vector2 GetScrollSize() const;
+
+  /**
+   * @brief Gets the last known content's size.
+   */
+  Dali::Vector2 GetContentSize() const;
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -186,47 +255,52 @@ public:
   void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
 
   /**
-   * @brief Clears the history of Web.
+   * @brief Register a callback for JavaScript alert.
+   *
+   * @param[in] callback The callback function
    */
-  void ClearHistory();
+  void RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback);
 
   /**
-   * @brief Clears the cache of Web.
+   * @brief Reply for JavaScript alert.
    */
-  void ClearCache();
+  void JavaScriptAlertReply();
 
   /**
-   * @brief Clears all the cookies of Web.
+   * @brief Register a callback for JavaScript confirm.
+   *
+   * @param[in] callback The callback function
    */
-  void ClearCookies();
+  void RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback);
 
   /**
-   * @brief Get cache model option. The default is DOCUMENT_VIEWER.
-   *
-   * @return The cache model option
+   * @brief Reply for JavaScript confirm.
+   * @param[in] confirmed True if confirmed, false otherwise.
    */
-  Dali::WebEnginePlugin::CacheModel GetCacheModel() const;
+  void JavaScriptConfirmReply(bool confirmed);
 
   /**
-   * @brief Set cache model option. The default is DOCUMENT_VIEWER.
+   * @brief Register a callback for JavaScript prompt.
    *
-   * @param[in] cacheModel The cache model option
+   * @param[in] callback The callback function
    */
-  void SetCacheModel(Dali::WebEnginePlugin::CacheModel cacheModel);
+  void RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback);
 
   /**
-   * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
-   *
-   * @return The cookie acceptance policy
+   * @brief Reply for JavaScript prompt.
+   * @param[in] result The result returned from input-field in prompt popup.
    */
-  Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const;
+  void JavaScriptPromptReply(const std::string& result);
 
   /**
-   * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY.
-   *
-   * @param[in] policy The cookie acceptance policy
+   * @brief Clears the history of Web.
    */
-  void SetCookieAcceptPolicy(Dali::WebEnginePlugin::CookieAcceptPolicy policy);
+  void ClearHistory();
+
+  /**
+   * @brief Clears all tiles resources of Web.
+   */
+  void ClearAllTilesResources();
 
   /**
    * @brief Get user agent string.
@@ -243,80 +317,98 @@ public:
   void SetUserAgent(const std::string& userAgent);
 
   /**
-   * @brief Returns whether JavaScript can be executable. The default is true.
-   *
-   * @return true if JavaScript executing is enabled, false otherwise
+   * @brief Sets the size of Web Pages.
    */
-  bool IsJavaScriptEnabled() const;
+  void SetSize(int width, int height);
 
   /**
-   * @brief Enables/disables JavaScript executing. The default is enabled.
+   * @brief Sets background color of web page.
    *
-   * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+   * @param[in] color Background color
    */
-  void EnableJavaScript(bool enabled);
+  void SetDocumentBackgroundColor(Dali::Vector4 color);
 
   /**
-   * @brief Returns whether JavaScript can be executable. The default is true.
+   * @brief Clears tiles when hidden.
    *
-   * @return true if images are loaded automatically, false otherwise
+   * @param[in] cleared Whether tiles are cleared or not
    */
-  bool AreImagesAutomaticallyLoaded() const;
+  void ClearTilesWhenHidden(bool cleared);
 
   /**
-   * @brief Enables/disables auto loading of images. The default is enabled.
+   * @brief Sets multiplier of cover area of tile.
    *
-   * @param[in] automatic True if images are loaded automatically, false otherwise
+   * @param[in] multiplier The multiplier of cover area
    */
-  void LoadImagesAutomatically(bool automatic);
+  void SetTileCoverAreaMultiplier(float multiplier);
 
   /**
-   * @brief Gets the default text encoding name.
+   * @brief Enables cursor by client.
    *
-   * @return The default text encoding name
+   * @param[in] enabled Whether cursor is enabled or not
    */
-  const std::string& GetDefaultTextEncodingName() const;
+  void EnableCursorByClient(bool enabled);
 
   /**
-   * @brief Sets the default text encoding name.
+   * @brief Gets the selected text.
    *
-   * @param[in] defaultTextEncodingName The default text encoding name
+   * @return the selected text
+   */
+  std::string GetSelectedText() const;
+
+  /**
+   * @brief Sends Touch Events.
+   */
+  bool SendTouchEvent(const TouchEvent& touch);
+
+  /**
+   * @brief Sends key Events.
    */
-  void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName);
+  bool SendKeyEvent(const KeyEvent& event);
 
   /**
-   * @brief Returns the default font size in pixel. The default value is 16.
+   * @brief Set focus.
+   * @param[in] focused True if web view is focused, false otherwise
+   */
+  void SetFocus(bool focused);
+
+  /**
+   * @brief Enables/disables mouse events. The default is enabled.
    *
-   * @return The default font size
+   * @param[in] enabled True if mouse events are enabled, false otherwise
    */
-  int GetDefaultFontSize() const;
+  void EnableMouseEvents( bool enabled );
 
   /**
-   * @brief Sets the default font size in pixel. The default value is 16.
+   * @brief Enables/disables key events. The default is enabled.
    *
-   * @param[in] defaultFontSize A new default font size to set
+   * @param[in] enabled True if key events are enabled, false otherwise
    */
-  void SetDefaultFontSize(int defaultFontSize);
+  void EnableKeyEvents( bool enabled );
 
   /**
-   * @brief Sets the size of Web Pages.
+   * @brief Update display area.
+   * @param[in] displayArea The area to display web page.
    */
-  void SetSize(int width, int height);
+  void UpdateDisplayArea(Dali::Rect<int> displayArea);
 
   /**
-   * @brief Sends Touch Events.
+   * @brief Enable video hole.
+   * @param[in] enabled True if video hole is enabled, false otherwise
    */
-  bool SendTouchEvent(const TouchEvent& touch);
+  void EnableVideoHole(bool enabled);
 
   /**
-   * @brief Sends key Events.
+   * @brief Sends hover events.
+   * @param[in] event The hover event would be sent.
    */
-  bool SendKeyEvent(const KeyEvent& event);
+  bool SendHoverEvent( const HoverEvent& event );
 
   /**
-   * @brief Set focus.
+   * @brief Sends wheel events.
+   * @param[in] event The wheel event would be sent.
    */
-  void SetFocus( bool focused );
+  bool SendWheelEvent( const WheelEvent& event );
 
   /**
    * @brief Connects to this signal to be notified when page loading is started.
@@ -326,6 +418,13 @@ public:
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
 
   /**
+   * @brief Connects to this signal to be notified when page loading is in progress.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadInProgressSignal();
+
+  /**
    * @brief Connects to this signal to be notified when page loading is finished.
    *
    * @return A signal object to connect with.
@@ -339,6 +438,34 @@ public:
    */
   Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal();
 
+  /**
+   * @brief Connects to this signal to be notified when scroll edge is reached.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when url is changed.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& UrlChangedSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when form repost decision is requested.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& FormRepostDecisionSignal();
+
+  /**
+   * @brief Connects to this signal to be notified when frame is rendered.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal();
+
 private: // Not intended for application developers
   /**
    * @brief Internal constructor