[Windows WebKit2] Use cookies set in WebKit1
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 May 2011 00:49:26 +0000 (00:49 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 May 2011 00:49:26 +0000 (00:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=60274

Reviewed by Steve Falkenburg.

Source/WebCore:

Share the default storage session between the UI and Web Processes.

* platform/network/cf/CookieStorageCFNet.cpp:
(WebCore::defaultSessionCookieStorage):
Keep track of the default storage session cookie storage.
(WebCore::currentCookieStorage):
Call defaultCookieStorage to get the default cookie storage.
(WebCore::defaultCookieStorage):
If there is a default storage session cookie storage, prefer that over getting the default
cookie storage. In the Web Process, asking CFNetwork for the default cookie storage directly
without specifying a storage session will not get the cookie storage being shared by the UI
and Web Processes.

* platform/network/ResourceHandle.h:
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::willSendRequest):
Make sure to set the current storage session on any requests used by the Web
Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
doing anything with the Web Process's default storage session (which is not the one shared
with the UI Process).
(WebCore::makeFinalRequest):
Ditto.
(WebCore::ResourceHandle::willSendRequest):
Ditto.
(WebCore::ResourceHandle::currentStorageSession):
If there is a Private Browsing storage session, return that.
If not, on Windows return the default storage session that is being shared with the UI
Process and on Mac return 0.
(WebCore::defaultCFURLStorageSession):
(WebCore::ResourceHandle::setDefaultStorageSession):
(WebCore::ResourceHandle::defaultStorageSession):

* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
Make sure to set the current storage session on any requests used by the Web
Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
doing anything with the Web Process's default storage session (which is not the one shared
with the UI Process).

Source/WebKit/win:

* WebView.cpp:
(WebView::setCacheModel):
Pass 0 to wkCopyFoundationCacheDirectory so that it uses the default session.

Source/WebKit2:

Share the default storage session between the UI and Web Processes.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
Add a parameter for a serialized default storage session, used only on Windows.

* Shared/win/WebCoreArgumentCodersWin.cpp:
(CoreIPC::decodeResourceRequest):
Make sure to set the current storage session on any requests used by the Web
Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
doing anything with the Web Process's default storage session.

* UIProcess/win/WebContextWin.cpp:
(WebKit::WebContext::platformInitializeWebProcess):
Serialize the default storage session in the UI Process and add it to the
WebProcessCreationParameters.

* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::cachedResponseForURL):
Use the cache associated with the current storage session and make sure the request has the
current storage session set on it before doing anything with it.

* WebProcess/win/WebProcessWin.cpp:
(WebKit::WebProcess::platformSetCacheModel):
Use the default storage session.
(WebKit::WebProcess::platformClearResourceCaches):
Ditto.
(WebKit::WebProcess::platformInitializeWebProcess):
Deserialize the default storage session passed in by the UI Process and hand it to the
ResourceHandle.

WebKitLibraries:

* win/include/WebKitSystemInterface/WebKitSystemInterface.h:
* win/lib/WebKitSystemInterface.lib:

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp
Source/WebKit2/UIProcess/win/WebContextWin.cpp
Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
Source/WebKit2/WebProcess/win/WebProcessWin.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib

index 28cf97436e81861dcbc96563d664cc8dc48160b2..930114fd8407997aaf5dacdb6c73c0d51a29d6bc 100644 (file)
@@ -1,3 +1,49 @@
+2011-05-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        Share the default storage session between the UI and Web Processes.
+
+        * platform/network/cf/CookieStorageCFNet.cpp:
+        (WebCore::defaultSessionCookieStorage):
+        Keep track of the default storage session cookie storage.
+        (WebCore::currentCookieStorage):
+        Call defaultCookieStorage to get the default cookie storage.
+        (WebCore::defaultCookieStorage):
+        If there is a default storage session cookie storage, prefer that over getting the default
+        cookie storage. In the Web Process, asking CFNetwork for the default cookie storage directly
+        without specifying a storage session will not get the cookie storage being shared by the UI
+        and Web Processes.
+
+        * platform/network/ResourceHandle.h:
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::willSendRequest):
+        Make sure to set the current storage session on any requests used by the Web
+        Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
+        doing anything with the Web Process's default storage session (which is not the one shared
+        with the UI Process).
+        (WebCore::makeFinalRequest):
+        Ditto.
+        (WebCore::ResourceHandle::willSendRequest):
+        Ditto.
+        (WebCore::ResourceHandle::currentStorageSession):
+        If there is a Private Browsing storage session, return that.
+        If not, on Windows return the default storage session that is being shared with the UI
+        Process and on Mac return 0.
+        (WebCore::defaultCFURLStorageSession):
+        (WebCore::ResourceHandle::setDefaultStorageSession):
+        (WebCore::ResourceHandle::defaultStorageSession):
+
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        Make sure to set the current storage session on any requests used by the Web
+        Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
+        doing anything with the Web Process's default storage session (which is not the one shared
+        with the UI Process).
+
 2011-05-07  Joe Mason  <jmason@rim.com>
 
         Reviewed by Daniel Bates.
index d82a9e4d759c2ea6382808d6bf0d8b183fdc17fc..6ca150948c82fae0da4a62981661ca4adcd7154d 100644 (file)
@@ -194,7 +194,12 @@ public:
     static void setPrivateBrowsingEnabled(bool);
     static CFURLStorageSessionRef privateBrowsingStorageSession();
     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
-#endif
+    static CFURLStorageSessionRef currentStorageSession();
+#if PLATFORM(WIN)
+    static void setDefaultStorageSession(CFURLStorageSessionRef);
+    static CFURLStorageSessionRef defaultStorageSession();
+#endif // PLATFORM(WIN)
+#endif // USE(CFURLSTORAGESESSIONS)
 
     using RefCounted<ResourceHandle>::ref;
     using RefCounted<ResourceHandle>::deref;
index 3aa52152164a89e761dd3413b542831723717862..f8d5ee3183c774515b560e20b93695af4cd66aaa 100644 (file)
@@ -62,13 +62,23 @@ RetainPtr<CFHTTPCookieStorageRef>& privateBrowsingCookieStorage()
 
 #if USE(CFNETWORK)
 
+static RetainPtr<CFHTTPCookieStorageRef>& defaultSessionCookieStorage()
+{
+    DEFINE_STATIC_LOCAL(RetainPtr<CFHTTPCookieStorageRef>, cookieStorage, ());
+#if USE(CFURLSTORAGESESSIONS) && PLATFORM(WIN)
+    if (!cookieStorage && ResourceHandle::defaultStorageSession())
+        cookieStorage.adoptCF(wkCopyHTTPCookieStorage(ResourceHandle::defaultStorageSession()));
+#endif
+    return cookieStorage;
+}
+
 CFHTTPCookieStorageRef currentCookieStorage()
 {
     ASSERT(isMainThread());
 
     if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get())
         return cookieStorage;
-    return wkGetDefaultHTTPCookieStorage();
+    return defaultCookieStorage();
 }
 
 void setCurrentCookieStorage(CFHTTPCookieStorageRef cookieStorage)
@@ -97,6 +107,8 @@ void setCookieStoragePrivateBrowsingEnabled(bool enabled)
 
 CFHTTPCookieStorageRef defaultCookieStorage()
 {
+    if (CFHTTPCookieStorageRef defaultCookieStorage = defaultSessionCookieStorage().get())
+        return defaultCookieStorage;
     return wkGetDefaultHTTPCookieStorage();
 }
 
index 4678dfe91a4ecba9620b20a5394424da1de92ebb..3f590d184e90ab567a3f675d57b41dc3e9364e1d 100644 (file)
@@ -148,6 +148,9 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfReque
             RetainPtr<CFStringRef> newMethod(AdoptCF, CFURLRequestCopyHTTPRequestMethod(cfRequest));
             if (CFStringCompareWithOptions(lastHTTPMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(lastHTTPMethod.get())), kCFCompareCaseInsensitive)) {
                 RetainPtr<CFMutableURLRequestRef> mutableRequest(AdoptCF, CFURLRequestCreateMutableCopy(0, cfRequest));
+#if USE(CFURLSTORAGESESSIONS)
+                wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), mutableRequest.get());
+#endif
                 CFURLRequestSetHTTPRequestMethod(mutableRequest.get(), lastHTTPMethod.get());
 
                 FormData* body = handle->firstRequest().httpBody();
