[GTK] Cookies' storage path and policy are not set when the WebProcess is killed...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 09:19:44 +0000 (09:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 09:19:44 +0000 (09:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104370

Patch by Joaquim Rocha <jrocha@igalia.com> on 2012-12-12
Reviewed by Carlos Garcia Campos.

This issue happens on ports that use Soup and causes problems like not finding the stored cookies
nor their policy when the WebProcess is relaunched. As an example of a problem caused by this,
a previously logged in user will not be logged in again when the process is relaunched and the
policy used is always the same one.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode): Encode cookies' persistent storage path,
storage type and acceptance policy.
(WebKit::WebProcessCreationParameters::decode): Decode cookies' persistent storage path,
storage type and acceptance policy.
* Shared/WebProcessCreationParameters.h: Create 3 variables to hold the values mentioned above.
(WebProcessCreationParameters):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::WebCookieManagerProxy):
(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Call WebCookieManagerProxySoup::setCookieAcceptPolicy.
* UIProcess/WebCookieManagerProxy.h: Declare new Soup's methods setCookieAcceptPolicy, cookieAcceptPolicy and
cookiePersistentStorage as well as the variables m_cookieAcceptPolicy and m_cookiePersistentStorage.
(WebCookieManagerProxy):
* UIProcess/efl/WebContextEfl.cpp: Assign the parameters' cookiePersistentStoragePath and
cookiePersistentStorageType with the respective values.
(WebKit::WebContext::platformInitializeWebProcess):
* UIProcess/gtk/WebContextGtk.cpp: Assign the parameters' cookiePersistentStoragePath and
cookiePersistentStorageType with the respective values.
(WebKit::WebContext::platformInitializeWebProcess):
* UIProcess/soup/WebCookieManagerProxySoup.cpp:
(WebKit::WebCookieManagerProxy::setCookiePersistentStorage): Assign the m_cookiePersistentStorage pair
with the method's parameters.
(WebKit):
(WebKit::WebCookieManagerProxy::getCookiePersistentStorage): Implement this getter.
* WebProcess/Cookies/WebCookieManager.h: Declare setCookiePersistentStorage.
(WebCookieManager):
* WebProcess/soup/WebProcessSoup.cpp:
(WebKit::WebProcess::platformInitializeWebProcess): Set the cookies' persistent storage and policy
using the WebCookieManager's methods.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137432 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp
Source/WebKit2/UIProcess/WebCookieManagerProxy.h
Source/WebKit2/UIProcess/efl/WebContextEfl.cpp
Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp
Source/WebKit2/UIProcess/soup/WebCookieManagerProxySoup.cpp
Source/WebKit2/WebProcess/Cookies/WebCookieManager.h
Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp

index 71f40fa..bbf5ad8 100644 (file)
@@ -1,3 +1,45 @@
+2012-12-12  Joaquim Rocha  <jrocha@igalia.com>
+
+        [GTK] Cookies' storage path and policy are not set when the WebProcess is killed and relaunched
+        https://bugs.webkit.org/show_bug.cgi?id=104370
+
+        Reviewed by Carlos Garcia Campos.
+
+        This issue happens on ports that use Soup and causes problems like not finding the stored cookies
+        nor their policy when the WebProcess is relaunched. As an example of a problem caused by this,
+        a previously logged in user will not be logged in again when the process is relaunched and the
+        policy used is always the same one.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode): Encode cookies' persistent storage path,
+        storage type and acceptance policy.
+        (WebKit::WebProcessCreationParameters::decode): Decode cookies' persistent storage path,
+        storage type and acceptance policy.
+        * Shared/WebProcessCreationParameters.h: Create 3 variables to hold the values mentioned above.
+        (WebProcessCreationParameters):
+        * UIProcess/WebCookieManagerProxy.cpp:
+        (WebKit::WebCookieManagerProxy::WebCookieManagerProxy):
+        (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Call WebCookieManagerProxySoup::setCookieAcceptPolicy.
+        * UIProcess/WebCookieManagerProxy.h: Declare new Soup's methods setCookieAcceptPolicy, cookieAcceptPolicy and
+        cookiePersistentStorage as well as the variables m_cookieAcceptPolicy and m_cookiePersistentStorage.
+        (WebCookieManagerProxy):
+        * UIProcess/efl/WebContextEfl.cpp: Assign the parameters' cookiePersistentStoragePath and
+        cookiePersistentStorageType with the respective values.
+        (WebKit::WebContext::platformInitializeWebProcess):
+        * UIProcess/gtk/WebContextGtk.cpp: Assign the parameters' cookiePersistentStoragePath and
+        cookiePersistentStorageType with the respective values.
+        (WebKit::WebContext::platformInitializeWebProcess):
+        * UIProcess/soup/WebCookieManagerProxySoup.cpp:
+        (WebKit::WebCookieManagerProxy::setCookiePersistentStorage): Assign the m_cookiePersistentStorage pair
+        with the method's parameters.
+        (WebKit):
+        (WebKit::WebCookieManagerProxy::getCookiePersistentStorage): Implement this getter.
+        * WebProcess/Cookies/WebCookieManager.h: Declare setCookiePersistentStorage.
+        (WebCookieManager):
+        * WebProcess/soup/WebProcessSoup.cpp:
+        (WebKit::WebProcess::platformInitializeWebProcess): Set the cookies' persistent storage and policy
+        using the WebCookieManager's methods.
+
 2012-12-11  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         [EFL][WK2] Duplicated WebPageGroup initialization
index 5b55cb1..af8fb54 100644 (file)
@@ -78,6 +78,9 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) con
 #endif
 #if USE(SOUP)
     encoder << urlSchemesRegistered;
