[M108 Migration] Reset EWebContext ptr in CookieManager during EWebContext destroyed 02/288102/10
authorBakka Uday Kiran <b.kiran@samsung.com>
Fri, 10 Feb 2023 10:38:38 +0000 (16:08 +0530)
committerBot Blink <blinkbot@samsung.com>
Wed, 15 Feb 2023 15:52:34 +0000 (15:52 +0000)
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 <b.kiran@samsung.com>
tizen_src/ewk/efl_integration/cookie_manager.cc
tizen_src/ewk/efl_integration/cookie_manager.h
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/public/ewk_cookie_manager.cc

index d71ce4c..917ebb4 100644 (file)
@@ -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<content::URLRequestContextGetterEfl> CookieManager::GetContextGett
   return scoped_refptr<content::URLRequestContextGetterEfl>(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()
index cf67881..a811235 100644 (file)
@@ -103,6 +103,8 @@ class CookieManager : public base::RefCountedThreadSafe<CookieManager> {
   bool IsFileSchemeCookiesAllowed();
   void AllowFileSchemeCookies(bool allow);
 
+  void EWebContextShutDown();
+
  private:
   struct EwkGetHostCallback;
 
index c678e03..a895558 100644 (file)
@@ -400,6 +400,7 @@ EWebContext::~EWebContext() {
   auto cbce = static_cast<content::ContentBrowserClientEfl*>(cbc);
   cbce->SetBrowserContext(browser_context_.release());
 #endif
+  cookieManager()->EWebContextShutDown();
 }
 
 void EWebContext::ClearNetworkCache() {
index 0b8d8fa..b8e4750 100644 (file)
 
 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,