@@ -340,10 +343,8 @@ CFArrayRef arrayFromFormData(const FormData& d)
 static CFURLRequestRef makeFinalRequest(const ResourceRequest& request, bool shouldContentSniff)
 {
     CFMutableURLRequestRef newRequest = CFURLRequestCreateMutableCopy(kCFAllocatorDefault, request.cfURLRequest());
-
 #if USE(CFURLSTORAGESESSIONS)
-    if (CFURLStorageSessionRef storageSession = ResourceHandle::privateBrowsingStorageSession())
-        wkSetRequestStorageSession(storageSession, newRequest);
+    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), newRequest);
 #endif
     
     if (!shouldContentSniff)
@@ -493,8 +494,7 @@ void ResourceHandle::willSendRequest(ResourceRequest& request, const ResourceRes
         request.clearHTTPAuthorization();
 
 #if USE(CFURLSTORAGESESSIONS)
-    if (CFURLStorageSessionRef storageSession = privateBrowsingStorageSession())
-        request.setStorageSession(storageSession);
+     request.setStorageSession(ResourceHandle::currentStorageSession());
 #endif
 
     client()->willSendRequest(this, request, redirectResponse);
@@ -744,7 +744,38 @@ String ResourceHandle::privateBrowsingStorageSessionIdentifierDefaultBase()
     return String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey)));
 }
 
+CFURLStorageSessionRef ResourceHandle::currentStorageSession()
+{
+    if (CFURLStorageSessionRef privateStorageSession = privateBrowsingStorageSession())
+        return privateStorageSession;
+#if PLATFORM(WIN)
+    return defaultStorageSession();
+#else
+    return 0;
 #endif
+}
+
+#if PLATFORM(WIN)
+
+static RetainPtr<CFURLStorageSessionRef>& defaultCFURLStorageSession()
+{
+    DEFINE_STATIC_LOCAL(RetainPtr<CFURLStorageSessionRef>, storageSession, ());
+    return storageSession;
+}
+
+void ResourceHandle::setDefaultStorageSession(CFURLStorageSessionRef storageSession)
+{
+    defaultCFURLStorageSession().adoptCF(storageSession);
+}
+
+CFURLStorageSessionRef ResourceHandle::defaultStorageSession()
+{
+    return defaultCFURLStorageSession().get();
+}
+
+#endif // PLATFORM(WIN)
+
+#endif // USE(CFURLSTORAGESESSIONS)
 
 void WebCoreSynchronousLoaderClient::willSendRequest(ResourceHandle* handle, ResourceRequest& request, const ResourceResponse& /*redirectResponse*/)
 {
index e90ab4fe0c95f3da3aec59c320e4af64d7ada4f7..374ab85c38fd8568e7790199c4a4266aa7901ade 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ResourceRequestCFNet.h"
 
+#include "ResourceHandle.h"
 #include "ResourceRequest.h"
 
 #if PLATFORM(MAC)
@@ -123,9 +124,11 @@ void ResourceRequest::doUpdatePlatformRequest()
         CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get());
         CFURLRequestSetCachePolicy(cfRequest, (CFURLRequestCachePolicy)cachePolicy());
         CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval());
-    } else {
+    } else
         cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get());
-    }
+#if USE(CFURLSTORAGESESSIONS)
+    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), cfRequest);
+#endif
 
     RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString());
     CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get());
index 9a2066b5600986c181c913ad874e2772623eda9d..2bbd86d959e64daf3ba7625cf712fdaede98f9c9 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        * WebView.cpp:
+        (WebView::setCacheModel):
+        Pass 0 to wkCopyFoundationCacheDirectory so that it uses the default session.
+
 2011-05-06  Adam Roben  <aroben@apple.com>
 
         Touch WebKit.idl to fix the build
index 89815f9b6699d58efbb83b46a62f36b7fc2e5f5f..41f1ef5a0a2fdb8e30030cc29ea7ce7159af3228 100644 (file)
@@ -452,7 +452,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
         return;
 
     RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
-    RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory());
+    RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory(0));
     if (!cfurlCacheDirectory)
         cfurlCacheDirectory.adoptCF(WebCore::localUserSpecificStorageDirectory().createCFString());
 
