[Tizen] Add an API for 'create,window' event. 85/285285/1
authorhuayong.xu <huayong.xu@samsung.com>
Wed, 7 Dec 2022 09:03:50 +0000 (17:03 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Wed, 7 Dec 2022 09:03:50 +0000 (17:03 +0800)
Change-Id: I57a6cbdd88c539b1742fd380b28e11ba9874e27b

dali/devel-api/adaptor-framework/web-engine-plugin.h
dali/devel-api/adaptor-framework/web-engine.cpp
dali/devel-api/adaptor-framework/web-engine.h
dali/internal/web-engine/common/web-engine-impl.cpp
dali/internal/web-engine/common/web-engine-impl.h

index ad72e6e..b203a30 100755 (executable)
@@ -83,6 +83,11 @@ public:
   using WebEngineNavigationPolicyDecidedCallback = std::function<void(std::unique_ptr<Dali::WebEnginePolicyDecision>)>;
 
   /**
+   * @brief WebView callback related with a new window would be created.
+   */
+  using WebEngineNewWindowCreatedCallback = std::function<void(Dali::WebEnginePlugin*&)>;
+
+  /**
    * @brief Enumeration for the scroll edge.
    */
   enum class ScrollEdge
@@ -179,7 +184,7 @@ public:
    *
    * @return Url of string type
    */
-  virtual const std::string& GetUrl() = 0;
+  virtual std::string GetUrl() const = 0;
 
   /**
    * @brief Loads a given string as web contents.
@@ -288,7 +293,7 @@ public:
    *
    * @return The string value of user agent
    */
-  virtual const std::string& GetUserAgent() const = 0;
+  virtual std::string GetUserAgent() const = 0;
 
   /**
    * @brief Set user agent string.
@@ -372,6 +377,13 @@ public:
   virtual void RegisterNavigationPolicyDecidedCallback(WebEngineNavigationPolicyDecidedCallback callback) = 0;
 
   /**
+   * @brief Callback to be called when a new window would be created.
+   *
+   * @param[in] callback
+   */
+  virtual void RegisterNewWindowCreatedCallback(WebEngineNewWindowCreatedCallback callback) = 0;
+
+  /**
    * @brief Get a plain text of current web page asynchronously.
    *
    * @param[in] callback The callback function called asynchronously.
index c00723e..3f8f927 100755 (executable)
@@ -85,6 +85,11 @@ void WebEngine::Destroy()
   GetImplementation(*this).Destroy();
 }
 
+WebEnginePlugin* WebEngine::GetPlugin() const
+{
+  return GetImplementation(*this).GetPlugin();
+}
+
 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
 {
   return GetImplementation(*this).GetNativeImageSource();
@@ -125,7 +130,7 @@ Dali::PixelData WebEngine::GetFavicon() const
   return GetImplementation(*this).GetFavicon();
 }
 
-const std::string& WebEngine::GetUrl()
+std::string WebEngine::GetUrl() const
 {
   return GetImplementation(*this).GetUrl();
 }
@@ -220,7 +225,7 @@ void WebEngine::ClearHistory()
   return GetImplementation(*this).ClearHistory();
 }
 
-const std::string& WebEngine::GetUserAgent() const
+std::string WebEngine::GetUserAgent() const
 {
   return GetImplementation(*this).GetUserAgent();
 }
@@ -290,6 +295,11 @@ void WebEngine::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::W
   GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
 }
 
+void WebEngine::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+  GetImplementation(*this).RegisterNewWindowCreatedCallback(callback);
+}
+
 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
 {
   GetImplementation(*this).GetPlainTextAsynchronously(callback);
index 83fbb84..2f26b73 100755 (executable)
@@ -112,6 +112,11 @@ public:
   void Destroy();
 
   /**
+   * @brief Gets web engine plugin.
+   */
+  Dali::WebEnginePlugin* GetPlugin() const;
+
+  /**
    * @brief Gets native image source to render.
    */
   NativeImageInterfacePtr GetNativeImageSource();
@@ -160,7 +165,7 @@ public:
   /**
    * @brief Gets the url.
    */
-  const std::string& GetUrl();
+  std::string GetUrl() const;
 
   /**
    * @brief Loads a given string as web contents.
@@ -269,7 +274,7 @@ public:
    *
    * @return The string value of user agent
    */
-  const std::string& GetUserAgent() const;
+  std::string GetUserAgent() const;
 
   /**
    * @brief Set user agent string.
@@ -354,6 +359,13 @@ public:
   void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
 
   /**
+   * @brief Callback to be called when a new window would be created.
+   *
+   * @param[in] callback
+   */
+  void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+  /**
    * @brief Get a plain text of current web page asynchronously.
    *
    * @param[in] callback The callback function called asynchronously.
index 9bd7399..83a2fd0 100755 (executable)
@@ -175,6 +175,11 @@ void WebEngine::Create(int width, int height, int argc, char** argv)
   mPlugin->Create(width, height, argc, argv);
 }
 
+Dali::WebEnginePlugin* WebEngine::GetPlugin() const
+{
+  return mPlugin;
+}
+
 void WebEngine::Destroy()
 {
   mPlugin->Destroy();
@@ -220,12 +225,12 @@ Dali::PixelData WebEngine::GetFavicon() const
   return mPlugin->GetFavicon();
 }
 
-const std::string& WebEngine::GetUrl()
+std::string WebEngine::GetUrl() const
 {
   return mPlugin->GetUrl();
 }
 
-const std::string& WebEngine::GetUserAgent() const
+std::string WebEngine::GetUserAgent() const
 {
   return mPlugin->GetUserAgent();
 }
@@ -385,6 +390,11 @@ void WebEngine::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::W
   mPlugin->RegisterNavigationPolicyDecidedCallback(callback);
 }
 
+void WebEngine::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback)
+{
+  mPlugin->RegisterNewWindowCreatedCallback(callback);
+}
+
 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
 {
   mPlugin->GetPlainTextAsynchronously(callback);
index 1d7f1ca..4f3acab 100755 (executable)
@@ -70,6 +70,11 @@ public:
   void Destroy();
 
   /**
+   * @copydoc Dali::WebEngine::GetPlugin()
+   */
+  Dali::WebEnginePlugin* GetPlugin() const;
+
+  /**
    * @copydoc Dali::WebEngine::GetNativeImageSource()
    */
   Dali::NativeImageInterfacePtr GetNativeImageSource();
@@ -112,12 +117,12 @@ public:
   /**
    * @copydoc Dali::WebEngine::GetUrl()
    */
-  const std::string& GetUrl();
+  std::string GetUrl() const;
 
   /**
    * @copydoc Dali::WebEngine::GetUserAgent()
    */
-  const std::string& GetUserAgent() const;
+  std::string GetUserAgent() const;
 
   /**
    * @copydoc Dali::WebEngine::SetUserAgent()
@@ -275,6 +280,11 @@ public:
   void RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback);
 
   /**
+   @copydoc Dali::WebEngine::RegisterNewWindowCreatedCallback()
+   */
+  void RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineNewWindowCreatedCallback callback);
+
+  /**
    * @copydoc Dali::WebEngine::GetPlainTextAsynchronously()
    */
   void GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback);