From: huayong.xu Date: Tue, 12 Jul 2022 08:03:25 +0000 (+0800) Subject: Make web engine context be a singleton. X-Git-Tag: dali_2.1.32~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=e1dfa20fee127dd3bcfabf0c9f1aea6b5dd99f5e Make web engine context be a singleton. Change-Id: I602af540c5d8f475ebd18c3ba3e8ff5460dfc45d --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 075cf2a..0e86810 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -55,15 +55,16 @@ namespace Adaptor class WebEngine; class MockWebEngineContext; +class MockWebEngineCookieManager; namespace { - // Generally only one WebEngine instance exists. // If > 1, a new web engine has been created by CreateWindowSignal. -static WebEngine* gInstance = nullptr; -static int gInstanceCount = 0; -static MockWebEngineContext* gWebEngineContextInstance = nullptr; +WebEngine* gInstance = nullptr; +int gInstanceCount = 0; +MockWebEngineContext* gWebEngineContextInstance = nullptr; +MockWebEngineCookieManager* gMockWebEngineCookieManager = nullptr; bool OnGoBack(); bool OnGoForward(); @@ -342,6 +343,15 @@ private: float mockZoomFactor; }; +Dali::WebEngineContext* GetContext() +{ + if (!gWebEngineContextInstance) + { + gWebEngineContextInstance = new MockWebEngineContext(); + } + return gWebEngineContextInstance; +} + class MockWebEngineCookieManager : public Dali::WebEngineCookieManager { public: @@ -384,6 +394,15 @@ private: Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy; }; +Dali::WebEngineCookieManager* GetCookieManager() +{ + if (!gMockWebEngineCookieManager) + { + gMockWebEngineCookieManager = new MockWebEngineCookieManager(); + } + return gMockWebEngineCookieManager; +} + class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem { public: @@ -1211,13 +1230,6 @@ public: } mockWebEngineSettings = new MockWebEngineSettings(); - MockWebEngineContext* engineContext = new MockWebEngineContext(); - mockWebEngineContext = engineContext; - if ( gInstanceCount == 1 ) - { - gWebEngineContextInstance = engineContext; - } - mockWebEngineCookieManager = new MockWebEngineCookieManager(); mockWebEngineBackForwardList = new MockWebEngineBackForwardList(); } @@ -1226,13 +1238,10 @@ public: gInstanceCount--; if( !gInstanceCount ) { - gInstance = 0; - gWebEngineContextInstance = 0; + gInstance = nullptr; } delete mockWebEngineSettings; - delete mockWebEngineContext; - delete mockWebEngineCookieManager; delete mockWebEngineBackForwardList; } @@ -1241,16 +1250,6 @@ public: return *mockWebEngineSettings; } - Dali::WebEngineContext& GetContext() const - { - return *mockWebEngineContext; - } - - Dali::WebEngineCookieManager& GetCookieManager() const - { - return *mockWebEngineCookieManager; - } - Dali::WebEngineBackForwardList& GetBackForwardList() const { return *mockWebEngineBackForwardList; @@ -1604,8 +1603,6 @@ public: Dali::Vector2 mScrollSize; Dali::Vector2 mContentSize; WebEngineBackForwardList* mockWebEngineBackForwardList; - WebEngineContext* mockWebEngineContext; - WebEngineCookieManager* mockWebEngineCookieManager; WebEngineSettings* mockWebEngineSettings; std::vector mResultCallbacks; @@ -1938,17 +1935,11 @@ bool OnRequestIntercepted() bool OnChangesWatch() { - DisconnectFromGlobalSignal( &OnChangesWatch ); - - if ( gInstance ) + DisconnectFromGlobalSignal(&OnChangesWatch); + if (gMockWebEngineCookieManager) { - MockWebEngineCookieManager* temp = (MockWebEngineCookieManager *)(&(gInstance->GetCookieManager())); - if ( temp ) - { - temp->mChangesWatchCallback(); - } + gMockWebEngineCookieManager->mChangesWatchCallback(); } - return false; } @@ -2004,6 +1995,16 @@ WebEngine WebEngine::New() return WebEngine( baseObject ); } +Dali::WebEngineContext* WebEngine::GetContext() +{ + return Internal::Adaptor::GetContext(); +} + +Dali::WebEngineCookieManager* WebEngine::GetCookieManager() +{ + return Internal::Adaptor::GetCookieManager(); +} + WebEngine::WebEngine( const WebEngine& WebEngine ) : BaseHandle( WebEngine ) { @@ -2037,16 +2038,6 @@ WebEngineSettings& WebEngine::GetSettings() const return Internal::Adaptor::GetImplementation( *this ).GetSettings(); } -WebEngineContext& WebEngine::GetContext() const -{ - return Internal::Adaptor::GetImplementation( *this ).GetContext(); -} - -WebEngineCookieManager& WebEngine::GetCookieManager() const -{ - return Internal::Adaptor::GetImplementation( *this ).GetCookieManager(); -} - WebEngineBackForwardList& WebEngine::GetBackForwardList() const { return Internal::Adaptor::GetImplementation( *this ).GetBackForwardList(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp old mode 100644 new mode 100755 index 442d75d..30693fc --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -22,8 +22,6 @@ #include "dali-toolkit-test-utils/toolkit-timer.h" #include -#include -#include #include #include #include @@ -31,9 +29,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -890,10 +889,7 @@ int UtcDaliWebViewGetWebContext(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0); END_TEST; @@ -903,10 +899,7 @@ int UtcDaliWebViewGetWebCookieManager(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager(); DALI_TEST_CHECK(cookieManager != 0); END_TEST; @@ -1519,14 +1512,11 @@ int UtcDaliWebBackForwardListCheckItem(void) // test cases for web context. -int UtcDaliWebContextGetSetCacheModel(void) +int UtcDaliWebContextGetSetCacheModelEtc(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0) std::string kDefaultValue; @@ -1595,10 +1585,7 @@ int UtcDaliWebContextGetWebDatabaseStorageOrigins(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0) std::string kDefaultValue; @@ -1665,10 +1652,7 @@ int UtcDaliWebContextHttpRequestInterceptor(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0) // load url. @@ -1708,10 +1692,7 @@ int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager(); DALI_TEST_CHECK(cookieManager != 0) const std::string kDefaultValue; @@ -1736,10 +1717,7 @@ int UtcDaliWebCookieManagerChangesWatch(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager(); DALI_TEST_CHECK(cookieManager != 0) cookieManager->ChangesWatch(&OnChangesWatch); diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.cpp b/dali-toolkit/devel-api/controls/web-view/web-context.cpp deleted file mode 100755 index 128546b..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-context.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2022 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. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Toolkit -{ -WebContext::WebContext(Dali::WebEngineContext& context) -: mWebEngineContext(context) -{ -} - -WebContext::~WebContext() -{ -} - -Dali::WebEngineContext::CacheModel WebContext::GetCacheModel() const -{ - return mWebEngineContext.GetCacheModel(); -} - -void WebContext::SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel) -{ - mWebEngineContext.SetCacheModel(cacheModel); -} - -void WebContext::SetProxyUri(const std::string& uri) -{ - mWebEngineContext.SetProxyUri(uri); -} - -std::string WebContext::GetProxyUri() const -{ - return mWebEngineContext.GetProxyUri(); -} - -void WebContext::SetProxyBypassRule(const std::string& proxy, const std::string& bypass) -{ - mWebEngineContext.SetProxyBypassRule(proxy, bypass); -} - -std::string WebContext::GetProxyBypassRule() const -{ - return mWebEngineContext.GetProxyBypassRule(); -} - -void WebContext::SetCertificateFilePath(const std::string& certificatePath) -{ - mWebEngineContext.SetCertificateFilePath(certificatePath); -} - -std::string WebContext::GetCertificateFilePath() const -{ - return mWebEngineContext.GetCertificateFilePath(); -} - -void WebContext::SetDefaultProxyAuth(const std::string& username, const std::string& password) -{ - mWebEngineContext.SetDefaultProxyAuth(username, password); -} - -void WebContext::DeleteAllWebDatabase() -{ - mWebEngineContext.DeleteAllWebDatabase(); -} - -bool WebContext::GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) -{ - return mWebEngineContext.GetWebDatabaseOrigins(callback); -} - -bool WebContext::DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin) -{ - return mWebEngineContext.DeleteWebDatabase(origin); -} - -bool WebContext::GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) -{ - return mWebEngineContext.GetWebStorageOrigins(callback); -} - -bool WebContext::GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback) -{ - return mWebEngineContext.GetWebStorageUsageForOrigin(origin, callback); -} - -void WebContext::DeleteAllWebStorage() -{ - mWebEngineContext.DeleteAllWebStorage(); -} - -bool WebContext::DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin) -{ - return mWebEngineContext.DeleteWebStorage(origin); -} - -void WebContext::DeleteLocalFileSystem() -{ - mWebEngineContext.DeleteLocalFileSystem(); -} - -void WebContext::ClearCache() -{ - mWebEngineContext.ClearCache(); -} - -bool WebContext::DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin) -{ - return mWebEngineContext.DeleteApplicationCache(origin); -} - -void WebContext::GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback) -{ - mWebEngineContext.GetFormPasswordList(callback); -} - -void WebContext::RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback) -{ - mWebEngineContext.RegisterDownloadStartedCallback(callback); -} - -void WebContext::RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback) -{ - mWebEngineContext.RegisterMimeOverriddenCallback(callback); -} - -void WebContext::RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback) -{ - mWebEngineContext.RegisterRequestInterceptedCallback(callback); -} - -void WebContext::EnableCache(bool cacheEnabled) -{ - mWebEngineContext.EnableCache(cacheEnabled); -} - -bool WebContext::IsCacheEnabled() const -{ - return mWebEngineContext.IsCacheEnabled(); -} - -void WebContext::SetAppId(const std::string& appId) -{ - mWebEngineContext.SetAppId(appId); -} - -bool WebContext::SetAppVersion(const std::string& appVersion) -{ - return mWebEngineContext.SetAppVersion(appVersion); -} - -void WebContext::SetApplicationType(const Dali::WebEngineContext::ApplicationType applicationType) -{ - mWebEngineContext.SetApplicationType(applicationType); -} - -void WebContext::SetTimeOffset(float timeOffset) -{ - mWebEngineContext.SetTimeOffset(timeOffset); -} - -void WebContext::SetTimeZoneOffset(float timeZoneOffset, float daylightSavingTime) -{ - mWebEngineContext.SetTimeZoneOffset(timeZoneOffset, daylightSavingTime); -} - -void WebContext::SetDefaultZoomFactor(float zoomFactor) -{ - mWebEngineContext.SetDefaultZoomFactor(zoomFactor); -} - -float WebContext::GetDefaultZoomFactor() const -{ - return mWebEngineContext.GetDefaultZoomFactor(); -} - -void WebContext::RegisterUrlSchemesAsCorsEnabled(const std::vector& schemes) -{ - mWebEngineContext.RegisterUrlSchemesAsCorsEnabled(schemes); -} - -void WebContext::RegisterJsPluginMimeTypes(const std::vector& mimeTypes) -{ - mWebEngineContext.RegisterJsPluginMimeTypes(mimeTypes); -} - -bool WebContext::DeleteAllApplicationCache() -{ - return mWebEngineContext.DeleteAllApplicationCache(); -} - -bool WebContext::DeleteAllWebIndexedDatabase() -{ - return mWebEngineContext.DeleteAllWebIndexedDatabase(); -} - -void WebContext::DeleteFormPasswordDataList(const std::vector& list) -{ - mWebEngineContext.DeleteFormPasswordDataList(list); -} - -void WebContext::DeleteAllFormPasswordData() -{ - mWebEngineContext.DeleteAllFormPasswordData(); -} - -void WebContext::DeleteAllFormCandidateData() -{ - mWebEngineContext.DeleteAllFormCandidateData(); -} - -bool WebContext::FreeUnusedMemory() -{ - return mWebEngineContext.FreeUnusedMemory(); -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.h b/dali-toolkit/devel-api/controls/web-view/web-context.h deleted file mode 100755 index ebdbae0..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-context.h +++ /dev/null @@ -1,373 +0,0 @@ -#ifndef DALI_TOOLKIT_WEB_CONTEXT_H -#define DALI_TOOLKIT_WEB_CONTEXT_H - -/* - * Copyright (c) 2022 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 -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -class WebEngineSecurityOrigin; - -namespace Toolkit -{ -/** - * @addtogroup dali_toolkit_controls_web_view - * @{ - */ - -/** - * @brief WebContext is a control for context of WebView. - * - * For working WebContext, a WebEngineContext should be provided. - * - */ -class DALI_TOOLKIT_API WebContext -{ -public: - /** - * @brief Create a WebContext. - * - * @param[in] context The context of web engine. - */ - WebContext(Dali::WebEngineContext& context); - - /** - * @brief Destructor. - */ - virtual ~WebContext() final; - - /** - * @brief Return the cache model type. - * - * @return #Dali::WebEngineContext::CacheModel - */ - Dali::WebEngineContext::CacheModel GetCacheModel() const; - - /** - * @brief Request to set the cache model. - * - * @param[in] cacheModel The cache model - */ - void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel); - - /** - * @brief Set the given proxy URI to network backend of specific context. - * - * @param[in] uri The proxy URI to set - */ - void SetProxyUri(const std::string& uri); - - /** - * @brief Get the proxy URI from the network backend of specific context. - * - * @return current proxy URI or null string if it's not set - */ - std::string GetProxyUri() const; - - /** - * @brief Set the given proxy to network backend of specific context. - * - * @param[in] proxy URI to set - * @param[in] bypass rule to set - */ - void SetProxyBypassRule(const std::string& proxy, const std::string& bypass); - - /** - * @brief Get the proxy bypass rule from the network backend of specific context. - * - * @return current proxy bypass rule or null string if it's not set - */ - std::string GetProxyBypassRule() const; - - /** - * @brief Add CA certificates to persistent NSS certificate database - * - * Function accepts a path to a CA certificate file, a path to a directory - * containing CA certificate files, or a colon-seprarated list of those. - * Certificate files should have *.crt extension. - * Directories are traversed recursively. - * - * @param[in] certificatePath path to a CA certificate file(s), see above for details - */ - void SetCertificateFilePath(const std::string& certificatePath); - - /** - * @brief Get CA certifcate file path - * - * It returns an internal string and should not be modified. - * - * @return certificate_file path which is set during ewk_context_certificate_file_set or null string otherwise - */ - std::string GetCertificateFilePath() const; - - /** - * @brief Set a proxy auth credential to network backend of specific context. - * - * @param[in] username username to set - * @param[in] password password to set - */ - void SetDefaultProxyAuth(const std::string& username, const std::string& password); - - /** - * @brief Requests for deleting all web databases. - */ - void DeleteAllWebDatabase(); - - /** - * @brief Request for getting web database origins. - * - * @param[in] callback callback called after getting web database origins - * - * @return true if succeeded, false otherwise - */ - bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback); - - /** - * @brief Request for deleting web databases for origin. - * - * @param[in] origin database origin - * - * @return true if succeeded, false otherwise - */ - bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin); - - /** - * @brief Gets list of origins that is stored in web storage db. - * - * @param[in] callback callback called after getting web storage origins - * - * @return true if succeeded, false otherwise - */ - bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback); - - /** - * @brief Get list of origins that is stored in web storage db. - * - * @param[in] origin storage origin - * @param[in] callback callback called after getting web storage origins - * - * @return true if succeeded, false otherwise - */ - bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback); - - /** - * @brief Delete all web storage. - * - * @details This function does not ensure that all data will be removed. - * Should be used to extend free physical memory. - */ - void DeleteAllWebStorage(); - - /** - * @brief Delete web storage db. - * - * @param[in] origin origin of db - * - * @return true if succeeded, false otherwise - */ - bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin); - - /** - * @brief Request for deleting all local file systems. - */ - void DeleteLocalFileSystem(); - - /** - * @brief Requests to clear cache - */ - void ClearCache(); - - /** - * @brief Request for deleting web application cache for origin. - * - * @param[in] origin application cache origin - * - * @return true if succeeded, false otherwise - */ - bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin); - - /** - * @brief Asynchronous request to get list of all password data. - * - * @param[in] callback callback called after getting form password - */ - void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback); - - /** - * @brief Register callback for download started. - * - * @param[in] callback callback for download started - */ - void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback); - - /** - * @brief Register callback for mime overridden. - * - * @param[in] callback callback for mime overridden - */ - void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback); - - /** - * @brief Callback to be called when http request need be intercepted. - * - * @param[in] callback - */ - void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback); - - /** - * @brief Toggle the cache to be enabled or disabled - * - * @param[in] cacheEnabled enable or disable cache - */ - void EnableCache(bool cacheEnabled); - - /** - * @brief Query if the cache is enabled - * - * @return true is cache is enabled or false otherwise - */ - bool IsCacheEnabled() const; - - /** - * @brief Set application id for context. - * - * @param[in] appId application id - */ - void SetAppId(const std::string& appId); - - /** - * @brief Set application version for context. - * - * @param[in] appVersion application version - * - * @return true if successful, false otherwise - */ - bool SetAppVersion(const std::string& appVersion); - - /** - * @brief To declare application type - * - * @param[in] applicationType The Application_Type enum - * - */ - void SetApplicationType(const Dali::WebEngineContext::ApplicationType applicationType); - - /** - * @brief Set time offset - * - * @param[in] timeOffset The value will be added to system time as offset - */ - void SetTimeOffset(float timeOffset); - - /** - * @brief Set timezone offset - * - * @param[in] timeZoneOffset offset for time zone. - * @param[in] daylightSavingTime The value is for daylight saving time use. - */ - void SetTimeZoneOffset(float timeZoneOffset, float daylightSavingTime); - - /** - * @brief Set default zoom factor - * - * @param[in] zoomFactor default zoom factor - */ - void SetDefaultZoomFactor(float zoomFactor); - - /** - * @brief Get default zoom factor - * - * Gets default zoom factor for all pages opened with this context. - * - * @return default zoom factor or negative value on error - */ - float GetDefaultZoomFactor() const; - - /** - * @brief Register url schemes as CORS enabled - * - * @param[in] schemes The URL schemes list which will be added to web security policy - * - */ - void RegisterUrlSchemesAsCorsEnabled(const std::vector& schemes); - - /** - * @brief Register JS plugin mime types. - * - * @param[in] mimeTypes The MIME types will be checked by the renderer frame loader - * to skip creating default frame for the object tags with the registered MIME type. - */ - void RegisterJsPluginMimeTypes(const std::vector& mimeTypes); - - /** - * @brief Request for deleting all web application caches. - * - * @return @c true on success, otherwise @c false - */ - bool DeleteAllApplicationCache(); - - /** - * @brief Request for deleting all web indexed databases. - * - * @return @c true on success, otherwise @c false - */ - bool DeleteAllWebIndexedDatabase(); - - /** - * @brief Delete a given password data list - * - * @param[in] list List with Ewk_Password_Data - */ - void DeleteFormPasswordDataList(const std::vector& list); - - /** - * @brief Delete whole password data from DB - */ - void DeleteAllFormPasswordData(); - - /** - * @brief Delete all candidate form data from DB - */ - void DeleteAllFormCandidateData(); - - /** - * @brief Notify low memory to free unused memory. - * - * @return @c true on success or @c false otherwise. - */ - bool FreeUnusedMemory(); - -private: - Dali::WebEngineContext& mWebEngineContext; -}; - -/** - * @} - */ - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_WEB_CONTEXT_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp deleted file mode 100755 index 61529a8..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - * - */ - -// CLASS HEADER -#include - -namespace Dali -{ -namespace Toolkit -{ -WebCookieManager::WebCookieManager(Dali::WebEngineCookieManager& manager) -: mWebEngineCookieManager(manager) -{ -} - -WebCookieManager::~WebCookieManager() -{ -} - -void WebCookieManager::SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy cookieAcceptPolicy) -{ - mWebEngineCookieManager.SetCookieAcceptPolicy(cookieAcceptPolicy); -} - -Dali::WebEngineCookieManager::CookieAcceptPolicy WebCookieManager::GetCookieAcceptPolicy() const -{ - return mWebEngineCookieManager.GetCookieAcceptPolicy(); -} - -void WebCookieManager::ClearCookies() -{ - mWebEngineCookieManager.ClearCookies(); -} - -void WebCookieManager::SetPersistentStorage(const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage) -{ - mWebEngineCookieManager.SetPersistentStorage(path, storage); -} - -void WebCookieManager::ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback) -{ - mWebEngineCookieManager.ChangesWatch(callback); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h deleted file mode 100755 index b7b5bf1..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef DALI_TOOLKIT_WEB_COOKIE_MANAGER_H -#define DALI_TOOLKIT_WEB_COOKIE_MANAGER_H - -/* - * Copyright (c) 2022 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 -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -class WebEngineCookieManager; - -namespace Toolkit -{ -/** - * @addtogroup dali_toolkit_controls_web_view - * @{ - */ - -/** - * @brief WebCookieManager is a control for cookie manager of WebView. - * - * - * For working WebCookieManager, a WebView should be provided. - * - */ -class DALI_TOOLKIT_API WebCookieManager -{ -public: - /** - * @brief Creates a WebCookieManager. - * @param[in] manager A #Dali::WebEngineCookieManager - */ - WebCookieManager(Dali::WebEngineCookieManager& manager); - - /** - * @brief Destructor. - */ - virtual ~WebCookieManager() final; - - /** - * @brief Sets @a policy as the cookie acceptance policy for @a manager. - * - * @details By default, only cookies set by the main document loaded are - * accepted. - * - * @param[in] policy A #Dali::WebEngineCookieManager::CookieAcceptPolicy - */ - void SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy policy); - - /** - * @brief Gets the cookie acceptance policy. The default is Toolkit::WebCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY. - * @see Dali::WebEngineCookieManager::CookieAcceptPolicy - */ - Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const; - - /** - * @brief Deletes all the cookies of @a manager. - */ - void ClearCookies(); - - /** - * @brief Sets the @a path where non-session cookies are stored persistently using - * @a storage as the format to read/write the cookies. - * - * @details Cookies are initially read from @a path/Cookies to create an initial - * set of cookies. Then, non-session cookies will be written to @a path/Cookies. - * By default, @a manager doesn't store the cookies persistently, so you need to - * call this method to keep cookies saved across sessions. - * If @a path does not exist it will be created. - * - * @param[in] path The path where to read/write Cookies - * @param[in] storage The type of storage - */ - void SetPersistentStorage(const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage); - - /** - * @brief Watch for cookies' changes in @a manager. - * - * @param[in] callback cookies are added, removed or modified. - */ - void ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback); - -private: - Dali::WebEngineCookieManager& mWebEngineCookieManager; -}; - -/** - * @} - */ - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_WEB_COOKIE_MANAGER_H diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.cpp b/dali-toolkit/devel-api/controls/web-view/web-view.cpp index 5b0f3d2..321b43f 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-view.cpp @@ -64,24 +64,24 @@ WebView WebView::New(uint32_t argc, char** argv) return Internal::WebView::New(argc, argv); } -WebView WebView::DownCast(BaseHandle handle) +Dali::WebEngineContext* WebView::GetContext() { - return Control::DownCast(handle); + return Internal::WebView::GetContext(); } -Dali::Toolkit::WebSettings* WebView::GetSettings() const +Dali::WebEngineCookieManager* WebView::GetCookieManager() { - return Dali::Toolkit::GetImpl(*this).GetSettings(); + return Internal::WebView::GetCookieManager(); } -Dali::Toolkit::WebContext* WebView::GetContext() const +WebView WebView::DownCast(BaseHandle handle) { - return Dali::Toolkit::GetImpl(*this).GetContext(); + return Control::DownCast(handle); } -Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const +Dali::Toolkit::WebSettings* WebView::GetSettings() const { - return Dali::Toolkit::GetImpl(*this).GetCookieManager(); + return Dali::Toolkit::GetImpl(*this).GetSettings(); } Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index 55908e8..4d90fbd 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -216,6 +216,16 @@ public: static WebView New(uint32_t argc, char** argv); /** + * @brief Get context of web engine. + */ + static Dali::WebEngineContext* GetContext(); + + /** + * @brief Get cookie manager of web engine. + */ + static Dali::WebEngineCookieManager* GetCookieManager(); + + /** * @brief Create an uninitialized WebView. */ WebView(); @@ -259,16 +269,6 @@ public: Dali::Toolkit::WebSettings* GetSettings() const; /** - * @brief Get WebContext of WebEngine. - */ - Dali::Toolkit::WebContext* GetContext() const; - - /** - * @brief Get CookieManager of WebEngine. - */ - Dali::Toolkit::WebCookieManager* GetCookieManager() const; - - /** * @brief Get WebBackForwardList of WebEngine. */ Dali::Toolkit::WebBackForwardList* GetBackForwardList() const; diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 0a000bc..b501c9c 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -41,8 +41,6 @@ SET( devel_api_src_files ${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp ${devel_api_src_dir}/controls/video-view/video-view-devel.cpp ${devel_api_src_dir}/controls/web-view/web-back-forward-list.cpp - ${devel_api_src_dir}/controls/web-view/web-context.cpp - ${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp ${devel_api_src_dir}/controls/web-view/web-settings.cpp ${devel_api_src_dir}/controls/web-view/web-view.cpp ${devel_api_src_dir}/focus-manager/keyinput-focus-manager.cpp @@ -260,8 +258,6 @@ SET( devel_api_video_view_header_files SET( devel_api_web_view_header_files ${devel_api_src_dir}/controls/web-view/web-back-forward-list.h - ${devel_api_src_dir}/controls/web-view/web-context.h - ${devel_api_src_dir}/controls/web-view/web-cookie-manager.h ${devel_api_src_dir}/controls/web-view/web-settings.h ${devel_api_src_dir}/controls/web-view/web-view.h ) diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp index 4beea3f..5aeeabf 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -44,8 +44,6 @@ // INTERNAL INCLUDES #include #include -#include -#include #include #include #include @@ -178,6 +176,16 @@ Toolkit::WebView WebView::New(uint32_t argc, char** argv) return handle; } +Dali::WebEngineContext* WebView::GetContext() +{ + return Dali::WebEngine::GetContext(); +} + +Dali::WebEngineCookieManager* WebView::GetCookieManager() +{ + return Dali::WebEngine::GetCookieManager(); +} + void WebView::OnInitialize() { Actor self = Self(); @@ -199,8 +207,6 @@ void WebView::OnInitialize() if(mWebEngine) { mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered); - mWebContext = std::unique_ptr(new WebContext(mWebEngine.GetContext())); - mWebCookieManager = std::unique_ptr(new WebCookieManager(mWebEngine.GetCookieManager())); mWebSettings = std::unique_ptr(new WebSettings(mWebEngine.GetSettings())); mWebBackForwardList = std::unique_ptr(new WebBackForwardList(mWebEngine.GetBackForwardList())); } @@ -218,16 +224,6 @@ Dali::Toolkit::WebSettings* WebView::GetSettings() const return mWebSettings.get(); } -Dali::Toolkit::WebContext* WebView::GetContext() const -{ - return mWebContext.get(); -} - -Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const -{ - return mWebCookieManager.get(); -} - Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const { return mWebBackForwardList.get(); diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h index 6fe96ad..377ea61 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -40,8 +40,6 @@ namespace Toolkit class KeyEvent; class TouchEvent; class WebBackForwardList; -class WebContext; -class WebCookieManager; class WebSettings; class WebView; @@ -75,19 +73,19 @@ public: static Toolkit::WebView New(uint32_t argc, char** argv); /** - * @copydoc Dali::Toolkit::WebView::GetSettings() + * @copydoc Dali::Toolkit::WebView::GetContext() */ - Dali::Toolkit::WebSettings* GetSettings() const; + static Dali::WebEngineContext* GetContext(); /** - * @copydoc Dali::Toolkit::WebView::GetContext() + * @copydoc Dali::Toolkit::WebView::GetCookieManager() */ - Dali::Toolkit::WebContext* GetContext() const; + static Dali::WebEngineCookieManager* GetCookieManager(); /** - * @copydoc Dali::Toolkit::WebView::GetCookieManager() + * @copydoc Dali::Toolkit::WebView::GetSettings() */ - Dali::Toolkit::WebCookieManager* GetCookieManager() const; + Dali::Toolkit::WebSettings* GetSettings() const; /** * @copydoc Dali::Toolkit::WebView::GetBackForwardList() @@ -698,8 +696,6 @@ private: Dali::Size mWebViewSize; Dali::WebEngine mWebEngine; - std::unique_ptr mWebContext; - std::unique_ptr mWebCookieManager; std::unique_ptr mWebSettings; std::unique_ptr mWebBackForwardList;