From 04ac566274b389acb4913ef8af74851c69c99918 Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Tue, 6 Jul 2021 10:29:13 +0800 Subject: [PATCH] Replace Signal with std::function. Originally Signal is used to notify webview when callback of web engine is called. If Signal is called with a std::shared_ptr, lifecyle of object X would be managed by Signal only in csharp-binder. So if Signal are destroyed, object X would be destroyed too. This might cause some problem. This patch is to replace Signal with std::fuction, and replace std:shared_ptr with unique_ptr. Lifecycle of object X would not be associated with that of Signal. Change-Id: I7ce7cd977994308541ac645494b6dea97765e818 --- .../adaptor-framework/web-engine-plugin.h | 166 +++++++++++---------- dali/devel-api/adaptor-framework/web-engine.cpp | 68 ++++----- dali/devel-api/adaptor-framework/web-engine.h | 100 ++++++------- .../internal/web-engine/common/web-engine-impl.cpp | 68 ++++----- dali/internal/web-engine/common/web-engine-impl.h | 68 ++++----- 5 files changed, 240 insertions(+), 230 deletions(-) diff --git a/dali/devel-api/adaptor-framework/web-engine-plugin.h b/dali/devel-api/adaptor-framework/web-engine-plugin.h index 7facdac..69027c2 100755 --- a/dali/devel-api/adaptor-framework/web-engine-plugin.h +++ b/dali/devel-api/adaptor-framework/web-engine-plugin.h @@ -58,35 +58,40 @@ class WebEnginePlugin { public: /** - * @brief WebEngine signal type related with page loading. + * @brief WebView signal type related with frame rendered. + */ + using WebEngineFrameRenderedSignalType = Signal; + + /** + * @brief WebEngine callback related with page loading. */ - using WebEnginePageLoadSignalType = Signal; + using WebEnginePageLoadCallback = std::function; /** - * @brief WebView signal type related with page loading error. + * @brief WebView callback related with page loading error. */ - using WebEnginePageLoadErrorSignalType = Signal)>; + using WebEnginePageLoadErrorCallback = std::function)>; // forward declaration. enum class ScrollEdge; /** - * @brief WebView signal type related with scroll edge reached. + * @brief WebView callback related with scroll edge reached. */ - using WebEngineScrollEdgeReachedSignalType = Signal; + using WebEngineScrollEdgeReachedCallback = std::function; /** - * @brief WebView signal type related with page url changed. + * @brief WebView callback related with page url changed. */ - using WebEngineUrlChangedSignalType = Signal; + using WebEngineUrlChangedCallback = std::function; /** - * @brief WebView signal type related with screen captured. + * @brief WebView callback related with screen captured. */ using ScreenshotCapturedCallback = std::function; /** - * @brief WebView signal type related with geolocation permission. + * @brief WebView callback related with geolocation permission. * Host and protocol of security origin will be provided when requesting * geolocation permission. * It returns true if a pop-up is created successfully, false otherwise. @@ -94,39 +99,44 @@ public: using GeolocationPermissionCallback = std::function; /** - * @brief WebView signal type related with video playing. + * @brief WebView callback related with video playing. */ using VideoPlayingCallback = std::function; /** - * @brief WebView signal type related with http request interceptor. + * @brief WebView callback related with http request interceptor. + */ + using WebEngineRequestInterceptorCallback = std::function)>; + + /** + * @brief WebView callback related with console message logged. */ - using WebEngineRequestInterceptorSignalType = Signal)>; + using WebEngineConsoleMessageReceivedCallback = std::function)>; /** - * @brief WebView signal type related with console message logged. + * @brief WebView callback related with certificate changed. */ - using WebEngineConsoleMessageSignalType = Signal)>; + using WebEngineCertificateCallback = std::function)>; /** - * @brief WebView signal type related with certificate changed. + * @brief WebView callback related with http authentication. */ - using WebEngineCertificateSignalType = Signal)>; + using WebEngineHttpAuthHandlerCallback = std::function)>; /** - * @brief WebView signal type related with http authentication. + * @brief WebView callback related with context menu shown. */ - using WebEngineHttpAuthHandlerSignalType = Signal)>; + using WebEngineContextMenuShownCallback = std::function)>; /** - * @brief WebView signal type related with context menu shown. + * @brief WebView callback related with context menu hidden. */ - using WebEngineContextMenuShownSignalType = Signal)>; + using WebEngineContextMenuHiddenCallback = std::function)>; /** - * @brief WebView signal type related with context menu hidden. + * @brief Message result callback when JavaScript is executed with a message. */ - using WebEngineContextMenuHiddenSignalType = Signal)>; + using JavaScriptMessageHandlerCallback = std::function; /** * @brief Alert callback when JavaScript alert is called with a message. @@ -148,19 +158,19 @@ public: using JavaScriptPromptCallback = std::function; /** - * @brief WebView signal type related with form repost decision. + * @brief WebView callback related with form repost decision. */ - using WebEngineFormRepostDecisionSignalType = Signal)>; + using WebEngineFormRepostDecidedCallback = std::function)>; /** - * @brief WebView signal type related with frame rendered. + * @brief WebView callback related with frame rendered. */ - using WebEngineFrameRenderedSignalType = Signal; + using WebEngineFrameRenderedCallback = std::function; /** - * @brief WebView signal type related with response policy would be decided. + * @brief WebView callback related with response policy would be decided. */ - using WebEngineResponsePolicyDecisionSignalType = Signal)>; + using WebEngineResponsePolicyDecidedCallback = std::function)>; /** * @brief Hit test callback called after hit test is created asynchronously. @@ -451,7 +461,7 @@ public: * @param[in] script The JavaScript code * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result. */ - virtual void EvaluateJavaScript(const std::string& script, std::function resultHandler) = 0; + virtual void EvaluateJavaScript(const std::string& script, JavaScriptMessageHandlerCallback resultHandler) = 0; /** * @brief Add a message handler into JavaScript. @@ -459,7 +469,7 @@ public: * @param[in] exposedObjectName The name of exposed object * @param[in] handler The callback function */ - virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler) = 0; + virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, JavaScriptMessageHandlerCallback handler) = 0; /** * @brief Register a callback for JavaScript alert. @@ -748,116 +758,116 @@ public: virtual bool SendWheelEvent(const WheelEvent& event) = 0; /** - * @brief Connect to this signal to be notified when page loading is started. + * @brief Connect to this signal to be notified when frame is rendered. * * @return A signal object to connect with. */ - virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0; + virtual WebEngineFrameRenderedSignalType& FrameRenderedSignal() = 0; /** - * @brief Connect to this signal to be notified when page loading is in progress. + * @brief Callback to be called when page loading is started. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEnginePageLoadSignalType& PageLoadInProgressSignal() = 0; + virtual void RegisterPageLoadStartedCallback(WebEnginePageLoadCallback callback) = 0; /** - * @brief Connect to this signal to be notified when page loading is finished. + * @brief Callback to be called when page loading is in progress. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0; + virtual void RegisterPageLoadInProgressCallback(WebEnginePageLoadCallback callback) = 0; /** - * @brief Connect to this signal to be notified when an error occurs in page loading. + * @brief Callback to be called when page loading is finished. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0; + virtual void RegisterPageLoadFinishedCallback(WebEnginePageLoadCallback callback) = 0; /** - * @brief Connect to this signal to be notified when scroll edge is reached. + * @brief Callback to be called when an error occurs in page loading. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0; + virtual void RegisterPageLoadErrorCallback(WebEnginePageLoadErrorCallback callback) = 0; /** - * @brief Connect to this signal to be notified when url is changed. + * @brief Callback to be called when scroll edge is reached. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineUrlChangedSignalType& UrlChangedSignal() = 0; + virtual void RegisterScrollEdgeReachedCallback(WebEngineScrollEdgeReachedCallback callback) = 0; /** - * @brief Connect to this signal to be notified when form repost decision is requested. + * @brief Callback to be called when url is changed. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineFormRepostDecisionSignalType& FormRepostDecisionSignal() = 0; + virtual void RegisterUrlChangedCallback(WebEngineUrlChangedCallback callback) = 0; /** - * @brief Connect to this signal to be notified when frame is rendered. + * @brief Callback to be called when form repost decision is requested. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineFrameRenderedSignalType& FrameRenderedSignal() = 0; + virtual void RegisterFormRepostDecidedCallback(WebEngineFormRepostDecidedCallback callback) = 0; /** - * @brief Connect to this signal to be notified when http request need be intercepted. + * @brief Callback to be called when http request need be intercepted. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineRequestInterceptorSignalType& RequestInterceptorSignal() = 0; + virtual void RegisterRequestInterceptorCallback(WebEngineRequestInterceptorCallback callback) = 0; /** - * @brief Connect to this signal to be notified when console message will be logged. + * @brief Callback to be called when console message will be logged. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineConsoleMessageSignalType& ConsoleMessageSignal() = 0; + virtual void RegisterConsoleMessageReceivedCallback(WebEngineConsoleMessageReceivedCallback callback) = 0; /** - * @brief Connect to this signal to be notified when response policy would be decided. + * @brief Callback to be called when response policy would be decided. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineResponsePolicyDecisionSignalType& ResponsePolicyDecisionSignal() = 0; + virtual void RegisterResponsePolicyDecidedCallback(WebEngineResponsePolicyDecidedCallback callback) = 0; /** - * @brief Connect to this signal to be notified when certificate need be confirmed. + * @brief Callback to be called when certificate need be confirmed. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineCertificateSignalType& CertificateConfirmSignal() = 0; + virtual void RegisterCertificateConfirmedCallback(WebEngineCertificateCallback callback) = 0; /** - * @brief Connect to this signal to be notified when ssl certificate is changed. + * @brief Callback to be called when ssl certificate is changed. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineCertificateSignalType& SslCertificateChangedSignal() = 0; + virtual void RegisterSslCertificateChangedCallback(WebEngineCertificateCallback callback) = 0; /** - * @brief Connect to this signal to be notified when http authentication need be confirmed. + * @brief Callback to be called when http authentication need be confirmed. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineHttpAuthHandlerSignalType& HttpAuthHandlerSignal() = 0; + virtual void RegisterHttpAuthHandlerCallback(WebEngineHttpAuthHandlerCallback callback) = 0; /** - * @brief Connect to this signal to be notified when context menu would be shown. + * @brief Callback to be called when context menu would be shown. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineContextMenuShownSignalType& ContextMenuShownSignal() = 0; + virtual void RegisterContextMenuShownCallback(WebEngineContextMenuShownCallback callback) = 0; /** - * @brief Connect to this signal to be notified when context menu would be hidden. + * @brief Callback to be called when context menu would be hidden. * - * @return A signal object to connect with. + * @param[in] callback */ - virtual WebEngineContextMenuHiddenSignalType& ContextMenuHiddenSignal() = 0; + virtual void RegisterContextMenuHiddenCallback(WebEngineContextMenuHiddenCallback callback) = 0; }; // specialization has to be done in the same namespace diff --git a/dali/devel-api/adaptor-framework/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine.cpp index 3758a00..0161ba6 100755 --- a/dali/devel-api/adaptor-framework/web-engine.cpp +++ b/dali/devel-api/adaptor-framework/web-engine.cpp @@ -257,12 +257,12 @@ void WebEngine::GoBack() GetImplementation(*this).GoBack(); } -void WebEngine::EvaluateJavaScript(const std::string& script, std::function resultHandler) +void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler) { GetImplementation(*this).EvaluateJavaScript(script, resultHandler); } -void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler) +void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler) { GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler); } @@ -477,84 +477,84 @@ void WebEngine::EnableVideoHole(bool enabled) GetImplementation(*this).EnableVideoHole(enabled); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() +Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal() { - return GetImplementation(*this).PageLoadStartedSignal(); + return GetImplementation(*this).FrameRenderedSignal(); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal() +void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback) { - return GetImplementation(*this).PageLoadInProgressSignal(); + GetImplementation(*this).RegisterPageLoadStartedCallback(callback); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() +void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback) { - return GetImplementation(*this).PageLoadFinishedSignal(); + GetImplementation(*this).RegisterPageLoadInProgressCallback(callback); } -Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() +void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback) { - return GetImplementation(*this).PageLoadErrorSignal(); + GetImplementation(*this).RegisterPageLoadFinishedCallback(callback); } -Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal() +void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback) { - return GetImplementation(*this).ScrollEdgeReachedSignal(); + GetImplementation(*this).RegisterPageLoadErrorCallback(callback); } -Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal() +void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback) { - return GetImplementation(*this).UrlChangedSignal(); + GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback); } -Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal() +void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback) { - return GetImplementation(*this).FormRepostDecisionSignal(); + GetImplementation(*this).RegisterUrlChangedCallback(callback); } -Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal() +void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback) { - return GetImplementation(*this).FrameRenderedSignal(); + GetImplementation(*this).RegisterFormRepostDecidedCallback(callback); } -Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal() +void WebEngine::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback) { - return GetImplementation(*this).RequestInterceptorSignal(); + GetImplementation(*this).RegisterRequestInterceptorCallback(callback); } -Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal() +void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback) { - return GetImplementation(*this).ConsoleMessageSignal(); + GetImplementation(*this).RegisterConsoleMessageReceivedCallback(callback); } -Dali::WebEnginePlugin::WebEngineResponsePolicyDecisionSignalType& WebEngine::ResponsePolicyDecisionSignal() +void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback) { - return GetImplementation(*this).ResponsePolicyDecisionSignal(); + GetImplementation(*this).RegisterResponsePolicyDecidedCallback(callback); } -Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::CertificateConfirmSignal() +void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback) { - return GetImplementation(*this).CertificateConfirmSignal(); + GetImplementation(*this).RegisterCertificateConfirmedCallback(callback); } -Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::SslCertificateChangedSignal() +void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback) { - return GetImplementation(*this).SslCertificateChangedSignal(); + GetImplementation(*this).RegisterSslCertificateChangedCallback(callback); } -Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& WebEngine::HttpAuthHandlerSignal() +void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback) { - return GetImplementation(*this).HttpAuthHandlerSignal(); + GetImplementation(*this).RegisterHttpAuthHandlerCallback(callback); } -Dali::WebEnginePlugin::WebEngineContextMenuShownSignalType& WebEngine::ContextMenuShownSignal() +void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback) { - return GetImplementation(*this).ContextMenuShownSignal(); + GetImplementation(*this).RegisterContextMenuShownCallback(callback); } -Dali::WebEnginePlugin::WebEngineContextMenuHiddenSignalType& WebEngine::ContextMenuHiddenSignal() +void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback) { - return GetImplementation(*this).ContextMenuHiddenSignal(); + GetImplementation(*this).RegisterContextMenuHiddenCallback(callback); } } // namespace Dali diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h index 9ea8f00..d3b5017 100755 --- a/dali/devel-api/adaptor-framework/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine.h @@ -331,7 +331,7 @@ public: * @param[in] script The JavaScript code * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result. */ - void EvaluateJavaScript(const std::string& script, std::function resultHandler); + void EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler); /** * @brief Add a message handler into JavaScript. @@ -339,7 +339,7 @@ public: * @param[in] exposedObjectName The name of exposed object * @param[in] handler The callback function */ - void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); + void AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler); /** * @brief Register a callback for JavaScript alert. @@ -632,116 +632,116 @@ public: bool SendWheelEvent(const WheelEvent& event); /** - * @brief Connect to this signal to be notified when page loading is started. + * @brief Connect to this signal to be notified when frame is rendered. * - * @return A signal object to connect with + * @return A signal object to connect with. */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal(); + Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal(); /** - * @brief Connect to this signal to be notified when page loading is in progress. + * @brief Callback to be called when page loading is started. * - * @return A signal object to connect with + * @param[in] callback */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadInProgressSignal(); + void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @brief Connect to this signal to be notified when page loading is finished. + * @brief Callback to be called when page loading is in progress. * - * @return A signal object to connect with + * @param[in] callback */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal(); + void RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @brief Connect to this signal to be notified when an error occurs in page loading. + * @brief Callback to be called when page loading is finished. * - * @return A signal object to connect with + * @param[in] callback */ - Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); + void RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @brief Connect to this signal to be notified when scroll edge is reached. + * @brief Callback to be called when an error occurs in page loading. * - * @return A signal object to connect with + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); + void RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback); /** - * @brief Connect to this signal to be notified when url is changed. + * @brief Callback to be called when scroll edge is reached. * - * @return A signal object to connect with + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& UrlChangedSignal(); + void RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback); /** - * @brief Connect to this signal to be notified when form repost decision is requested. + * @brief Callback to be called when url is changed. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& FormRepostDecisionSignal(); + void RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback); /** - * @brief Connect to this signal to be notified when frame is rendered. + * @brief Callback to be called when form repost decision is requested. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal(); + void RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback); /** - * @brief Connect to this signal to be notified when http request need be intercepted. + * @brief Callback to be called when http request need be intercepted. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& RequestInterceptorSignal(); + void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback); /** - * @brief Connect to this signal to be notified when console message will be logged. + * @brief Callback to be called when console message will be logged. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& ConsoleMessageSignal(); + void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback); /** - * @brief Connect to this signal to be notified when response policy would be decided. + * @brief Callback to be called when response policy would be decided. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineResponsePolicyDecisionSignalType& ResponsePolicyDecisionSignal(); + void RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback); /** - * @brief Connect to this signal to be notified when certificate need be confirmed. + * @brief Callback to be called when certificate need be confirmed. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineCertificateSignalType& CertificateConfirmSignal(); + void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback); /** - * @brief Connect to this signal to be notified when ssl certificate is changed. + * @brief Callback to be called when ssl certificate is changed. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineCertificateSignalType& SslCertificateChangedSignal(); + void RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback); /** - * @brief Connect to this signal to be notified when http authentication need be confirmed. + * @brief Callback to be called when http authentication need be confirmed. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& HttpAuthHandlerSignal(); + void RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback); /** - * @brief Connect to this signal to be notified when context menu would be shown. + * @brief Callback to be called when context menu would be shown. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineContextMenuShownSignalType& ContextMenuShownSignal(); + void RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback); /** - * @brief Connect to this signal to be notified when context menu would be hidden. + * @brief Callback to be called when context menu would be hidden. * - * @return A signal object to connect with. + * @param[in] callback */ - Dali::WebEnginePlugin::WebEngineContextMenuHiddenSignalType& ContextMenuHiddenSignal(); + void RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback); private: // Not intended for application developers /** diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp index b6539f8..1c83af7 100755 --- a/dali/internal/web-engine/common/web-engine-impl.cpp +++ b/dali/internal/web-engine/common/web-engine-impl.cpp @@ -401,12 +401,12 @@ void WebEngine::GoBack() mPlugin->GoBack(); } -void WebEngine::EvaluateJavaScript(const std::string& script, std::function resultHandler) +void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler) { mPlugin->EvaluateJavaScript(script, resultHandler); } -void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler) +void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler) { mPlugin->AddJavaScriptMessageHandler(exposedObjectName, handler); } @@ -571,84 +571,84 @@ bool WebEngine::SendWheelEvent(const Dali::WheelEvent& event) return mPlugin->SendWheelEvent(event); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() +Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal() { - return mPlugin->PageLoadStartedSignal(); + return mPlugin->FrameRenderedSignal(); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal() +void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback) { - return mPlugin->PageLoadInProgressSignal(); + mPlugin->RegisterPageLoadStartedCallback(callback); } -Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() +void WebEngine::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback) { - return mPlugin->PageLoadFinishedSignal(); + mPlugin->RegisterPageLoadInProgressCallback(callback); } -Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() +void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback) { - return mPlugin->PageLoadErrorSignal(); + mPlugin->RegisterPageLoadFinishedCallback(callback); } -Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal() +void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback) { - return mPlugin->ScrollEdgeReachedSignal(); + mPlugin->RegisterPageLoadErrorCallback(callback); } -Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal() +void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback) { - return mPlugin->UrlChangedSignal(); + mPlugin->RegisterScrollEdgeReachedCallback(callback); } -Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal() +void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback) { - return mPlugin->FormRepostDecisionSignal(); + mPlugin->RegisterUrlChangedCallback(callback); } -Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal() +void WebEngine::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback) { - return mPlugin->FrameRenderedSignal(); + mPlugin->RegisterFormRepostDecidedCallback(callback); } -Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal() +void WebEngine::RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback) { - return mPlugin->RequestInterceptorSignal(); + mPlugin->RegisterRequestInterceptorCallback(callback); } -Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal() +void WebEngine::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback) { - return mPlugin->ConsoleMessageSignal(); + mPlugin->RegisterConsoleMessageReceivedCallback(callback); } -Dali::WebEnginePlugin::WebEngineResponsePolicyDecisionSignalType& WebEngine::ResponsePolicyDecisionSignal() +void WebEngine::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback) { - return mPlugin->ResponsePolicyDecisionSignal(); + mPlugin->RegisterResponsePolicyDecidedCallback(callback); } -Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::CertificateConfirmSignal() +void WebEngine::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback) { - return mPlugin->CertificateConfirmSignal(); + mPlugin->RegisterCertificateConfirmedCallback(callback); } -Dali::WebEnginePlugin::WebEngineCertificateSignalType& WebEngine::SslCertificateChangedSignal() +void WebEngine::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback) { - return mPlugin->SslCertificateChangedSignal(); + mPlugin->RegisterSslCertificateChangedCallback(callback); } -Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& WebEngine::HttpAuthHandlerSignal() +void WebEngine::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback) { - return mPlugin->HttpAuthHandlerSignal(); + mPlugin->RegisterHttpAuthHandlerCallback(callback); } -Dali::WebEnginePlugin::WebEngineContextMenuShownSignalType& WebEngine::ContextMenuShownSignal() +void WebEngine::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback) { - return mPlugin->ContextMenuShownSignal(); + mPlugin->RegisterContextMenuShownCallback(callback); } -Dali::WebEnginePlugin::WebEngineContextMenuHiddenSignalType& WebEngine::ContextMenuHiddenSignal() +void WebEngine::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback) { - return mPlugin->ContextMenuHiddenSignal(); + mPlugin->RegisterContextMenuHiddenCallback(callback); } } // namespace Adaptor diff --git a/dali/internal/web-engine/common/web-engine-impl.h b/dali/internal/web-engine/common/web-engine-impl.h index 0dda54b..4f621a6 100755 --- a/dali/internal/web-engine/common/web-engine-impl.h +++ b/dali/internal/web-engine/common/web-engine-impl.h @@ -287,12 +287,12 @@ public: /** * @copydoc Dali::WebEngine::EvaluateJavaScript() */ - void EvaluateJavaScript(const std::string& script, std::function resultHandler); + void EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler); /** * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler() */ - void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function handler); + void AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler); /** * @copydoc Dali::WebEngine::ClearAllTilesResources() @@ -455,84 +455,84 @@ public: bool SendWheelEvent(const Dali::WheelEvent& event); /** - * @copydoc Dali::WebEngine::PageLoadStartedSignal() + * @copydoc Dali::WebEngine::FrameRenderedSignal() */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal(); + Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal(); /** - * @copydoc Dali::WebEngine::PageLoadProgressSignal() + * @copydoc Dali::WebEngine::RegisterPageLoadStartedCallback() */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadInProgressSignal(); + void RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @copydoc Dali::WebEngine::PageLoadFinishedSignal() + * @copydoc Dali::WebEngine::RegisterPageLoadInProgressCallback() */ - Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal(); + void RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @copydoc Dali::WebEngine::PageLoadErrorSignal() + * @copydoc Dali::WebEngine::RegisterPageLoadFinishedCallback() */ - Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); + void RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback); /** - * @copydoc Dali::WebEngine::ScrollEdgeReachedSignal() + * @copydoc Dali::WebEngine::RegisterPageLoadErrorCallback() */ - Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); + void RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback); /** - * @copydoc Dali::WebEngine::UrlChangedSignal() + * @copydoc Dali::WebEngine::RegisterScrollEdgeReachedCallback() */ - Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& UrlChangedSignal(); + void RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback); /** - * @copydoc Dali::WebEngine::FormRepostDecisionSignal() + * @copydoc Dali::WebEngine::RegisterUrlChangedCallback() */ - Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& FormRepostDecisionSignal(); + void RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback); /** - * @copydoc Dali::WebEngine::FrameRenderedSignal() + * @copydoc Dali::WebEngine::RegisterFormRepostDecidedCallback() */ - Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal(); + void RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngineFormRepostDecidedCallback callback); /** - * @copydoc Dali::WebEngine::RequestInterceptorSignal() + * @copydoc Dali::WebEngine::RegisterRequestInterceptorCallback() */ - Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& RequestInterceptorSignal(); + void RegisterRequestInterceptorCallback(Dali::WebEnginePlugin::WebEngineRequestInterceptorCallback callback); /** - @copydoc Dali::WebEngine::ConsoleMessageSignal() + @copydoc Dali::WebEngine::RegisterConsoleMessageReceivedCallback() */ - Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& ConsoleMessageSignal(); + void RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback); /** - @copydoc Dali::WebEngine::ResponsePolicyDecisionSignal() + @copydoc Dali::WebEngine::RegisterResponsePolicyDecidedCallback() */ - Dali::WebEnginePlugin::WebEngineResponsePolicyDecisionSignalType& ResponsePolicyDecisionSignal(); + void RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineResponsePolicyDecidedCallback callback); /** - * @copydoc Dali::WebEngine::CertificateConfirmSignal() + * @copydoc Dali::WebEngine::RegisterCertificateConfirmedCallback() */ - Dali::WebEnginePlugin::WebEngineCertificateSignalType& CertificateConfirmSignal(); + void RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback); /** - * @copydoc Dali::WebEngine::SslCertificateChangedSignal() + * @copydoc Dali::WebEngine::RegisterSslCertificateChangedCallback() */ - Dali::WebEnginePlugin::WebEngineCertificateSignalType& SslCertificateChangedSignal(); + void RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEngineCertificateCallback callback); /** - * @copydoc Dali::WebEngine::HttpAuthHandlerSignal() + * @copydoc Dali::WebEngine::RegisterHttpAuthHandlerCallback() */ - Dali::WebEnginePlugin::WebEngineHttpAuthHandlerSignalType& HttpAuthHandlerSignal(); + void RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHttpAuthHandlerCallback callback); /** - * @copydoc Dali::WebEngine::ContextMenuShownSignal() + * @copydoc Dali::WebEngine::RegisterContextMenuShownCallback() */ - Dali::WebEnginePlugin::WebEngineContextMenuShownSignalType& ContextMenuShownSignal(); + void RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineContextMenuShownCallback callback); /** - * @copydoc Dali::WebEngine::ContextMenuHiddenSignal() + * @copydoc Dali::WebEngine::RegisterContextMenuHiddenCallback() */ - Dali::WebEnginePlugin::WebEngineContextMenuHiddenSignalType& ContextMenuHiddenSignal(); + void RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngineContextMenuHiddenCallback callback); private: /** -- 2.7.4