Title: [221276] trunk/Source
Revision
221276
Author
[email protected]
Date
2017-08-28 15:23:08 -0700 (Mon, 28 Aug 2017)

Log Message

[Cocoa] Upstream CFNetwork-related WebKitSystemInterface functions
https://bugs.webkit.org/show_bug.cgi?id=176032

Reviewed by Alex Christensen.

Source/WebCore:

* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::switchToNewTestingSession):
(WebCore::NetworkStorageSession::ensureSession):
* platform/network/cf/ResourceRequest.h:
* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::createPrivateStorageSession):
* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::ResourceRequest::setStorageSession):
(WebCore::copyRequestWithStorageSession):
(WebCore::cachedResponseForRequest):
* platform/network/mac/CookieJarMac.mm:
(WebCore::httpCookies):
(WebCore::setHTTPCookiesForURL):
(WebCore::deleteHTTPCookie):
(WebCore::deleteAllHTTPCookies):
(WebCore::setCookiesFromDOM):
(WebCore::httpCookieAcceptPolicy):
(WebCore::cookiesEnabled):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):
(WebCore::deleteAllCookies):
(WebCore::deleteCookiesForHostnames):
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::createNSURLConnection):

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::privateBrowsingSession):
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformHasLocalDataForURL):
(WebKit::cachedResponseForURL):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
* WebView/WebView.mm:
(-[WebView _cachedResponseForURL:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221275 => 221276)


--- trunk/Source/WebCore/ChangeLog	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/ChangeLog	2017-08-28 22:23:08 UTC (rev 221276)
@@ -1,3 +1,39 @@
+2017-08-28  Andy Estes  <[email protected]>
+
+        [Cocoa] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176032
+
+        Reviewed by Alex Christensen.
+
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        * platform/network/NetworkStorageSession.h:
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+        (WebCore::NetworkStorageSession::switchToNewTestingSession):
+        (WebCore::NetworkStorageSession::ensureSession):
+        * platform/network/cf/ResourceRequest.h:
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::createPrivateStorageSession):
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::ResourceRequest::setStorageSession):
+        (WebCore::copyRequestWithStorageSession):
+        (WebCore::cachedResponseForRequest):
+        * platform/network/mac/CookieJarMac.mm:
+        (WebCore::httpCookies):
+        (WebCore::setHTTPCookiesForURL):
+        (WebCore::deleteHTTPCookie):
+        (WebCore::deleteAllHTTPCookies):
+        (WebCore::setCookiesFromDOM):
+        (WebCore::httpCookieAcceptPolicy):
+        (WebCore::cookiesEnabled):
+        (WebCore::deleteCookie):
+        (WebCore::getHostnamesWithCookies):
+        (WebCore::deleteAllCookies):
+        (WebCore::deleteCookiesForHostnames):
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::createNSURLConnection):
+
 2017-08-28  Brent Fulgham  <[email protected]>
 
         Disable access to secure cookies if an HTTPS site loads mixed content (Part 2: Header Requests)

Modified: trunk/Source/WebCore/PAL/ChangeLog (221275 => 221276)


--- trunk/Source/WebCore/PAL/ChangeLog	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/PAL/ChangeLog	2017-08-28 22:23:08 UTC (rev 221276)
@@ -1,3 +1,12 @@
+2017-08-28  Andy Estes  <[email protected]>
+
+        [Cocoa] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176032
+
+        Reviewed by Alex Christensen.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+
 2017-08-25  Eric Carlson  <[email protected]>
 
         Add Logger::logAlways

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (221275 => 221276)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2017-08-28 22:23:08 UTC (rev 221276)
@@ -115,6 +115,8 @@
 
 @interface NSHTTPCookie ()
 - (CFHTTPCookieRef)_CFHTTPCookie;
++ (CFArrayRef __nullable)_ns2cfCookies:(NSArray * __nullable)nsCookies CF_RETURNS_RETAINED;
+- (CFHTTPCookieRef __nullable)_GetInternalCFHTTPCookie;
 @end
 
 @interface NSURLSessionConfiguration ()