index 41e1bd4e6d5c6ca84a952d0e3cbf04fa29c885db..bbc95dc95f2fa7d07ac0baaf820731962b1775b1 100644 (file)
@@ -1,3 +1,43 @@
+2011-05-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        Share the default storage session between the UI and Web Processes.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        Add a parameter for a serialized default storage session, used only on Windows.
+
+        * Shared/win/WebCoreArgumentCodersWin.cpp:
+        (CoreIPC::decodeResourceRequest):
+        Make sure to set the current storage session on any requests used by the Web
+        Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
+        doing anything with the Web Process's default storage session.
+
+        * UIProcess/win/WebContextWin.cpp:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        Serialize the default storage session in the UI Process and add it to the
+        WebProcessCreationParameters.
+
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::cachedResponseForURL):
+        Use the cache associated with the current storage session and make sure the request has the
+        current storage session set on it before doing anything with it.
+
+        * WebProcess/win/WebProcessWin.cpp:
+        (WebKit::WebProcess::platformSetCacheModel):
+        Use the default storage session.
+        (WebKit::WebProcess::platformClearResourceCaches):
+        Ditto.
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        Deserialize the default storage session passed in by the UI Process and hand it to the
+        ResourceHandle.
+
 2011-05-07  Keith Kyzivat  <keith.kyzivat@nokia.com>
 
         Reviewed by Adam Roben.
index f29ef1ae04e1129287343a7fda6fc84b9745fb9f..fd350b68730fab0bec19efc949e68ecbd84dbd9b 100644 (file)
@@ -27,6 +27,9 @@
 #include "WebProcessCreationParameters.h"
 
 #include "ArgumentCoders.h"
+#if USE(CFURLSTORAGESESSIONS) && PLATFORM(WIN)
+#include "ArgumentCodersCF.h"
+#endif
 
 namespace WebKit {
 
@@ -79,6 +82,9 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(cfURLCacheDiskCapacity);
     encoder->encode(cfURLCacheMemoryCapacity);
     encoder->encode(initialHTTPCookieAcceptPolicy);
+#if USE(CFURLSTORAGESESSIONS)
+    CoreIPC::encode(encoder, serializedDefaultStorageSession.get());
+#endif // USE(CFURLSTORAGESESSIONS)
 #endif
 }
 
@@ -149,6 +155,10 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
     if (!decoder->decode(parameters.initialHTTPCookieAcceptPolicy))
         return false;
+#if USE(CFURLSTORAGESESSIONS)
+    if (!CoreIPC::decode(decoder, parameters.serializedDefaultStorageSession))
+        return false;
+#endif // USE(CFURLSTORAGESESSIONS)
 #endif
 
     return true;
index 62ceaf9ce0763be9744b447795d4d9cae686bb66..e00ca55690b12add3ea85e8a0ea3932282854c2a 100644 (file)
@@ -29,6 +29,7 @@
 #include "CacheModel.h"
 #include "SandboxExtension.h"
 #include "TextCheckerState.h"
+#include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -103,7 +104,11 @@ struct WebProcessCreationParameters {
     uint32_t initialHTTPCookieAcceptPolicy;
 
     bool shouldPaintNativeControls;
-#endif
+
+#if USE(CFURLSTORAGESESSIONS)
+    RetainPtr<CFDataRef> serializedDefaultStorageSession;
+#endif // USE(CFURLSTORAGESESSIONS)
+#endif // PLATFORM(WIN)
 };
 
 } // namespace WebKit
index d659ac45c80f6a8a8e0bb4dbe25aa88e031d2dce..2d9defd27f5bab869ae4620ebc78b28e0c3e390b 100644 (file)
@@ -29,7 +29,9 @@
 #if USE(CFNETWORK)
 #include "ArgumentCodersCF.h"
 #include "PlatformCertificateInfo.h"
+#include <CFNetwork/CFURLRequestPriv.h>
 #include <WebCore/CertificateCFWin.h>
+#include <WebCore/ResourceHandle.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #endif
 
@@ -70,8 +72,13 @@ bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& r
     CFURLRequestRef cfURLRequest = wkCFURLRequestCreateFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
     if (!cfURLRequest)
         return false;
+    CFMutableURLRequestRef mutableCFURLRequest = CFURLRequestCreateMutableCopy(0, cfURLRequest);
+    CFRelease(cfURLRequest);
+#if USE(CFURLSTORAGESESSIONS)
+    wkSetRequestStorageSession(WebCore::ResourceHandle::currentStorageSession(), mutableCFURLRequest);
+#endif
 
