<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197518] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197518">197518</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2016-03-03 13:46:07 -0800 (Thu, 03 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Adopt CFNetwork storage partitioning SPI
https://bugs.webkit.org/show_bug.cgi?id=154957
rdar://problem/23614620
Reviewed by Darin Adler.
Source/WebCore:
Adopt CFNetwork SPI for creating storage partitions. If Settings::cookieStoragePartitioningEnabled() is true,
create cookie storage partitions for third-party contexts. This feature is disabled by default.
No new tests. Test support is tracked by <https://webkit.org/b/154958>.
* page/Settings.cpp:
(WebCore::Settings::setCookieStoragePartitioningEnabled): Controls whether storage partitioning for cookies is enabled.
* page/Settings.h:
(WebCore::Settings::cookieStoragePartitioningEnabled):
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::cookieStoragePartition): Computes a storage partition identifier by determining the top
privately-controlled domain of the cookie's first-party (main frame document) URL, then determining whether the
cookie's document hostname is a subdomain of it. If is is not, the first-party top domain is the partition name.
Otherwise, there is no partition name.
* platform/network/mac/CookieJarMac.mm:
(WebCore::applyPartitionToCookies): Returns a deep copy of the given cookie array after adding a storage
partition property to each copied cookie.
(WebCore::cookiesInPartitionForURL): Returns cookies for the partition computed by the given URLs. If no
partition can be determined, nil is returned.
(WebCore::cookiesForURL): Returns cookiesInPartitionForURL() if non-nil, otherwise returns wkHTTPCookiesForURL().
(WebCore::cookiesForSession): Started calling cookiesForURL().
(WebCore::setCookiesFromDOM): Called applyPartitionToCookies() if a partition can be computed from the given URLs.
(WebCore::getRawCookies): Started calling cookiesForURL().
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::createNSURLConnection): Computed the storage partition identifier for the new request.
If non-empty, set it as a property on the NSURLRequest where CFNetwork knows to find it.
* platform/spi/cf/CFNetworkSPI.h: Declare new SPI for building with the public SDK.
Source/WebKit2:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTask::NetworkDataTask): Computed the storage partition identifier for the new session task.
If non-empty, set it using a NSURLSessionTask SPI.
Source/WTF:
* wtf/Platform.h: Defined HAVE_CFNETWORK_STORAGE_PARTITIONING.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsh">trunk/Source/WebCore/page/Settings.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkNetworkStorageSessionh">trunk/Source/WebCore/platform/network/NetworkStorageSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcfNetworkStorageSessionCFNetcpp">trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkmacCookieJarMacmm">trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkmacResourceHandleMacmm">trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformspicfCFNetworkSPIh">trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscocoaNetworkDataTaskCocoamm">trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WTF/ChangeLog        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-03-03 Andy Estes <aestes@apple.com>
+
+ Adopt CFNetwork storage partitioning SPI
+ https://bugs.webkit.org/show_bug.cgi?id=154957
+ rdar://problem/23614620
+
+ Reviewed by Darin Adler.
+
+ * wtf/Platform.h: Defined HAVE_CFNETWORK_STORAGE_PARTITIONING.
+
</ins><span class="cx"> 2016-03-02 Konstantin Tokarev <annulen@yandex.ru>
</span><span class="cx">
</span><span class="cx"> [cmake] Moved PRE/POST_BUILD_COMMAND to WEBKIT_FRAMEWORK.
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WTF/wtf/Platform.h        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -665,6 +665,10 @@
</span><span class="cx"> #define HAVE_VIRTUALALLOC 1
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
+#define HAVE_CFNETWORK_STORAGE_PARTITIONING 1
+#endif
+
</ins><span class="cx"> /* ENABLE macro defaults */
</span><span class="cx">
</span><span class="cx"> /* FIXME: move out all ENABLE() defines from here to FeatureDefines.h */
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/ChangeLog        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-03-03 Andy Estes <aestes@apple.com>
+
+ Adopt CFNetwork storage partitioning SPI
+ https://bugs.webkit.org/show_bug.cgi?id=154957
+ rdar://problem/23614620
+
+ Reviewed by Darin Adler.
+
+ Adopt CFNetwork SPI for creating storage partitions. If Settings::cookieStoragePartitioningEnabled() is true,
+ create cookie storage partitions for third-party contexts. This feature is disabled by default.
+
+ No new tests. Test support is tracked by <https://webkit.org/b/154958>.
+
+ * page/Settings.cpp:
+ (WebCore::Settings::setCookieStoragePartitioningEnabled): Controls whether storage partitioning for cookies is enabled.
+ * page/Settings.h:
+ (WebCore::Settings::cookieStoragePartitioningEnabled):
+ * platform/network/NetworkStorageSession.h:
+ * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+ (WebCore::cookieStoragePartition): Computes a storage partition identifier by determining the top
+ privately-controlled domain of the cookie's first-party (main frame document) URL, then determining whether the
+ cookie's document hostname is a subdomain of it. If is is not, the first-party top domain is the partition name.
+ Otherwise, there is no partition name.
+ * platform/network/mac/CookieJarMac.mm:
+ (WebCore::applyPartitionToCookies): Returns a deep copy of the given cookie array after adding a storage
+ partition property to each copied cookie.
+ (WebCore::cookiesInPartitionForURL): Returns cookies for the partition computed by the given URLs. If no
+ partition can be determined, nil is returned.
+ (WebCore::cookiesForURL): Returns cookiesInPartitionForURL() if non-nil, otherwise returns wkHTTPCookiesForURL().
+ (WebCore::cookiesForSession): Started calling cookiesForURL().
+ (WebCore::setCookiesFromDOM): Called applyPartitionToCookies() if a partition can be computed from the given URLs.
+ (WebCore::getRawCookies): Started calling cookiesForURL().
+ * platform/network/mac/ResourceHandleMac.mm:
+ (WebCore::ResourceHandle::createNSURLConnection): Computed the storage partition identifier for the new request.
+ If non-empty, set it as a property on the NSURLRequest where CFNetwork knows to find it.
+ * platform/spi/cf/CFNetworkSPI.h: Declare new SPI for building with the public SDK.
+
</ins><span class="cx"> 2016-03-03 Manuel Rego Casasnovas <rego@igalia.com>
</span><span class="cx">
</span><span class="cx"> [css-grid] Fix order of grid shorthands in CSSPropertyNames.in
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/page/Settings.cpp        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -82,6 +82,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> bool Settings::gQTKitEnabled = false;
</span><ins>+bool Settings::gCookieStoragePartitioningEnabled = false;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool Settings::gMockScrollbarsEnabled = false;
</span><span class="lines">@@ -598,6 +599,11 @@
</span><span class="cx"> gQTKitEnabled = enabled;
</span><span class="cx"> HTMLMediaElement::resetMediaEngines();
</span><span class="cx"> }
</span><ins>+
+void Settings::setCookieStoragePartitioningEnabled(bool enabled)
+{
+ gCookieStoragePartitioningEnabled = enabled;
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.h (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.h        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/page/Settings.h        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -198,6 +198,9 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> WEBCORE_EXPORT static void setQTKitEnabled(bool flag);
</span><span class="cx"> static bool isQTKitEnabled() { return gQTKitEnabled; }
</span><ins>+
+ WEBCORE_EXPORT static void setCookieStoragePartitioningEnabled(bool flag);
+ static bool cookieStoragePartitioningEnabled() { return gCookieStoragePartitioningEnabled; }
</ins><span class="cx"> #else
</span><span class="cx"> static bool isQTKitEnabled() { return false; }
</span><span class="cx"> #endif
</span><span class="lines">@@ -352,6 +355,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> WEBCORE_EXPORT static bool gQTKitEnabled;
</span><ins>+ static bool gCookieStoragePartitioningEnabled;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> static bool gMockScrollbarsEnabled;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkNetworkStorageSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class NetworkingContext;
</span><ins>+class ResourceRequest;
</ins><span class="cx"> class SoupNetworkSession;
</span><span class="cx">
</span><span class="cx"> class NetworkStorageSession {
</span><span class="lines">@@ -79,6 +80,9 @@
</span><span class="cx"> CredentialStorage m_credentialStorage;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+WEBCORE_EXPORT String cookieStoragePartition(const ResourceRequest&);
+String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource);
+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif // NetworkStorageSession_h
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcfNetworkStorageSessionCFNetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -31,6 +31,9 @@
</span><span class="cx"> #include <wtf/ProcessID.h>
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+#include "PublicSuffix.h"
+#include "ResourceRequest.h"
+#include "Settings.h"
</ins><span class="cx"> #include "WebCoreSystemInterface.h"
</span><span class="cx"> #else
</span><span class="cx"> #include <WebKitSystemInterface/WebKitSystemInterface.h>
</span><span class="lines">@@ -94,4 +97,36 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if PLATFORM(COCOA)
+
+String cookieStoragePartition(const ResourceRequest& request)
+{
+ return cookieStoragePartition(request.firstPartyForCookies(), request.url());
</ins><span class="cx"> }
</span><ins>+
+static inline bool hostIsInDomain(StringView host, StringView domain)
+{
+ if (!host.endsWithIgnoringASCIICase(domain))
+ return false;
+
+ ASSERT(host.length() >= domain.length());
+ unsigned suffixOffset = host.length() - domain.length();
+ return suffixOffset == 0 || host[suffixOffset - 1] == '.';
+}
+
+String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource)
+{
+ if (!Settings::cookieStoragePartitioningEnabled())
+ return emptyString();
+
+ String firstPartyDomain = firstPartyForCookies.host();
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+ firstPartyDomain = topPrivatelyControlledDomain(firstPartyDomain);
+#endif
+
+ return hostIsInDomain(resource.host(), firstPartyDomain) ? emptyString() : firstPartyDomain;
+}
+
+#endif
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkmacCookieJarMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import "Cookie.h"
</span><span class="cx"> #import "CookieStorage.h"
</span><span class="cx"> #import "URL.h"
</span><ins>+#import <wtf/Optional.h>
</ins><span class="cx"> #import <wtf/text/StringBuilder.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -64,12 +65,64 @@
</span><span class="cx"> return filteredCookies;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+
+static NSArray *applyPartitionToCookies(NSString *partition, NSArray *cookies)
+{
+ // FIXME 24747739: CFNetwork should expose this key as SPI
+ static NSString * const partitionKey = @"StoragePartition";
+
+ NSMutableArray *partitionedCookies = [NSMutableArray arrayWithCapacity:cookies.count];
+ for (NSHTTPCookie *cookie in cookies) {
+ RetainPtr<NSMutableDictionary> properties = adoptNS([cookie.properties mutableCopy]);
+ [properties setObject:partition forKey:partitionKey];
+ [partitionedCookies addObject:[NSHTTPCookie cookieWithProperties:properties.get()]];
+ }
+
+ return partitionedCookies;
+}
+
+static NSArray *cookiesInPartitionForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+ String partition = cookieStoragePartition(firstParty, url);
+ if (partition.isEmpty())
+ return nil;
+
+ // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar.
+ // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us.
+ RetainPtr<NSHTTPCookieStorage> cookieStorage;
+ if (auto storage = session.cookieStorage())
+ cookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:storage.get()]);
+ else
+ cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
+
+ // The _getCookiesForURL: method calls the completionHandler synchronously.
+ Optional<RetainPtr<NSArray *>> cookiesPtr;
+ [cookieStorage _getCookiesForURL:url mainDocumentURL:firstParty partition:partition completionHandler:[&cookiesPtr](NSArray *cookies) {
+ cookiesPtr = retainPtr(cookies);
+ }];
+ ASSERT(!!cookiesPtr);
+
+ return cookiesPtr->autorelease();
+}
+
+#endif // HAVE(CFNETWORK_STORAGE_PARTITIONING)
+
+static NSArray *cookiesForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url)
+{
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ if (NSArray *cookies = cookiesInPartitionForURL(session, firstParty, url))
+ return cookies;
+#endif
+ return wkHTTPCookiesForURL(session.cookieStorage().get(), firstParty, url);
+}
+
</ins><span class="cx"> enum IncludeHTTPOnlyOrNot { DoNotIncludeHTTPOnly, IncludeHTTPOnly };
</span><span class="cx"> static String cookiesForSession(const NetworkStorageSession& session, const URL& firstParty, const URL& url, IncludeHTTPOnlyOrNot includeHTTPOnly)
</span><span class="cx"> {
</span><span class="cx"> BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx">
</span><del>- NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), firstParty, url);
</del><ins>+ NSArray *cookies = cookiesForURL(session, firstParty, url);
</ins><span class="cx"> if (![cookies count])
</span><span class="cx"> return String(); // Return a null string, not an empty one that StringBuilder would create below.
</span><span class="cx">
</span><span class="lines">@@ -129,6 +182,12 @@
</span><span class="cx"> RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies);
</span><span class="cx"> ASSERT([filteredCookies.get() count] <= 1);
</span><span class="cx">
</span><ins>+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ String partition = cookieStoragePartition(firstParty, url);
+ if (!partition.isEmpty())
+ filteredCookies = applyPartitionToCookies(partition, filteredCookies.get());
+#endif
+
</ins><span class="cx"> wkSetHTTPCookiesForURL(session.cookieStorage().get(), filteredCookies.get(), cookieURL, firstParty);
</span><span class="cx">
</span><span class="cx"> END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="lines">@@ -150,7 +209,7 @@
</span><span class="cx"> rawCookies.clear();
</span><span class="cx"> BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx">
</span><del>- NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), firstParty, url);
</del><ins>+ NSArray *cookies = cookiesForURL(session, firstParty, url);
</ins><span class="cx"> NSUInteger count = [cookies count];
</span><span class="cx"> rawCookies.reserveCapacity(count);
</span><span class="cx"> for (NSUInteger i = 0; i < count; ++i) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkmacResourceHandleMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #import "Logging.h"
</span><span class="cx"> #import "MIMETypeRegistry.h"
</span><span class="cx"> #import "NSURLConnectionSPI.h"
</span><ins>+#import "NetworkStorageSession.h"
</ins><span class="cx"> #import "NetworkingContext.h"
</span><span class="cx"> #import "Page.h"
</span><span class="cx"> #import "ResourceError.h"
</span><span class="lines">@@ -172,6 +173,15 @@
</span><span class="cx"> nsRequest = mutableRequest;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ String storagePartition = cookieStoragePartition(firstRequest());
+ if (!storagePartition.isEmpty()) {
+ NSMutableURLRequest *mutableRequest = [[nsRequest mutableCopy] autorelease];
+ [mutableRequest _setProperty:storagePartition forKey:@"__STORAGE_PARTITION_IDENTIFIER"];
+ nsRequest = mutableRequest;
+ }
+#endif
+
</ins><span class="cx"> if (d->m_storageSession)
</span><span class="cx"> nsRequest = [wkCopyRequestWithStorageSession(d->m_storageSession.get(), nsRequest) autorelease];
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformspicfCFNetworkSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> #include <CFNetwork/CFURLResponsePriv.h>
</span><span class="cx"> #include <CFNetwork/CFURLStorageSession.h>
</span><span class="cx">
</span><del>-// FIXME: Remove the defined(__OBJC__)-guard onnce we fix <rdar://problem/19033610>.
</del><ins>+// FIXME: Remove the defined(__OBJC__)-guard once we fix <rdar://problem/19033610>.
</ins><span class="cx"> #if defined(__OBJC__) && PLATFORM(COCOA)
</span><span class="cx"> // FIXME: As a workaround for <rdar://problem/18337182>, we conditionally enclose the header
</span><span class="cx"> // in an extern "C" linkage block to make it suitable for C++ use.
</span><span class="lines">@@ -103,8 +103,22 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000)
+@interface NSHTTPCookie ()
+@property (nullable, readonly, copy) NSString *_storagePartition;
+@end
+
+@interface NSHTTPCookieStorage ()
+- (void)_getCookiesForURL:(NSURL *)url mainDocumentURL:(NSURL *)mainDocumentURL partition:(NSString *)partition completionHandler:(void (^)(NSArray *))completionHandler;
+@end
+
+@interface NSURLSessionTask ()
+@property (copy) NSString *_storagePartitionIdentifier;
+@end
</ins><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#endif // defined(__OBJC__)
+
</ins><span class="cx"> #endif // PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
</span><span class="cx">
</span><span class="cx"> EXTERN_C void CFURLRequestSetShouldStartSynchronously(CFURLRequestRef, Boolean);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-03-03 Andy Estes <aestes@apple.com>
+
+ Adopt CFNetwork storage partitioning SPI
+ https://bugs.webkit.org/show_bug.cgi?id=154957
+ rdar://problem/23614620
+
+ Reviewed by Darin Adler.
+
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+ (WebKit::NetworkDataTask::NetworkDataTask): Computed the storage partition identifier for the new session task.
+ If non-empty, set it using a NSURLSessionTask SPI.
+
</ins><span class="cx"> 2016-03-03 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> [WK2] testRunner.setPrivateBrowsingEnabled doesn't work with NetworkProcess
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscocoaNetworkDataTaskCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (197517 => 197518)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm        2016-03-03 21:43:47 UTC (rev 197517)
+++ trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm        2016-03-03 21:46:07 UTC (rev 197518)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #import "WebCoreArgumentCoders.h"
</span><span class="cx"> #import <WebCore/AuthenticationChallenge.h>
</span><span class="cx"> #import <WebCore/CFNetworkSPI.h>
</span><ins>+#import <WebCore/NetworkStorageSession.h>
</ins><span class="cx"> #import <WebCore/ResourceRequest.h>
</span><span class="cx"> #import <wtf/MainThread.h>
</span><span class="cx">
</span><span class="lines">@@ -85,6 +86,12 @@
</span><span class="cx"> ASSERT(!m_session.m_dataTaskMapWithoutCredentials.contains([m_task taskIdentifier]));
</span><span class="cx"> m_session.m_dataTaskMapWithoutCredentials.add([m_task taskIdentifier], this);
</span><span class="cx"> }
</span><ins>+
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ String storagePartition = WebCore::cookieStoragePartition(request);
+ if (!storagePartition.isEmpty())
+ m_task.get()._storagePartitionIdentifier = storagePartition;
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NetworkDataTask::~NetworkDataTask()
</span></span></pre>
</div>
</div>
</body>
</html>