@@ -171,6 +173,7 @@
 void CFURLCacheSetMemoryCapacity(CFURLCacheRef, CFIndex memoryCapacity);
 CFIndex CFURLCacheMemoryCapacity(CFURLCacheRef);
 void CFURLCacheSetDiskCapacity(CFURLCacheRef, CFIndex);
+CFCachedURLResponseRef CFURLCacheCopyResponseForRequest(CFURLCacheRef, CFURLRequestRef);
 
 #if PLATFORM(COCOA)
 Boolean _CFNetworkIsKnownHSTSHostWithSession(CFURLRef, CFURLStorageSessionRef);
@@ -192,6 +195,7 @@
 extern const CFStringRef kCFHTTPVersion1_1;
 extern const CFStringRef kCFURLRequestAllowAllPOSTCaching;
 extern const CFStringRef _kCFURLConnectionPropertyShouldSniff;
+extern const CFStringRef _kCFURLStorageSessionIsPrivate;
 
 CFHTTPCookieStorageRef _CFHTTPCookieStorageGetDefault(CFAllocatorRef);
 CFHTTPCookieStorageRef CFHTTPCookieStorageCreateFromFile(CFAllocatorRef, CFURLRef, CFHTTPCookieStorageRef);
@@ -228,6 +232,10 @@
 CFURLResponseRef CFURLResponseCreate(CFAllocatorRef, CFURLRef, CFStringRef mimeType, SInt64 expectedContentLength, CFStringRef textEncodingName, CFURLCacheStoragePolicy);
 void CFURLResponseSetExpectedContentLength(CFURLResponseRef, SInt64 length);
 CFURLResponseRef CFURLResponseCreateWithHTTPResponse(CFAllocatorRef, CFURLRef, CFHTTPMessageRef, CFURLCacheStoragePolicy);
+CFArrayRef CFHTTPCookieStorageCopyCookies(CFHTTPCookieStorageRef);
+void CFHTTPCookieStorageSetCookies(CFHTTPCookieStorageRef, CFArrayRef cookies, CFURLRef, CFURLRef mainDocumentURL);
+void CFHTTPCookieStorageDeleteCookie(CFHTTPCookieStorageRef, CFHTTPCookieRef);
+CFMutableURLRequestRef CFURLRequestCreateMutableCopy(CFAllocatorRef, CFURLRequestRef);
 
 #endif // !PLATFORM(WIN)
 

Modified: trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm (221275 => 221276)


--- trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -39,14 +39,6 @@
 WEBCORE_EXPORT void (*wkSetLayerContentsScale)(CALayer *);
 WEBCORE_EXPORT CFStringEncoding (*wkGetWebDefaultCFStringEncoding)(void);
 
-WEBCORE_EXPORT CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef);
-WEBCORE_EXPORT NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*);
-WEBCORE_EXPORT unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef);
-WEBCORE_EXPORT NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
-WEBCORE_EXPORT void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
-WEBCORE_EXPORT void (*wkDeleteAllHTTPCookies)(CFHTTPCookieStorageRef);
-WEBCORE_EXPORT void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
-
 WEBCORE_EXPORT void(*wkDestroyRenderingResources)(void);
 
 WEBCORE_EXPORT bool (*wkCaptionAppearanceHasUserPreferences)(void);

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (221275 => 221276)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2017-08-28 22:23:08 UTC (rev 221276)
@@ -214,16 +214,7 @@
 #endif
 
 typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
-extern CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef);
-extern NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*);
 
-typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
-extern unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef);
-extern NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
-extern void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
-extern void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
-extern void (*wkDeleteAllHTTPCookies)(CFHTTPCookieStorageRef);
-
 #if !PLATFORM(IOS)
 extern void (*wkSetMetadataURL)(NSString *urlString, NSString *referrer, NSString *path);
 extern CGFloat (*wkNSElasticDeltaForTimeDelta)(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (221275 => 221276)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -93,14 +93,6 @@
 BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length);
 AXUIElementRef (*wkCreateAXUIElementRef)(id element);
 
-CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef);
-NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*);
-unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef);
-NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
-void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
-void (*wkDeleteAllHTTPCookies)(CFHTTPCookieStorageRef);
-void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
-
 void (*wkSetMetadataURL)(NSString *urlString, NSString *referrer, NSString *path);
 
 #if !PLATFORM(IOS)

Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (221275 => 221276)


--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h	2017-08-28 22:23:08 UTC (rev 221276)
@@ -153,4 +153,8 @@
 #endif
 };
 
+#if PLATFORM(COCOA)
+WEBCORE_EXPORT CFURLStorageSessionRef createPrivateStorageSession(CFStringRef identifier);
+#endif
+
 }

Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (221275 => 221276)


--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp	2017-08-28 22:23:08 UTC (rev 221276)
@@ -90,7 +90,7 @@
 
     RetainPtr<CFURLStorageSessionRef> session;
 #if PLATFORM(COCOA)
-    session = adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get()));
+    session = adoptCF(createPrivateStorageSession(sessionName.createCFString().get()));
 #else
     session = adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultStorageSession().platformSession()));
 #endif
@@ -126,7 +126,7 @@
     RetainPtr<CFURLStorageSessionRef> storageSession;
     if (sessionID.isEphemeral()) {
 #if PLATFORM(COCOA)
-        storageSession = adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get()));
+        storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get()));
 #else
         storageSession = adoptCF(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultNetworkStorageSession()->platformSession()));
 #endif

Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequest.h (221275 => 221276)


--- trunk/Source/WebCore/platform/network/cf/ResourceRequest.h	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequest.h	2017-08-28 22:23:08 UTC (rev 221276)
@@ -29,6 +29,7 @@
 #include "ResourceRequestBase.h"
 #include <wtf/RetainPtr.h>
 
+OBJC_CLASS NSCachedURLResponse;
 OBJC_CLASS NSURLRequest;
 
 #if PLATFORM(COCOA) || USE(CFURLCONNECTION)
@@ -135,4 +136,9 @@
 #endif
 }
 
+#if PLATFORM(COCOA)
+NSURLRequest *copyRequestWithStorageSession(CFURLStorageSessionRef, NSURLRequest *);
+WEBCORE_EXPORT NSCachedURLResponse *cachedResponseForRequest(CFURLStorageSessionRef, NSURLRequest *);
+#endif
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (221275 => 221276)


--- trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -99,4 +99,38 @@
     return *m_cookieStorageObserver;
 }
 
+CFURLStorageSessionRef createPrivateStorageSession(CFStringRef identifier)
+{
+    const void* sessionPropertyKeys[] = { _kCFURLStorageSessionIsPrivate };
+    const void* sessionPropertyValues[] = { kCFBooleanTrue };
+    auto sessionProperties = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, sessionPropertyKeys, sessionPropertyValues, sizeof(sessionPropertyKeys) / sizeof(*sessionPropertyKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    auto storageSession = adoptCF(_CFURLStorageSessionCreate(kCFAllocatorDefault, identifier, sessionProperties.get()));
+
+    if (!storageSession)
+        return nullptr;
+
+    // The private storage session should have the same properties as the default storage session,
+    // with the exception that it should be in-memory only storage.
+
+    // FIXME 9199649: If any of the storages do not exist, do no use the storage session.
+    // This could occur if there is an issue figuring out where to place a storage on disk (e.g. the
+    // sandbox does not allow CFNetwork access).
+
+    auto cache = adoptCF(_CFURLStorageSessionCopyCache(kCFAllocatorDefault, storageSession.get()));
+    if (!cache)
+        return nullptr;
+
+    CFURLCacheSetDiskCapacity(cache.get(), 0); // Setting disk cache size should not be necessary once <rdar://problem/12656814> is fixed.
+    CFURLCacheSetMemoryCapacity(cache.get(), [[NSURLCache sharedURLCache] memoryCapacity]);
+
+    auto cookieStorage = adoptCF(_CFURLStorageSessionCopyCookieStorage(kCFAllocatorDefault, storageSession.get()));
+    if (!cookieStorage)
+        return nullptr;
+
+    // FIXME: Use _CFHTTPCookieStorageGetDefault when USE(CFNETWORK) is defined in WebKit for consistency.
+    CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy]);
+
+    return storageSession.leakRef();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm (221275 => 221276)


--- trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -260,11 +260,34 @@
 void ResourceRequest::setStorageSession(CFURLStorageSessionRef storageSession)
 {
     updatePlatformRequest();
-    m_nsRequest = adoptNS(wkCopyRequestWithStorageSession(storageSession, m_nsRequest.get()));
+    m_nsRequest = adoptNS(copyRequestWithStorageSession(storageSession, m_nsRequest.get()));
 }
 
 #endif // USE(CFURLCONNECTION)
 
+NSURLRequest *copyRequestWithStorageSession(CFURLStorageSessionRef storageSession, NSURLRequest *request)
+{
+    if (!storageSession || !request)
+        return [request copy];
+
+    auto cfRequest = adoptCF(CFURLRequestCreateMutableCopy(kCFAllocatorDefault, [request _CFURLRequest]));
+    _CFURLRequestSetStorageSession(cfRequest.get(), storageSession);
+    return [[NSURLRequest alloc] _initWithCFURLRequest:cfRequest.get()];
+}
+
+NSCachedURLResponse *cachedResponseForRequest(CFURLStorageSessionRef storageSession, NSURLRequest *request)
+{
+    if (!storageSession)
+        return [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
+
+    auto cache = adoptCF(_CFURLStorageSessionCopyCache(kCFAllocatorDefault, storageSession));
+    auto cachedResponse = adoptCF(CFURLCacheCopyResponseForRequest(cache.get(), [request _CFURLRequest]));
+    if (!cachedResponse)
+        return nil;
+
+    return [[[NSCachedURLResponse alloc] _initWithCFCachedURLResponse:cachedResponse.get()] autorelease];
+}
+
 } // namespace WebCore
 
 #endif // PLATFORM(COCOA)

Modified: trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm (221275 => 221276)


--- trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -40,6 +40,10 @@
 #import <wtf/Optional.h>
 #import <wtf/text/StringBuilder.h>
 
+@interface NSURL ()
+- (CFURLRef)_cfurl;
+@end
+
 namespace WebCore {
 
 static NSArray *httpCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSURL *firstParty, NSURL *url)
@@ -169,6 +173,52 @@
     return { String(), false };
 }
 
+static NSArray *httpCookies(CFHTTPCookieStorageRef cookieStorage)
+{
+    if (!cookieStorage)
+        return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
+
+    auto cookies = adoptCF(CFHTTPCookieStorageCopyCookies(cookieStorage));
+    return [NSHTTPCookie _cf2nsCookies:cookies.get()];
+}
+
+static void setHTTPCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSArray *cookies, NSURL *url, NSURL *mainDocumentURL)
+{
+    if (!cookieStorage) {
+        [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL];
+        return;
+    }
+
+    auto cfCookies = adoptCF([NSHTTPCookie _ns2cfCookies:cookies]);
+    CFHTTPCookieStorageSetCookies(cookieStorage, cfCookies.get(), [url _cfurl], [mainDocumentURL _cfurl]);
+}
+
+static void deleteHTTPCookie(CFHTTPCookieStorageRef cookieStorage, NSHTTPCookie *cookie)
+{
+    if (!cookieStorage) {
+        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
+        return;
+    }
+
+    CFHTTPCookieStorageDeleteCookie(cookieStorage, [cookie _GetInternalCFHTTPCookie]);
+}
+
+static void deleteAllHTTPCookies(CFHTTPCookieStorageRef cookieStorage)
+{
+    if (!cookieStorage) {
+        NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
+        NSArray *cookies = [cookieStorage cookies];
+        if (!cookies)
+            return;
+
+        for (NSHTTPCookie *cookie in cookies)
+            [cookieStorage deleteCookie:cookie];
+        return;
+    }
+
+    CFHTTPCookieStorageDeleteAllCookies(cookieStorage);
+}
+
 std::pair<String, bool> cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const URL& url, IncludeSecureCookies includeSecureCookies)
 {
     return cookiesForSession(session, firstParty, url, DoNotIncludeHTTPOnly, includeSecureCookies);
@@ -210,16 +260,24 @@
         filteredCookies = applyPartitionToCookies(partition, filteredCookies.get());
 #endif
 
-    wkSetHTTPCookiesForURL(session.cookieStorage().get(), filteredCookies.get(), cookieURL, firstParty);
+    setHTTPCookiesForURL(session.cookieStorage().get(), filteredCookies.get(), cookieURL, firstParty);
 
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
+static NSHTTPCookieAcceptPolicy httpCookieAcceptPolicy(CFHTTPCookieStorageRef cookieStorage)
+{
+    if (!cookieStorage)
+        return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
+
+    return static_cast<NSHTTPCookieAcceptPolicy>(CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage));
+}
+
 bool cookiesEnabled(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& /*url*/)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(session.cookieStorage().get()));