+    encoder << cookiePersistentStoragePath;
+    encoder << cookiePersistentStorageType;
+    encoder.encodeEnum(cookieAcceptPolicy);
 #endif
     encoder.encodeEnum(cacheModel);
     encoder << shouldTrackVisitedLinks;
@@ -172,6 +175,12 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
 #if USE(SOUP)
     if (!decoder->decode(parameters.urlSchemesRegistered))
         return false;
+    if (!decoder->decode(parameters.cookiePersistentStoragePath))
+        return false;
+    if (!decoder->decode(parameters.cookiePersistentStorageType))
+        return false;
+    if (!decoder->decode(parameters.cookieAcceptPolicy))
+        return false;
 #endif
     if (!decoder->decodeEnum(parameters.cacheModel))
         return false;
index cda8e45..f651111 100644 (file)
 #include "MachPort.h"
 #endif
 
+#if USE(SOUP)
+#include "HTTPCookieAcceptPolicy.h"
+#endif
+
 namespace CoreIPC {
     class ArgumentDecoder;
     class ArgumentEncoder;
@@ -77,6 +81,9 @@ struct WebProcessCreationParameters {
 #endif
 #if USE(SOUP)
     Vector<String> urlSchemesRegistered;
+    String cookiePersistentStoragePath;
+    uint32_t cookiePersistentStorageType;
+    HTTPCookieAcceptPolicy cookieAcceptPolicy;
 #endif
 
     CacheModel cacheModel;
index 66fe9a0..78d6477 100644 (file)
@@ -169,10 +169,10 @@ public:
 
 #if PLATFORM(WIN)
     void setShouldPaintNativeControls(bool);
-
+#endif
+#if PLATFORM(WIN) || USE(SOUP)
     void setInitialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { m_initialHTTPCookieAcceptPolicy = policy; }
 #endif
-
     void setEnhancedAccessibility(bool);
     
     // Downloads.
@@ -398,6 +398,8 @@ private:
 
 #if PLATFORM(WIN)
     bool m_shouldPaintNativeControls;
+#endif
+#if PLATFORM(WIN) || USE(SOUP)
     HTTPCookieAcceptPolicy m_initialHTTPCookieAcceptPolicy;
 #endif
 
index b63c80c..5406198 100644 (file)
@@ -41,6 +41,9 @@ PassRefPtr<WebCookieManagerProxy> WebCookieManagerProxy::create(WebContext* cont
 
 WebCookieManagerProxy::WebCookieManagerProxy(WebContext* context)
     : m_webContext(context)
+#if USE(SOUP)
+    , m_cookiePersistentStorageType(SoupCookiePersistentStorageSQLite)
+#endif
 {
     m_webContext->addMessageReceiver(Messages::WebCookieManagerProxy::messageReceiverName(), this);
 }
@@ -134,6 +137,9 @@ void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy pol
 #if PLATFORM(MAC)
     persistHTTPCookieAcceptPolicy(policy);
 #endif
+#if USE(SOUP)
+    m_webContext->setInitialHTTPCookieAcceptPolicy(policy);
+#endif
 
     m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
 }
index c0168e2..3467bb4 100644 (file)
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
+#if USE(SOUP)
+#include "SoupCookiePersistentStorageType.h"
+#endif
+
 namespace CoreIPC {
     class Connection;
     class MessageID;
@@ -72,6 +76,7 @@ public:
 
 #if USE(SOUP)
     void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
+    void getCookiePersistentStorage(String& storagePath, uint32_t& storageType) const;
 #endif
 
     bool shouldTerminate(WebProcessProxy*) const;
@@ -99,6 +104,11 @@ private:
     HashMap<uint64_t, RefPtr<HTTPCookieAcceptPolicyCallback> > m_httpCookieAcceptPolicyCallbacks;
 
     WebCookieManagerProxyClient m_client;
+
+#if USE(SOUP)
+    String m_cookiePersistentStoragePath;
+    SoupCookiePersistentStorageType m_cookiePersistentStorageType;
+#endif
 };
 
 } // namespace WebKit
index c71a93c..ec864cc 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "config.h"
+#include "WebCookieManagerProxy.h"
 #include "WebContext.h"
 
 #include "Logging.h"
@@ -88,6 +89,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     initializeInspectorServer();
 
     parameters.urlSchemesRegistered = m_soupRequestManagerProxy->registeredURISchemes();
+    m_cookieManagerProxy->getCookiePersistentStorage(parameters.cookiePersistentStoragePath, parameters.cookieAcceptPolicy);
 }
 
 void WebContext::platformInvalidateContext()
