From: zhouleonlei Date: Fri, 9 Apr 2021 06:18:08 +0000 (+0800) Subject: Add APIs of webview context X-Git-Tag: dali_2.0.23~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=1cef647fe405dc3f2f5b05547bf9e31ae3858ea4;hp=-c Add APIs of webview context ewk_context_cache_disabled_get ewk_context_certificate_file_get ewk_context_tizen_app_id_set ewk_context_tizen_app_version_set ewk_context_application_type_set ewk_context_time_offset_set ewk_context_timezone_offset_set ewk_context_register_url_schemes_as_cors_enabled ewk_context_register_jsplugin_mime_types ewk_context_default_zoom_factor_set ewk_context_default_zoom_factor_get ewk_context_application_cache_delete_all ewk_context_web_indexed_database_delete_all ewk_context_form_password_data_list_free ewk_context_form_password_data_delete_all ewk_context_form_candidate_data_delete_all ewk_context_proxy_uri_get ewk_context_proxy_set ewk_context_proxy_bypass_rule_get ewk_context_notify_low_memory Change-Id: I8644022e5f68eb0d15cb8aca97d55236c9f791c2 --- 1cef647fe405dc3f2f5b05547bf9e31ae3858ea4 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 765d015..88be84c 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 @@ -171,7 +171,7 @@ public: { } - bool DeleteWebStorageOrigin(Dali::WebEngineSecurityOrigin& origin) + bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin) { return true; } @@ -180,10 +180,6 @@ public: { } - void DisableCache( bool cacheDisabled ) override - { - } - void ClearCache() override { } @@ -220,6 +216,99 @@ public: } } + void EnableCache( bool cacheEnabled ) override + { + } + + bool IsCacheEnabled() const override + { + return true; + } + + std::string GetContextCertificateFile() const override + { + return "test"; + } + + void SetContextAppId(const std::string& appID) override + { + } + + bool SetContextAppVersion(const std::string& appVersion) override + { + return true; + } + + void SetContextApplicationType(const Dali::WebEngineContext::ApplicationType applicationType) override + { + } + + void SetContextTimeOffset(float timeOffset) override + { + } + + void SetContextTimeZoneOffset(float timeZoneOffset, float daylightSavingTime) override + { + } + + void RegisterUrlSchemesAsCorsEnabled(const std::vector& schemes) override + { + } + + void RegisterJsPluginMimeTypes(const std::vector& mimeTypes) override + { + } + + void SetDefaultZoomFactor(float zoomFactor) override + { + } + + float GetContextDefaultZoomFactor() const override + { + return 0; + } + + bool DeleteAllApplicationCache() override + { + return true; + } + + bool DeleteAllWebIndexedDatabase() override + { + return true; + } + + void DeleteFormPasswordDataList(const std::vector& list) override + { + } + + void DeleteAllFormPasswordData() override + { + } + + void DeleteAllFormCandidateData() override + { + } + + std::string GetContextProxy() const override + { + return "test"; + } + + void SetContextProxy(const std::string& proxy, const std::string& bypass) override + { + } + + std::string GetProxyBypassRule() const override + { + return "test"; + } + + bool FreeUnusedMemory() override + { + return true; + } + public: Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback mSecurityOriginAcquiredCallback; Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback mStorageUsageAcquiredCallback; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index a4ae7e1..86776ff 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -1583,12 +1583,19 @@ int UtcDaliWebContextGetSetCacheModel(void) // Reset something context->SetProxyUri( kDefaultValue ); context->SetCertificateFilePath( kDefaultValue ); - context->DisableCache( false ); + context->EnableCache( true ); context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue ); context->DeleteAllWebDatabase(); context->DeleteAllWebStorage(); context->DeleteLocalFileSystem(); context->ClearCache(); + context->SetContextAppId( "id" ); + context->SetContextApplicationType( Dali::WebEngineContext::ApplicationType::OTHER ); + context->SetContextTimeOffset( 0 ); + context->SetContextTimeZoneOffset( 0, 0 ); + context->SetDefaultZoomFactor( 0 ); + context->DeleteAllFormPasswordData(); + context->DeleteAllFormCandidateData(); // Check default value Dali::WebEngineContext::CacheModel value = context->GetCacheModel(); @@ -1599,6 +1606,37 @@ int UtcDaliWebContextGetSetCacheModel(void) value = context->GetCacheModel(); DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER ); + // Get cache enabled + DALI_TEST_CHECK( context->IsCacheEnabled() ); + + // Get certificate + std::string str = context->GetContextCertificateFile(); + DALI_TEST_EQUALS( str, "test", TEST_LOCATION ); + + // Set version + DALI_TEST_CHECK( context->SetContextAppVersion( "test" ) ); + + // Register + std::vector temp; + context->RegisterUrlSchemesAsCorsEnabled( temp ); + context->RegisterJsPluginMimeTypes( temp ); + context->DeleteFormPasswordDataList( temp ); + + // Get zoom + DALI_TEST_EQUALS( context->GetContextDefaultZoomFactor(), float( 0 ), TEST_LOCATION ); + + // Delete cache and database + DALI_TEST_CHECK( context->DeleteAllApplicationCache() ); + DALI_TEST_CHECK( context->DeleteAllWebIndexedDatabase() ); + + // Get contextProxy + context->SetContextProxy("", ""); + DALI_TEST_EQUALS( context->GetContextProxy(), "test", TEST_LOCATION ); + DALI_TEST_EQUALS( context->GetProxyBypassRule(), "test", TEST_LOCATION ); + + //Notify low memory + DALI_TEST_CHECK( context->FreeUnusedMemory() ); + END_TEST; } @@ -1644,7 +1682,7 @@ int UtcDaliWebContextGetWebDatabaseStorageOrigins(void) Test::EmitGlobalTimerSignal(); DALI_TEST_EQUALS( gStorageUsageAcquiredCallbackCalled, 1, TEST_LOCATION ); - result = context->DeleteWebStorageOrigin(*origin); + result = context->DeleteWebStorage(*origin); DALI_TEST_CHECK( result ); result = context->DeleteApplicationCache(*origin); diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.cpp b/dali-toolkit/devel-api/controls/web-view/web-context.cpp old mode 100644 new mode 100755 index 413f5ca..2a7090b --- a/dali-toolkit/devel-api/controls/web-view/web-context.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-context.cpp @@ -54,11 +54,6 @@ void WebContext::SetCertificateFilePath(const std::string& certificatePath) mWebEngineContext.SetCertificateFilePath(certificatePath); } -void WebContext::DisableCache(bool cacheDisabled) -{ - mWebEngineContext.DisableCache(cacheDisabled); -} - void WebContext::SetDefaultProxyAuth(const std::string& username, const std::string& password) { mWebEngineContext.SetDefaultProxyAuth(username, password); @@ -94,9 +89,9 @@ void WebContext::DeleteAllWebStorage() mWebEngineContext.DeleteAllWebStorage(); } -bool WebContext::DeleteWebStorageOrigin(Dali::WebEngineSecurityOrigin& origin) +bool WebContext::DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin) { - return mWebEngineContext.DeleteWebStorageOrigin(origin); + return mWebEngineContext.DeleteWebStorage(origin); } void WebContext::DeleteLocalFileSystem() @@ -129,5 +124,110 @@ void WebContext::RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngin mWebEngineContext.RegisterMimeOverriddenCallback(callback); } +void WebContext::EnableCache(bool cacheEnabled) +{ + mWebEngineContext.EnableCache(cacheEnabled); +} + +bool WebContext::IsCacheEnabled() const +{ + return mWebEngineContext.IsCacheEnabled(); +} + +std::string WebContext::GetContextCertificateFile() const +{ + return mWebEngineContext.GetContextCertificateFile(); +} + +void WebContext::SetContextAppId(const std::string& appID) +{ + mWebEngineContext.SetContextAppId(appID); +} + +bool WebContext::SetContextAppVersion(const std::string& appVersion) +{ + return mWebEngineContext.SetContextAppVersion(appVersion); +} + +void WebContext::SetContextApplicationType(const Dali::WebEngineContext::ApplicationType applicationType) +{ + mWebEngineContext.SetContextApplicationType(applicationType); +} + +void WebContext::SetContextTimeOffset(float timeOffset) +{ + mWebEngineContext.SetContextTimeOffset(timeOffset); +} + +void WebContext::SetContextTimeZoneOffset(float timeZoneOffset, float daylightSavingTime) +{ + mWebEngineContext.SetContextTimeZoneOffset(timeZoneOffset, daylightSavingTime); +} + +void WebContext::RegisterUrlSchemesAsCorsEnabled(const std::vector& schemes) +{ + mWebEngineContext.RegisterUrlSchemesAsCorsEnabled(schemes); +} + +void WebContext::RegisterJsPluginMimeTypes(const std::vector& mimeTypes) +{ + mWebEngineContext.RegisterJsPluginMimeTypes(mimeTypes); +} + +void WebContext::SetDefaultZoomFactor(float zoomFactor) +{ + mWebEngineContext.SetDefaultZoomFactor(zoomFactor); +} + +float WebContext::GetContextDefaultZoomFactor() const +{ + return mWebEngineContext.GetContextDefaultZoomFactor(); +} + +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(); +} + +std::string WebContext::GetContextProxy() const +{ + return mWebEngineContext.GetContextProxy(); +} + +void WebContext::SetContextProxy(const std::string& proxy, const std::string& bypass) +{ + mWebEngineContext.SetContextProxy(proxy, bypass); +} + +std::string WebContext::GetProxyBypassRule() const +{ + return mWebEngineContext.GetProxyBypassRule(); +} + +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 index cdf7f0e..531ec00 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-context.h +++ b/dali-toolkit/devel-api/controls/web-view/web-context.h @@ -91,16 +91,6 @@ public: void SetCertificateFilePath(const std::string& certificatePath); /** - * @brief Toggle the cache to be enabled or disabled - * - * Function works asynchronously. - * By default the cache is disabled resulting in not storing network data on disk. - * - * @param[in] cacheDisabled enable or disable cache - */ - void DisableCache(bool cacheDisabled); - - /** * @brief Set a proxy auth credential to network backend of specific context. * * @param[in] username username to set @@ -159,13 +149,13 @@ public: void DeleteAllWebStorage(); /** - * @brief Delete origin that is stored in web storage db. + * @brief Delete web storage db. * * @param[in] origin origin of db * * @return true if succeeded, false otherwise */ - bool DeleteWebStorageOrigin(Dali::WebEngineSecurityOrigin& origin); + bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin); /** * @brief Request for deleting all local file systems. @@ -207,6 +197,160 @@ public: */ void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback 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 @c true is cache is enabled or @c false otherwise + */ + bool IsCacheEnabled() const; + + /** + * @brief Get CA certifcate file path + * + * It returns an internal string and should not be modified. + * + * @return @c certificate_file is path which is set during ewk_context_certificate_file_set or @c null string otherwise + */ + std::string GetContextCertificateFile() const; + + /** + * @brief Set application id for @a context. + * + * @param[in] appID application id + */ + void SetContextAppId(const std::string& appID); + + /** + * @brief Set application version for @a context. + * + * @param[in] appVersion application version + * + * @return @c true if successful, @c false otherwise + */ + bool SetContextAppVersion(const std::string& appVersion); + + /** + * @brief To declare application type + * + * @param[in] applicationType The Application_Type enum + * + */ + void SetContextApplicationType(const Dali::WebEngineContext::ApplicationType applicationType); + + /** + * @brief Set time offset + * + * @param[in] timeOffset The value will be added to system time as offset + */ + void SetContextTimeOffset(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 SetContextTimeZoneOffset(float timeZoneOffset, float daylightSavingTime); + + /** + * @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 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 @c default zoom factor or negative value on error + */ + float GetContextDefaultZoomFactor() const; + + /** + * @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 Get the proxy URI from the network backend of specific context. + * + * @return current proxy URI or @c null string if it's not set + */ + std::string GetContextProxy() 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 SetContextProxy(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 @c null string if it's not set + */ + std::string GetProxyBypassRule() const; + + /** + * @brief Notify low memory to free unused memory. + * + * @return @c true on success or @c false otherwise. + */ + bool FreeUnusedMemory(); + private: Dali::WebEngineContext& mWebEngineContext; };