+    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = httpCookieAcceptPolicy(session.cookieStorage().get());
     return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
 
     END_BLOCK_OBJC_EXCEPTIONS;
@@ -256,7 +314,7 @@
     for (NSUInteger i = 0; i < count; ++i) {
         NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i];
         if ([[cookie name] isEqualToString:cookieNameString])
-            wkDeleteHTTPCookie(cookieStorage.get(), cookie);
+            deleteHTTPCookie(cookieStorage.get(), cookie);
     }
 
     END_BLOCK_OBJC_EXCEPTIONS;
@@ -266,7 +324,7 @@
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    NSArray *cookies = wkHTTPCookies(session.cookieStorage().get());
+    NSArray *cookies = httpCookies(session.cookieStorage().get());
     
     for (NSHTTPCookie* cookie in cookies)
         hostnames.add([cookie domain]);
@@ -276,7 +334,7 @@
 
 void deleteAllCookies(const NetworkStorageSession& session)
 {
-    wkDeleteAllHTTPCookies(session.cookieStorage().get());
+    deleteAllHTTPCookies(session.cookieStorage().get());
 }
 
 }
@@ -290,7 +348,7 @@
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
-    NSArray *cookies = wkHTTPCookies(cookieStorage.get());
+    NSArray *cookies = httpCookies(cookieStorage.get());
     if (!cookies)
         return;
 
@@ -306,7 +364,7 @@
             continue;
 
         for (auto& cookie : it->value)
-            wkDeleteHTTPCookie(cookieStorage.get(), cookie.get());
+            deleteHTTPCookie(cookieStorage.get(), cookie.get());
     }
 
     [session.nsCookieStorage() _saveCookies];

Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (221275 => 221276)


--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -177,7 +177,7 @@
 #endif
 
     if (d->m_storageSession)
-        nsRequest = [wkCopyRequestWithStorageSession(d->m_storageSession.get(), nsRequest) autorelease];
+        nsRequest = [copyRequestWithStorageSession(d->m_storageSession.get(), nsRequest) autorelease];
 
     ASSERT([NSURLConnection instancesRespondToSelector:@selector(_initWithRequest:delegate:usesCache:maxContentLength:startImmediately:connectionProperties:)]);
 

Modified: trunk/Source/WebKit/ChangeLog (221275 => 221276)


--- trunk/Source/WebKit/ChangeLog	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKit/ChangeLog	2017-08-28 22:23:08 UTC (rev 221276)
@@ -1,3 +1,18 @@
+2017-08-28  Andy Estes  <[email protected]>
+
+        [Cocoa] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176032
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::privateBrowsingSession):
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformHasLocalDataForURL):
+        (WebKit::cachedResponseForURL):
+
 2017-08-28  Brent Fulgham  <[email protected]>
 
         Disable access to secure cookies if an HTTPS site loads mixed content (Part 2: Header Requests)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (221275 => 221276)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -44,6 +44,7 @@
 #import "WindowServerConnection.h"
 #import <WebCore/Color.h>
 #import <WebCore/FileSystem.h>
