From: huayong.xu Date: Wed, 3 Feb 2021 08:42:59 +0000 (+0800) Subject: Support policy decision in web engine. X-Git-Tag: dali_2.0.21~11 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=aadc3293fd8e560de900b542f5fe92a77db8c3f5 Support policy decision in web engine. This patch is to add policy decision feature in web engine. Change-Id: I5ce01683303a139a64d5e7f8e4c83e624542796b --- 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 index 0000000..51beba9 --- /dev/null +++ b/dali/devel-api/adaptor-framework/web-engine-frame.h @@ -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 + +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 diff --git a/dali/devel-api/adaptor-framework/web-engine-plugin.h b/dali/devel-api/adaptor-framework/web-engine-plugin.h index 3530b1b..bbfa6f6 100644 --- a/dali/devel-api/adaptor-framework/web-engine-plugin.h +++ b/dali/devel-api/adaptor-framework/web-engine-plugin.h @@ -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; /** + * @brief WebView signal type related with policy would be decided. + */ + using WebEnginePolicyDecisionSignalType = Signal)>; + + /** * @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 index 0000000..a9fda10 --- /dev/null +++ b/dali/devel-api/adaptor-framework/web-engine-policy-decision.h @@ -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 + +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 diff --git a/dali/devel-api/adaptor-framework/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine.cpp index d186a61..b1d9fa0 100755 --- a/dali/devel-api/adaptor-framework/web-engine.cpp +++ b/dali/devel-api/adaptor-framework/web-engine.cpp @@ -23,8 +23,9 @@ #include #include #include -#include #include +#include +#include #include #include @@ -512,4 +513,9 @@ Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMess return GetImplementation(*this).ConsoleMessageSignal(); } +Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal() +{ + return GetImplementation(*this).PolicyDecisionSignal(); +} + } // namespace Dali diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h index 1c6e97a..9b479e4 100755 --- a/dali/devel-api/adaptor-framework/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine.h @@ -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 diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index b1aca21..b5664dc 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -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 diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp index bd2f0e2..4c3b7d8 100755 --- a/dali/internal/web-engine/common/web-engine-impl.cpp +++ b/dali/internal/web-engine/common/web-engine-impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -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 diff --git a/dali/internal/web-engine/common/web-engine-impl.h b/dali/internal/web-engine/common/web-engine-impl.h index bfac881..0500628 100755 --- a/dali/internal/web-engine/common/web-engine-impl.h +++ b/dali/internal/web-engine/common/web-engine-impl.h @@ -494,6 +494,11 @@ public: */ Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& ConsoleMessageSignal(); + /** + @copydoc Dali::WebEngine::PolicyDecisionSignal() + */ + Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& PolicyDecisionSignal(); + private: /** * @brief Constructor.