Support policy decision in web engine. 54/252954/6
authorhuayong.xu <huayong.xu@samsung.com>
Wed, 3 Feb 2021 08:42:59 +0000 (16:42 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Tue, 6 Apr 2021 05:29:32 +0000 (13:29 +0800)
This patch is to add policy decision feature in web engine.

Change-Id: I5ce01683303a139a64d5e7f8e4c83e624542796b

dali/devel-api/adaptor-framework/web-engine-frame.h [new file with mode: 0755]
dali/devel-api/adaptor-framework/web-engine-plugin.h
dali/devel-api/adaptor-framework/web-engine-policy-decision.h [new file with mode: 0755]
dali/devel-api/adaptor-framework/web-engine.cpp
dali/devel-api/adaptor-framework/web-engine.h
dali/devel-api/file.list
dali/internal/web-engine/common/web-engine-impl.cpp
dali/internal/web-engine/common/web-engine-impl.h

diff --git a/dali/devel-api/adaptor-framework/web-engine-frame.h b/dali/devel-api/adaptor-framework/web-engine-frame.h
new file mode 100755 (executable)
index 0000000..51beba9
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef DALI_WEB_ENGINE_FRAME_H
+#define DALI_WEB_ENGINE_FRAME_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+/**
+ * @brief A class WebEngineFrame for frame of web engine.
+ */
+class WebEngineFrame
+{
+public:
+  /**
+   * @brief Constructor.
+   */
+  WebEngineFrame() = default;
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEngineFrame() = default;
+
+  /**
+   * @brief Check whether the frame is main frame.
+   * @return true if the frame is main frame, false otherwise
+   */
+  virtual bool IsMainFrame() const = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_FRAME_H
index 3530b1b..bbfa6f6 100644 (file)
@@ -36,8 +36,9 @@ class WebEngineConsoleMessage;
 class WebEngineContext;
 class WebEngineCookieManager;
 class WebEngineFormRepostDecision;
-class WebEngineRequestInterceptor;
 class WebEngineLoadError;
+class WebEnginePolicyDecision;
+class WebEngineRequestInterceptor;
 class WebEngineSettings;
 class HoverEvent;
 class WheelEvent;
@@ -130,6 +131,11 @@ public:
   using WebEngineFrameRenderedSignalType = Signal<void(void)>;
 
   /**
+   * @brief WebView signal type related with policy would be decided.
+   */
+  using WebEnginePolicyDecisionSignalType = Signal<void(std::shared_ptr<Dali::WebEnginePolicyDecision>)>;
+
+  /**
    * @brief Enumeration for the scroll edge.
    */
   enum class ScrollEdge
@@ -755,6 +761,13 @@ public:
    * @return A signal object to connect with.
    */
   virtual WebEngineConsoleMessageSignalType& ConsoleMessageSignal() = 0;
+
+  /**
+   * @brief Connects to this signal to be notified when new policy would be decided.
+   *
+   * @return A signal object to connect with.
+   */
+  virtual WebEnginePolicyDecisionSignalType& PolicyDecisionSignal() = 0;
 };
 
 // specialization has to be done in the same namespace
diff --git a/dali/devel-api/adaptor-framework/web-engine-policy-decision.h b/dali/devel-api/adaptor-framework/web-engine-policy-decision.h
new file mode 100755 (executable)
index 0000000..a9fda10
--- /dev/null
@@ -0,0 +1,136 @@
+#ifndef DALI_WEB_ENGINE_POLICY_DECISION_H
+#define DALI_WEB_ENGINE_POLICY_DECISION_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+class WebEngineFrame;
+
+/**
+ * @brief A class WebBackForwardList for back forward list of web engine.
+ */
+class WebEnginePolicyDecision
+{
+public:
+  /**
+   * @brief Enumeration that provides an option to policy decision types.
+   */
+  enum class DecisionType
+  {
+    USE,      ///< Use.
+    DOWNLOAD, ///< Download.
+    IGNORE,   ///< Ignore.
+  };
+
+  /**
+   * @brief Enumeration that provides an option to policy navigation types.
+   */
+  enum class NavigationType
+  {
+    LINK_CLICKED,     ///< Link clicked.
+    FORM_SUBMITTED,   ///< Form submitted.
+    BACK_FORWARD,     ///< Back forward.
+    RELOAD,           ///< Reload.
+    FORM_RESUBMITTED, ///< Form resubmitted.
+    OTHER,            ///< Other.
+  };
+
+  /**
+   * @brief Constructor.
+   */
+  WebEnginePolicyDecision() = default;
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebEnginePolicyDecision() = default;
+
+  /**
+   * @brief Returns the url that request policy decision.
+   * @return The url that request policy decision
+   */
+  virtual std::string GetUrl() const = 0;
+
+  /**
+   * @brief Returns a cookie that web page has.
+   * @return The cookie string if successfully
+   */
+  virtual std::string GetCookie() const = 0;
+
+  /**
+   * @brief Returns a decision type.
+   * @return The decision type
+   */
+  virtual DecisionType GetDecisionType() const = 0;
+
+  /**
+   * @brief Returns a MIME type for response data.
+   * @return The MIME type string
+   */
+  virtual std::string GetResponseMime() const = 0;
+
+  /**
+   * @brief Returns an HTTP status code.
+   * @return The HTTP status code number
+   */
+  virtual int32_t GetResponseStatusCode() const = 0;
+
+  /**
+   * @brief Returns a navigation type.
+   * @return The navigation type
+   */
+  virtual NavigationType GetNavigationType() const = 0;
+
+  /**
+   * @brief Gets frame.
+   * @return The frame of policy decision
+   */
+  virtual WebEngineFrame& GetFrame() const = 0;
+
+  /**
+   * @brief Gets a scheme from the Policy Decision.
+   * @return The scheme if succeeded, empty otherwise
+   */
+  virtual std::string GetScheme() const = 0;
+
+  /**
+   * @brief Accepts the action which triggers this decision.
+   * @return True if successfully, false otherwise
+   */
+  virtual bool Use() = 0;
+
+  /**
+   * @brief Ignores the action which triggers this decision.
+   * @return True if successfully, false otherwise
+   */
+  virtual bool Ignore() = 0;
+
+  /**
+   * @brief Suspend the operation for policy decision.
+   * @return True if successfully, false otherwise
+   */
+  virtual bool Suspend() = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_POLICY_DECISION_H
index d186a61..b1d9fa0 100755 (executable)
@@ -23,8 +23,9 @@
 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
-#include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
+#include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
+#include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
 #include <dali/internal/web-engine/common/web-engine-impl.h>
 
@@ -512,4 +513,9 @@ Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMess
   return GetImplementation(*this).ConsoleMessageSignal();
 }
 
+Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal()
+{
+  return GetImplementation(*this).PolicyDecisionSignal();
+}
+
 } // namespace Dali