index 0b09e99..1a62a14 100644 (file)
@@ -29,6 +29,7 @@
 #include "WebContext.h"
 
 #include "Logging.h"
+#include "WebCookieManagerProxy.h";
 #include "WebInspectorServer.h"
 #include "WebProcessCreationParameters.h"
 #include "WebSoupRequestManagerProxy.h"
@@ -87,6 +88,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     initInspectorServer();
 
     parameters.urlSchemesRegistered = m_soupRequestManagerProxy->registeredURISchemes();
+    m_cookieManagerProxy->getCookiePersistentStorage(parameters.cookiePersistentStoragePath, parameters.cookieAcceptPolicy);
 }
 
 void WebContext::platformInvalidateContext()
index 08914ed..fe20bab 100644 (file)
@@ -34,6 +34,15 @@ namespace WebKit {
 void WebCookieManagerProxy::setCookiePersistentStorage(const String& storagePath, uint32_t storageType)
 {
     m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::SetCookiePersistentStorage(storagePath, storageType));
+
+    m_cookiePersistentStoragePath = storagePath;
+    m_cookiePersistentStorageType = static_cast<SoupCookiePersistentStorageType>(storageType);
+}
+
+void WebCookieManagerProxy::getCookiePersistentStorage(String& storagePath, uint32_t& storageType) const
+{
+    storagePath = m_cookiePersistentStoragePath;
+    storageType = static_cast<uint32_t>(m_cookiePersistentStorageType);
 }
 
 }
index aac0419..1dba752 100644 (file)
@@ -53,6 +53,10 @@ public:
 
     void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
 
+#if USE(SOUP)
+    void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
+#endif
+
 private:
     WebCookieManager();
     
@@ -67,10 +71,6 @@ private:
     void startObservingCookieChanges();
     void stopObservingCookieChanges();
 
-#if USE(SOUP)
-    void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
-#endif
-
     void didReceiveWebCookieManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
 };
 
index 746e367..f854711 100644 (file)
@@ -29,6 +29,7 @@
 
 #define LIBSOUP_USE_UNSTABLE_REQUEST_API
 
+#include "WebCookieManager.h"
 #include "WebProcessCreationParameters.h"
 #include <WebCore/FileSystem.h>
 #include <WebCore/Language.h>
@@ -169,6 +170,12 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     for (size_t i = 0; i < parameters.urlSchemesRegistered.size(); i++)
         m_soupRequestManager.registerURIScheme(parameters.urlSchemesRegistered[i]);
 
+    if (!parameters.cookiePersistentStoragePath.isEmpty()) {
+        WebCookieManager::shared().setCookiePersistentStorage(parameters.cookiePersistentStoragePath,
+            parameters.cookiePersistentStorageType);
+    }
+    WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy);
+
     WebCore::addLanguageChangeObserver(this, languageChanged);
 }