WebCore:
authoradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Oct 2007 17:04:38 +0000 (17:04 +0000)
committeradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Oct 2007 17:04:38 +0000 (17:04 +0000)
        <rdar://problem/5534421>
        Switched to using wkGetDefaultHTTPCookieStorage() and removed some cookie-related
        methods we no longer need in ResourceHandle.

        <rdar://problem/5244261> "Never" cookie policy was ignored on windows
        Need to set the cookie accept policy on each CFURLRequest.

WebKit/win:
        <rdar://problem/5534421>
        Switched to using wkGetDefaultHTTPCookieStorage() to avoid recreating CFHTTPCookieStorageRef.
        Removed usage of ResourceHandle::cookieStorage().

        Reviewed by Oliver.

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

WebCore/ChangeLog
WebCore/platform/network/ResourceHandle.h
WebCore/platform/network/cf/ResourceHandleCFNet.cpp
WebCore/platform/network/cf/ResourceRequestCFNet.cpp
WebCore/platform/network/win/CookieJarWin.cpp
WebKit/win/ChangeLog
WebKit/win/WebView.cpp

index cf7231467c515cb95dd56680456f457d425a4d56..8810afdfb3c6c19d853dde7a873a479f8ba792b9 100644 (file)
@@ -1,3 +1,24 @@
+2007-10-11  Ada Chan  <adachan@apple.com>
+
+        <rdar://problem/5534421> 
+        Switched to using wkGetDefaultHTTPCookieStorage() and removed some cookie-related
+        methods we no longer need in ResourceHandle.
+        
+        <rdar://problem/5244261> "Never" cookie policy was ignored on windows
+        Need to set the cookie accept policy on each CFURLRequest.
+        
+        Reviewed by Oliver.
+
+        * platform/network/ResourceHandle.h:
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::makeFinalRequest):
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        * platform/network/win/CookieJarWin.cpp:
+        (WebCore::setCookies):
+        (WebCore::cookies):
+        (WebCore::cookiesEnabled):
+
 2007-10-11  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Tim Hatcher.
index a58a7de39b5c8d95a2e7c0816bba1821d8cae22e..012e5f5a5e035a3341279999a7c72a28f30d743d 100644 (file)
@@ -113,12 +113,6 @@ public:
     CFURLConnectionRef connection() const;
     CFURLConnectionRef releaseConnectionForDownload();
 
-    static CFHTTPCookieStorageAcceptPolicy cookieStorageAcceptPolicy();
-    static void setCookieStorageAcceptPolicy(CFHTTPCookieStorageAcceptPolicy);
-
-    static CFHTTPCookieStorageRef cookieStorage();
-    static void setCookieStorage(CFHTTPCookieStorageRef);
-
     static void setHostAllowsAnyHTTPSCertificate(const String&);
 #endif
     PassRefPtr<SharedBuffer> bufferedData();
index 23d1812856efc4a1cf23fb5f481cfaee26b04919..ae9a51f6aabd6eb0ea2ee8e5dcf5f499a0316ce4 100644 (file)
 #include <process.h> // for _beginthread()
 
 #include <CFNetwork/CFNetwork.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 
 namespace WebCore {
 
-static CFHTTPCookieStorageAcceptPolicy defaultAcceptPolicy = CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain;
-static CFHTTPCookieStorageRef defaultStorage;
-
 static HashSet<String>& allowsAnyHTTPSCertificateHosts()
 {
     static HashSet<String> hosts;
@@ -234,10 +232,8 @@ static CFURLRequestRef makeFinalRequest(const ResourceRequest& request)
         CFURLRequestSetSSLProperties(newRequest, sslProps);
     }
 
-#ifdef CFNETWORK_HAS_NEW_COOKIE_FUNCTIONS
-    CFURLRequestSetHTTPCookieStorage(newRequest, defaultStorage);
-    CFURLRequestSetHTTPCookieStorageAcceptPolicy(newRequest, defaultAcceptPolicy);
-#endif
+    if (CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage())
+        CFURLRequestSetHTTPCookieStorageAcceptPolicy(newRequest, CFHTTPCookieStorageGetCookieAcceptPolicy(defaultCookieStorage));
 
     return newRequest;
 }
@@ -374,34 +370,6 @@ void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, R
     }
 }
 