-    resourceRequest = WebCore::ResourceRequest(cfURLRequest);
+    resourceRequest = WebCore::ResourceRequest(mutableCFURLRequest);
     return true;
 #else
     return false;
index c1c2a00e78783d481648eb4bffa994631b3d0338..9964de06c72840e48cadddb2f031f968b5a4cba3 100644 (file)
@@ -60,7 +60,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     parameters.cfURLCacheDiskCapacity = CFURLCacheDiskCapacity(cfurlCache.get());
     parameters.cfURLCacheMemoryCapacity = CFURLCacheMemoryCapacity(cfurlCache.get());
 
-    RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory());
+    RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory(0));
     parameters.cfURLCachePath = String(cfURLCachePath.get());
     // Remove the ending '\' (necessary to have CFNetwork find the Cache file).
     ASSERT(parameters.cfURLCachePath.length());
@@ -69,6 +69,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
 
 #if USE(CFURLSTORAGESESSIONS)
     parameters.uiProcessBundleIdentifier = String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey)));
+    parameters.serializedDefaultStorageSession.adoptCF(wkCopySerializedDefaultStorageSession());
 #endif // USE(CFURLSTORAGESESSIONS)
 
     parameters.initialHTTPCookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
index 49238d910cd8ebbece06d77f5a268d20238654e2..dd86f00d468b2fcc208f88361f0ce32ba95c2aa1 100644 (file)
@@ -268,14 +268,17 @@ static RetainPtr<CFCachedURLResponseRef> cachedResponseForURL(WebPage* webPage,
 {
     RetainPtr<CFURLRef> cfURL(AdoptCF, url.createCFURL());
     RetainPtr<CFMutableURLRequestRef> request(AdoptCF, CFURLRequestCreateMutable(0, cfURL.get(), kCFURLRequestCachePolicyReloadIgnoringCache, 60, 0));
+#if USE(CFURLSTORAGESESSIONS)
+    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), request.get());
+#endif
 
     RetainPtr<CFStringRef> userAgent(AdoptCF, webPage->userAgent().createCFString());
     CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), userAgent.get());
 
     RetainPtr<CFURLCacheRef> cache;
 #if USE(CFURLSTORAGESESSIONS)
-    if (CFURLStorageSessionRef storageSession = ResourceHandle::privateBrowsingStorageSession())
-        cache.adoptCF(wkCopyURLCache(storageSession));
+    if (CFURLStorageSessionRef currentStorageSession = ResourceHandle::currentStorageSession())
+        cache.adoptCF(wkCopyURLCache(currentStorageSession));
     else
 #endif
         cache.adoptCF(CFURLCacheCopySharedURLCache());
index d9a4af547363bcfb73cf635d1643f6f2fdfd0c39..b9c36667c947f295630398723ba9009fc750c4f6 100644 (file)
@@ -32,6 +32,7 @@
 #include <WebCore/FileSystem.h>
 #include <WebCore/MemoryCache.h>
 #include <WebCore/PageCache.h>
+#include <WebCore/ResourceHandle.h>
 #include <WebCore/Settings.h>
 #include <wtf/text/WTFString.h>
 
@@ -69,7 +70,14 @@ static uint64_t volumeFreeSize(CFStringRef cfstringPath)
 void WebProcess::platformSetCacheModel(CacheModel cacheModel)
 {
 #if USE(CFNETWORK)
-    RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory());
+    RetainPtr<CFStringRef> cfurlCacheDirectory;
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession())
+        cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(defaultStorageSession));
+    else
+#endif
+        cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(0));
+
     if (!cfurlCacheDirectory)
         cfurlCacheDirectory.adoptCF(WebCore::localUserSpecificStorageDirectory().createCFString());
 
@@ -94,7 +102,14 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
     memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
     pageCache()->setCapacity(pageCacheCapacity);
 