+#import <WebCore/NetworkStorageSession.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/PlatformPasteboard.h>
 #import <WebCore/RuntimeApplicationChecks.h>
@@ -576,7 +577,7 @@
     dispatch_once(&once, ^{
         NSString *identifier = [NSString stringWithFormat:@"%@.PrivateBrowsing", [[NSBundle mainBundle] bundleIdentifier]];
 
-        session = WKCreatePrivateStorageSession((CFStringRef)identifier);
+        session = createPrivateStorageSession((CFStringRef)identifier);
     });
 
     return session;

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (221275 => 221276)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -75,13 +75,6 @@
 #if !PLATFORM(IOS)
         INIT(SetDragImage);
 #endif
-        INIT(CreatePrivateStorageSession);
-        INIT(CopyRequestWithStorageSession);
-        INIT(GetHTTPCookieAcceptPolicy);
-        INIT(HTTPCookies);
-        INIT(SetHTTPCookiesForURL);
-        INIT(DeleteAllHTTPCookies);
-        INIT(DeleteHTTPCookie);
 
 #if !PLATFORM(IOS)
         INIT(SetMetadataURL);

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (221275 => 221276)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -684,7 +684,7 @@
     [request setValue:(NSString*)userAgent(url) forHTTPHeaderField:@"User-Agent"];
     NSCachedURLResponse *cachedResponse;
     if (CFURLStorageSessionRef storageSession = corePage()->mainFrame().loader().networkingContext()->storageSession().platformSession())
-        cachedResponse = WKCachedResponseForRequest(storageSession, request);
+        cachedResponse = cachedResponseForRequest(storageSession, request);
     else
         cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
     [request release];
@@ -698,7 +698,7 @@
     [request setValue:(NSString *)webPage->userAgent(url) forHTTPHeaderField:@"User-Agent"];
 
     if (CFURLStorageSessionRef storageSession = webPage->corePage()->mainFrame().loader().networkingContext()->storageSession().platformSession())
-        return WKCachedResponseForRequest(storageSession, request.get());
+        return cachedResponseForRequest(storageSession, request.get());
 
     return [[NSURLCache sharedURLCache] cachedResponseForRequest:request.get()];
 }

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (221275 => 221276)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-08-28 22:23:08 UTC (rev 221276)
@@ -1,3 +1,15 @@
+2017-08-28  Andy Estes  <[email protected]>
+
+        [Cocoa] Upstream CFNetwork-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176032
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+        * WebView/WebView.mm:
+        (-[WebView _cachedResponseForURL:]):
+
 2017-08-28  Brent Fulgham  <[email protected]>
 
         Disable access to secure cookies if an HTTPS site loads mixed content (Part 2: Header Requests)

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm (221275 => 221276)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -105,13 +105,6 @@
     INIT(CreateAXUIElementRef);
     INIT(UnregisterUniqueIdForElement);
 #endif
-    INIT(CreatePrivateStorageSession);
-    INIT(CopyRequestWithStorageSession);
-    INIT(GetHTTPCookieAcceptPolicy);
-    INIT(HTTPCookies);
-    INIT(SetHTTPCookiesForURL);
-    INIT(DeleteAllHTTPCookies);
-    INIT(DeleteHTTPCookie);
 
 #if !PLATFORM(IOS)
     INIT(SetMetadataURL);

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (221275 => 221276)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-08-28 22:08:34 UTC (rev 221275)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-08-28 22:23:08 UTC (rev 221276)
@@ -3555,7 +3555,7 @@
         return nil;
 
     if (CFURLStorageSessionRef storageSession = _private->page->mainFrame().loader().networkingContext()->storageSession().platformSession())
-        cachedResponse = WKCachedResponseForRequest(storageSession, request.get());
+        cachedResponse = cachedResponseForRequest(storageSession, request.get());
     else
         cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request.get()];
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to