From: Bakka Uday Kiran Date: Fri, 10 Feb 2023 10:38:38 +0000 (+0530) Subject: [M108 Migration] Reset EWebContext ptr in CookieManager during EWebContext destroyed X-Git-Tag: submit/tizen/20230227.160252~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eebfc7f5c6f945a09dfc966e7451aa93f09b8ef6;p=platform%2Fframework%2Fweb%2Fchromium-efl.git [M108 Migration] Reset EWebContext ptr in CookieManager during EWebContext destroyed CookieManager accesses EWebContext when it handles cookie storage, but it has longer life cycle than EWebContext. To prevent accessing the destroyed EWebContext, this patch resets the pointer of EWebContext in CookieManager when EWebContext is destroyed. Chromium supports only SQLite based persistent cookie storage. This patch deprecates an enumeration for text file based cookie storage, EWK_COOKIE_PERSISTENT_STORAGE_TEXT. Reference: https://review.tizen.org/gerrit/c/281416 https://review.tizen.org/gerrit/c/280780 Change-Id: I180b12b6929aac1d991d2c942f1eaf6780de992f Signed-off-by: Bakka Uday Kiran --- diff --git a/tizen_src/ewk/efl_integration/cookie_manager.cc b/tizen_src/ewk/efl_integration/cookie_manager.cc index d71ce4c..917ebb4 100644 --- a/tizen_src/ewk/efl_integration/cookie_manager.cc +++ b/tizen_src/ewk/efl_integration/cookie_manager.cc @@ -275,7 +275,7 @@ bool CookieManager::IsFileSchemeCookiesAllowed() { } void CookieManager::AllowFileSchemeCookies(bool allow) { - if (allow == is_file_scheme_cookies_allowed_) + if (allow == is_file_scheme_cookies_allowed_ || !eweb_context_) return; auto* cookie_manager = eweb_context_->browser_context() @@ -359,6 +359,11 @@ scoped_refptr CookieManager::GetContextGett return scoped_refptr(request_context_getter_.get()); } +void CookieManager::EWebContextShutDown() { + LOG(INFO) << "EWebContext is shutting down."; + eweb_context_ = nullptr; +} + net::CookieStore* CookieManager::GetCookieStore() const { return request_context_getter_ ? request_context_getter_->GetURLRequestContext()->cookie_store() diff --git a/tizen_src/ewk/efl_integration/cookie_manager.h b/tizen_src/ewk/efl_integration/cookie_manager.h index cf67881..a811235 100644 --- a/tizen_src/ewk/efl_integration/cookie_manager.h +++ b/tizen_src/ewk/efl_integration/cookie_manager.h @@ -103,6 +103,8 @@ class CookieManager : public base::RefCountedThreadSafe { bool IsFileSchemeCookiesAllowed(); void AllowFileSchemeCookies(bool allow); + void EWebContextShutDown(); + private: struct EwkGetHostCallback; diff --git a/tizen_src/ewk/efl_integration/eweb_context.cc b/tizen_src/ewk/efl_integration/eweb_context.cc index c678e03..a895558 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.cc +++ b/tizen_src/ewk/efl_integration/eweb_context.cc @@ -400,6 +400,7 @@ EWebContext::~EWebContext() { auto cbce = static_cast(cbc); cbce->SetBrowserContext(browser_context_.release()); #endif + cookieManager()->EWebContextShutDown(); } void EWebContext::ClearNetworkCache() { diff --git a/tizen_src/ewk/efl_integration/public/ewk_cookie_manager.cc b/tizen_src/ewk/efl_integration/public/ewk_cookie_manager.cc index 0b8d8fa..b8e4750 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_cookie_manager.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_cookie_manager.cc @@ -45,12 +45,11 @@ void ewk_cookie_manager_persistent_storage_set(Ewk_Cookie_Manager* manager, const char* file_name, - Ewk_Cookie_Persistent_Storage storage) -{ + Ewk_Cookie_Persistent_Storage) { EWK_COOKIE_MANAGER_GET_OR_RETURN(manager, cookie_manager); EINA_SAFETY_ON_NULL_RETURN(file_name); - std::string fileName(file_name); - cookie_manager->SetStoragePath(file_name, true /*persist session*/, storage); + cookie_manager->SetStoragePath(file_name, true /*persist session*/, + EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); } void ewk_cookie_manager_accept_policy_set(Ewk_Cookie_Manager* manager,