index 1c6e97a..9b479e4 100755 (executable)
@@ -678,6 +678,13 @@ public:
    */
   Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& ConsoleMessageSignal();
 
+  /**
+   * @brief Connects to this signal to be notified when new policy would be decided.
+   *
+   * @return A signal object to connect with.
+   */
+  Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& PolicyDecisionSignal();
+
 private: // Not intended for application developers
   /**
    * @brief Internal constructor
index b1aca21..b5664dc 100755 (executable)
@@ -95,8 +95,10 @@ SET( devel_api_adaptor_framework_header_files
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-context.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-cookie-manager.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-form-repost-decision.h
+  ${adaptor_devel_api_dir}/adaptor-framework/web-engine-frame.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-load-error.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-plugin.h
+  ${adaptor_devel_api_dir}/adaptor-framework/web-engine-policy-decision.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-request-interceptor.h
   ${adaptor_devel_api_dir}/adaptor-framework/web-engine-settings.h
   ${adaptor_devel_api_dir}/adaptor-framework/key-extension-plugin.h
index bd2f0e2..4c3b7d8 100755 (executable)
@@ -32,6 +32,7 @@
 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
+#include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
 #include <dali/internal/system/common/environment-variables.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
@@ -607,6 +608,11 @@ Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMess
   return mPlugin->ConsoleMessageSignal();
 }
 
+Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal()
+{
+  return mPlugin->PolicyDecisionSignal();
+}
+
 } // namespace Adaptor
 } // namespace Internal
 } // namespace Dali
index bfac881..0500628 100755 (executable)
@@ -494,6 +494,11 @@ public:
    */
   Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& ConsoleMessageSignal();
 
+  /**
+   @copydoc Dali::WebEngine::PolicyDecisionSignal()
+   */
+  Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& PolicyDecisionSignal();
+
 private:
   /**
    * @brief Constructor.