-    RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
+    RetainPtr<CFURLCacheRef> cfurlCache;
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession())
+        cfurlCache.adoptCF(wkCopyURLCache(defaultStorageSession));
+    else
+#endif // USE(CFURLSTORAGESESSIONS)
+        cfurlCache.adoptCF(CFURLCacheCopySharedURLCache());
+
     CFURLCacheSetMemoryCapacity(cfurlCache.get(), urlCacheMemoryCapacity);
     CFURLCacheSetDiskCapacity(cfurlCache.get(), max<unsigned long>(urlCacheDiskCapacity, CFURLCacheDiskCapacity(cfurlCache.get()))); // Don't shrink a big disk cache, since that would cause churn.
 #endif
@@ -105,8 +120,17 @@ void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear
 #if USE(CFNETWORK)
     if (cachesToClear == InMemoryResourceCachesOnly)
         return;
-    CFURLCacheRemoveAllCachedResponses(RetainPtr<CFURLCacheRef>(AdoptCF, CFURLCacheCopySharedURLCache()).get());
-#endif
+
+    RetainPtr<CFURLCacheRef> cache;
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession())
+        cache.adoptCF(wkCopyURLCache(defaultStorageSession));
+    else
+#endif // USE(CFURLSTORAGESESSIONS)
+        cache.adoptCF(CFURLCacheCopySharedURLCache());
+
+    CFURLCacheRemoveAllCachedResponses(cache.get());
+#endif // USE(CFNETWORK)
 }
 
 void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::ArgumentDecoder*)
@@ -114,6 +138,13 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     setShouldPaintNativeControls(parameters.shouldPaintNativeControls);
 
 #if USE(CFNETWORK)
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = wkDeserializeStorageSession(parameters.serializedDefaultStorageSession.get())) {
+        ResourceHandle::setDefaultStorageSession(defaultStorageSession);
+        return;
+    }
+#endif // USE(CFURLSTORAGESESSIONS)
+
     RetainPtr<CFStringRef> cachePath(AdoptCF, parameters.cfURLCachePath.createCFString());
     if (!cachePath)
         return;
@@ -122,7 +153,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     CFIndex cacheMemoryCapacity = parameters.cfURLCacheMemoryCapacity;
     RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, cachePath.get()));
     CFURLCacheSetSharedURLCache(uiProcessCache.get());
-#endif
+#endif // USE(CFNETWORK)
 
     WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.initialHTTPCookieAcceptPolicy);
 }
index d184b529bd32ddf8744737c6186f4e166e2425d6..8a225b452100ace6f0a0a547b476fad8d86bfd3e 100644 (file)
@@ -1,3 +1,13 @@
+2011-05-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
+        * win/lib/WebKitSystemInterface.lib:
+
 2011-05-05  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Simon Fraser.
index b2cda98a73e8d4f4bf4a82645b713fb795d442a1..6cf90d8237041bfa5b9ea53c0d4b0fac26b0513e 100644 (file)
@@ -93,7 +93,7 @@ void* wkGetSSLCertificateChainContext(CFDictionaryRef);
 CFHTTPCookieStorageRef wkGetDefaultHTTPCookieStorage();
 CFHTTPCookieStorageRef wkCreateInMemoryHTTPCookieStorage();
 void wkSetCFURLRequestShouldContentSniff(CFMutableURLRequestRef, bool);
-CFStringRef wkCopyFoundationCacheDirectory();
+CFStringRef wkCopyFoundationCacheDirectory(CFURLStorageSessionRef);
 void wkSetClientCertificateInSSLProperties(CFMutableDictionaryRef, CFDataRef);
 
 CFArrayRef wkCFURLRequestCopyHTTPRequestBodyParts(CFURLRequestRef);
@@ -103,6 +103,8 @@ CFURLStorageSessionRef wkCreatePrivateStorageSession(CFStringRef identifier);
 void wkSetRequestStorageSession(CFURLStorageSessionRef, CFMutableURLRequestRef);
 CFURLCacheRef wkCopyURLCache(CFURLStorageSessionRef);
 CFHTTPCookieStorageRef wkCopyHTTPCookieStorage(CFURLStorageSessionRef);
+CFDataRef wkCopySerializedDefaultStorageSession();
+CFURLStorageSessionRef wkDeserializeStorageSession(CFDataRef);
 
 CFArrayRef wkCFURLCacheCopyAllHostNamesInPersistentStore();
 void wkCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostNames);
index a33fb2ec0f3ac6a5cc1eab4a21dea2b3f69ac9c2..364d0d1f03ac1d2636c330fcdb1d7591cde08ce1 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