Add callbacks for form repost decision and frame rendering.
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine.h
index a01db89..ad49b52 100755 (executable)
@@ -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();
@@ -134,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();
@@ -168,27 +192,27 @@ public:
   /**
    * @brief Scrolls the webpage of view by deltaX and deltaY.
    */
-  void ScrollBy( int deltaX, int deltaY );
+  void ScrollBy(int deltaX, int deltaY);
 
   /**
    * @brief Sets an absolute scroll of the given view.
    */
-  void SetScrollPosition( int x, int y );
+  void SetScrollPosition(int x, int y);
 
   /**
    * @brief Gets the current scroll position of the given view.
    */
-  void GetScrollPosition( int& x, int& y ) const;
+  Dali::Vector2 GetScrollPosition() const;
 
   /**
    * @brief Gets the possible scroll size of the given view.
    */
-  void GetScrollSize( int& width, int& height ) const;
+  Dali::Vector2 GetScrollSize() const;
 
   /**
    * @brief Gets the last known content's size.
    */
-  void GetContentSize( int& width, int& height ) const;
+  Dali::Vector2 GetContentSize() const;
 
   /**
    * @brief Returns whether forward is possible.
@@ -231,11 +255,54 @@ public:
   void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
 
   /**
+   * @brief Register a callback for JavaScript alert.
+   *
+   * @param[in] callback The callback function
+   */
+  void RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback);
+
+  /**
+   * @brief Reply for JavaScript alert.
+   */
+  void JavaScriptAlertReply();
+
+  /**
+   * @brief Register a callback for JavaScript confirm.
+   *
+   * @param[in] callback The callback function
+   */
+  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 a callback for JavaScript prompt.
+   *
+   * @param[in] callback The callback function
+   */
+  void RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback);
+
+  /**
+   * @brief Reply for JavaScript prompt.
+   * @param[in] result The result returned from input-field in prompt popup.
+   */
+  void JavaScriptPromptReply(const std::string& result);
+
+  /**
    * @brief Clears the history of Web.
    */
   void ClearHistory();
 
   /**
+   * @brief Clears all tiles resources of Web.
+   */
+  void ClearAllTilesResources();
+
+  /**
    * @brief Get user agent string.
    *
    * @return The string value of user agent
@@ -255,6 +322,41 @@ public:
   void SetSize(int width, int height);
 
   /**
+   * @brief Sets background color of web page.
+   *
+   * @param[in] color Background color
+   */
+  void SetDocumentBackgroundColor(Dali::Vector4 color);
+
+  /**
+   * @brief Clears tiles when hidden.
+   *
+   * @param[in] cleared Whether tiles are cleared or not
+   */
+  void ClearTilesWhenHidden(bool cleared);
+
+  /**
+   * @brief Sets multiplier of cover area of tile.
+   *
+   * @param[in] multiplier The multiplier of cover area
+   */
+  void SetTileCoverAreaMultiplier(float multiplier);
+
+  /**
+   * @brief Enables cursor by client.
+   *
+   * @param[in] enabled Whether cursor is enabled or not
+   */
+  void EnableCursorByClient(bool enabled);
+
+  /**
+   * @brief Gets the selected text.
+   *
+   * @return the selected text
+   */
+  std::string GetSelectedText() const;
+
+  /**
    * @brief Sends Touch Events.
    */
   bool SendTouchEvent(const TouchEvent& touch);
@@ -266,8 +368,47 @@ public:
 
   /**
    * @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.
+   *
+   * @param[in] enabled True if mouse events are enabled, false otherwise
    */
-  void SetFocus( bool focused );
+  void EnableMouseEvents( bool enabled );
+
+  /**
+   * @brief Enables/disables key events. The default is enabled.
+   *
+   * @param[in] enabled True if key events are enabled, false otherwise
+   */
+  void EnableKeyEvents( bool enabled );
+
+  /**
+   * @brief Update display area.
+   * @param[in] displayArea The area to display web page.
+   */
+  void UpdateDisplayArea(Dali::Rect<int> displayArea);
+
+  /**
+   * @brief Enable video hole.
+   * @param[in] enabled True if video hole is enabled, false otherwise
+   */
+  void EnableVideoHole(bool enabled);
+
+  /**
+   * @brief Sends hover events.
+   * @param[in] event The hover event would be sent.
+   */
+  bool SendHoverEvent( const HoverEvent& event );
+
+  /**
+   * @brief Sends wheel events.
+   * @param[in] event The wheel event would be sent.
+   */
+  bool SendWheelEvent( const WheelEvent& event );
 
   /**
    * @brief Connects to this signal to be notified when page loading is started.
@@ -277,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.
@@ -297,6 +445,27 @@ public:
    */
   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