-CFHTTPCookieStorageAcceptPolicy ResourceHandle::cookieStorageAcceptPolicy()
-{
-    return defaultAcceptPolicy;
-}
-
-void ResourceHandle::setCookieStorageAcceptPolicy(CFHTTPCookieStorageAcceptPolicy acceptPolicy)
-{
-    defaultAcceptPolicy = acceptPolicy;
-    if (defaultStorage)
-        CFHTTPCookieStorageSetCookieAcceptPolicy(defaultStorage, defaultAcceptPolicy);
-}
-
-CFHTTPCookieStorageRef ResourceHandle::cookieStorage()
-{
-    return defaultStorage;
-}
-
-void ResourceHandle::setCookieStorage(CFHTTPCookieStorageRef storage)
-{
-    if (storage)
-        CFRetain(storage);
-    if (defaultStorage)
-        CFRelease(defaultStorage);
-    defaultStorage = storage;
-    if (defaultStorage)
-        CFHTTPCookieStorageSetCookieAcceptPolicy(defaultStorage, defaultAcceptPolicy);
-}
-
 void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
 {
     allowsAnyHTTPSCertificateHosts().add(host.lower());
index 44d3c435081a9b95415837b370eda1a42bbe3399..9651eba22d82fbbc09fd394ab91536bb458eaf24 100644 (file)
@@ -70,11 +70,7 @@ void ResourceRequest::doUpdatePlatformRequest()
     CFURLRequestSetShouldHandleHTTPCookies(cfRequest, allowHTTPCookies());
 
     if (m_cfRequest) {
-#ifdef CFNETWORK_HAS_NEW_COOKIE_FUNCTIONS
-        RetainPtr<CFHTTPCookieStorageRef> cookieStorage(AdoptCF, CFURLRequestCopyHTTPCookieStorage(m_cfRequest.get()));
-        CFURLRequestSetHTTPCookieStorage(cfRequest, cookieStorage.get());
         CFURLRequestSetHTTPCookieStorageAcceptPolicy(cfRequest, CFURLRequestGetHTTPCookieStorageAcceptPolicy(m_cfRequest.get()));
-#endif
         CFURLRequestSetSSLProperties(cfRequest, CFURLRequestGetSSLProperties(m_cfRequest.get()));
     }
 
index d741c5c4b3a625739c0a0853c1d91f2ca945c482..6634207706040b478b7fc792271e4c964df22bb1 100644 (file)
@@ -32,6 +32,7 @@
 #if USE(CFNETWORK)
 #include <CoreFoundation/CoreFoundation.h>
 #include <CFNetwork/CFHTTPCookiesPriv.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #else
 #include <Wininet.h>
 #endif
@@ -48,7 +49,8 @@ namespace WebCore
 void setCookies(const KURL& url, const KURL& policyURL, const String& value)
 {
 #if USE(CFNETWORK)
-    if (!ResourceHandle::cookieStorage())
+    CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage();
+    if (!defaultCookieStorage)
         return;
 
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
@@ -65,7 +67,7 @@ void setCookies(const KURL& url, const KURL& policyURL, const String& value)
     RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault,
         headerFieldsCF.get(), urlCF.get()));
 
-    CFHTTPCookieStorageSetCookies(ResourceHandle::cookieStorage(), cookiesCF.get(), urlCF.get(), policyURLCF.get());
+    CFHTTPCookieStorageSetCookies(defaultCookieStorage, cookiesCF.get(), urlCF.get(), policyURLCF.get());
 #else
     // FIXME: Deal with the policy URL.
     DeprecatedString str = url.url();
@@ -79,7 +81,8 @@ void setCookies(const KURL& url, const KURL& policyURL, const String& value)
 String cookies(const KURL& url)
 {
 #if USE(CFNETWORK)
-    if (!ResourceHandle::cookieStorage())
+    CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage();
+    if (!defaultCookieStorage)
         return String();
 
     String cookieString;
@@ -87,7 +90,7 @@ String cookies(const KURL& url)
 
     bool secure = equalIgnoringCase(url.protocol(), "https");
 
-    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(ResourceHandle::cookieStorage(), urlCF.get(), secure));
+    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(defaultCookieStorage, urlCF.get(), secure));
     RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get()));
 
     return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
@@ -110,8 +113,10 @@ String cookies(const KURL& url)
 
 bool cookiesEnabled()
 {
-    return ResourceHandle::cookieStorageAcceptPolicy() == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain ||
-        ResourceHandle::cookieStorageAcceptPolicy() == CFHTTPCookieStorageAcceptPolicyAlways;
+    CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain;
+    if (CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage())
+        policy = CFHTTPCookieStorageGetCookieAcceptPolicy(defaultCookieStorage);
+    return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways;
 }
 
 }
index d6e9533a4e9225a321720418fecf291b6ad84b0c..4a92886f6ec45c52ce6c8b6181f703b11b8264ba 100644 (file)
@@ -1,3 +1,15 @@
+2007-10-11  Ada Chan  <adachan@apple.com>
+
+        <rdar://problem/5534421>
+        Switched to using wkGetDefaultHTTPCookieStorage() to avoid recreating CFHTTPCookieStorageRef.
+        Removed usage of ResourceHandle::cookieStorage().
+
+        Reviewed by Oliver.
+
+        * WebView.cpp:
+        (WebView::updateWebCoreSettingsFromPreferences):
+        (WebView::initWithFrame):
+
 2007-10-10  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Geoff Garen.
index 46daddb8212b29e39a2cbc4679670a78e8f6eea6..8758705502a4dd1779cb1162235d3e2c52fb4478 100644 (file)
@@ -48,7 +48,6 @@
 #include "WebPreferences.h"
 #pragma warning( push, 0 )
 #include <CoreGraphics/CGContext.h>
-#include <CFNetwork/CFHTTPCookiesPriv.h>
 #include <WebCore/BString.h>
 #include <WebCore/Cache.h>
 #include <WebCore/CommandByName.h>
@@ -92,6 +91,7 @@
 #include <JavaScriptCore/collector.h>
 #include <JavaScriptCore/value.h>
 #include <CFNetwork/CFURLProtocolPriv.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <tchar.h>
 #include <dimm.h>
 #include <windowsx.h>
@@ -1561,7 +1561,9 @@ HRESULT WebView::updateWebCoreSettingsFromPreferences(IWebPreferences* preferenc
         return hr;
     settings->setDOMPasteAllowed(!!enabled);
 
-    ResourceHandle::setCookieStorageAcceptPolicy(acceptPolicy);
+    // set cookie storage accept policy
+    if (CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage())
+        CFHTTPCookieStorageSetCookieAcceptPolicy(defaultCookieStorage, acceptPolicy);
 
     settings->setShowsURLsInToolTips(false);
 
@@ -1843,10 +1845,6 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
     if (FAILED(hr))
         return hr;
 
-    // Use default cookie storage
-    RetainPtr<CFHTTPCookieStorageRef> cookies(AdoptCF, CFHTTPCookieStorageCreateFromFile(kCFAllocatorDefault, 0, 0));
-    ResourceHandle::setCookieStorage(cookies.get());
-
     // Register to receive notifications whenever preference values change.
     //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
     //                                             name:WebPreferencesChangedNotification object:[self preferences]];