[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 d71ce4cc3d1f9d1bc0fd9680f036ce5a61af9100..917ebb4fc2f307e46b8e2cf9853ebc324266b4db 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 cf67881d9c1ca6c16bcb479b17d69d49401c3175..a811235b0cc5f23d5e1ad23d3a1c1585d8c64693 100644 (file)
@@ -103,6 +103,8 @@ class CookieManager : public base::RefCountedThreadSafe<CookieManager> {
   bool IsFileSchemeCookiesAllowed();
   void AllowFileSchemeCookies(bool allow);
 
+  void EWebContextShutDown();
+
  private:
   struct EwkGetHostCallback;
 
index c678e03c0eae5139c1e932ceea57ff8f9128f40f..a8955582896e62d88fb25e57c7262885ea97dc62 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 0b8d8fabf42499fded21a04d57460f25df3fc78a..b8e4750b9d0057fe779ec4d7c0cef2e895b1e353 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,