<!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>[213877] trunk</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/213877">213877</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2017-03-13 16:00:49 -0700 (Mon, 13 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>WKWebView provides no access to cookies.
https://bugs.webkit.org/show_bug.cgi?id=140191
Reviewed by Tim Horton.
Source/WebCore:
Covered by API tests.
* platform/Cookie.h:
* platform/network/NetworkStorageSession.h:
* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::NetworkStorageSession::setCookie):
(WebCore::NetworkStorageSession::deleteCookie):
(WebCore::nsCookiesToCookieVector):
(WebCore::NetworkStorageSession::getAllCookies):
(WebCore::NetworkStorageSession::getCookies):
* platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::NetworkStorageSession::deleteCookie):
(WebCore::NetworkStorageSession::getAllCookies):
(WebCore::NetworkStorageSession::getCookies):
Source/WebKit2:
This adds a new WKHTTPCookieManager SPI.
It follows the NSHTTPCookieStorage API but asynchronous (with completion handlers).
* CMakeLists.txt:
* WebKit2.xcodeproj/project.pbxproj:
* Shared/API/APIObject.h:
* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* UIProcess/API/APIHTTPCookieStorage.cpp: Added.
(API::HTTPCookieStorage::HTTPCookieStorage):
(API::HTTPCookieStorage::~HTTPCookieStorage):
(API::HTTPCookieStorage::cookies):
(API::HTTPCookieStorage::setCookie):
(API::HTTPCookieStorage::setCookies):
(API::HTTPCookieStorage::deleteCookie):
(API::HTTPCookieStorage::removeCookiesSinceDate):
(API::HTTPCookieStorage::setHTTPCookieAcceptPolicy):
(API::HTTPCookieStorage::getHTTPCookieAcceptPolicy):
* UIProcess/API/APIHTTPCookieStorage.h: Added.
* UIProcess/API/APIWebsiteDataStore.cpp:
(API::WebsiteDataStore::defaultDataStore):
(API::WebsiteDataStore::httpCookieStorage):
* UIProcess/API/APIWebsiteDataStore.h:
* UIProcess/API/C/WKCookieManager.cpp:
(WKCookieManagerDeleteAllCookiesModifiedAfterDate):
(WKCookieManagerSetHTTPCookieAcceptPolicy):
(WKCookieManagerGetHTTPCookieAcceptPolicy):
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreGetDefaultDataStore):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _setCookieAcceptPolicy:]):
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore defaultDataStore]):
(-[WKWebsiteDataStore _httpCookieStorage]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/API/Cocoa/WKHTTPCookieStorage.h:
* UIProcess/API/Cocoa/WKHTTPCookieStorage.mm: Added.
(coreCookiesToNSCookies):
(-[WKHTTPCookieStorage dealloc]):
(-[WKHTTPCookieStorage fetchCookies:]):
(-[WKHTTPCookieStorage fetchCookiesForURL:completionHandler:]):
(-[WKHTTPCookieStorage setCookie:completionHandler:]):
(-[WKHTTPCookieStorage deleteCookie:completionHandler:]):
(-[WKHTTPCookieStorage setCookies:forURL:mainDocumentURL:completionHandler:]):
(-[WKHTTPCookieStorage removeCookiesSinceDate:completionHandler:]):
(-[WKHTTPCookieStorage setCookieAcceptPolicy:completionHandler:]):
(kitCookiePolicyToNSCookiePolicy):
(-[WKHTTPCookieStorage fetchCookieAcceptPolicy:]):
(-[WKHTTPCookieStorage _apiObject]):
* UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h.
(WebKit::wrapper):
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::addSingleCookie):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::getHostnamesWithCookies):
(WebKit::WebCookieManagerProxy::deleteCookiesForHostname):
(WebKit::WebCookieManagerProxy::deleteAllCookies):
(WebKit::WebCookieManagerProxy::deleteCookie):
(WebKit::WebCookieManagerProxy::deleteAllCookiesModifiedSince):
(WebKit::WebCookieManagerProxy::setCookie):
(WebKit::WebCookieManagerProxy::setCookies):
(WebKit::WebCookieManagerProxy::getAllCookies):
(WebKit::WebCookieManagerProxy::getCookies):
(WebKit::WebCookieManagerProxy::didSetCookies):
(WebKit::WebCookieManagerProxy::didGetCookies):
(WebKit::WebCookieManagerProxy::didDeleteCookies):
(WebKit::WebCookieManagerProxy::startObservingCookieChanges):
(WebKit::WebCookieManagerProxy::stopObservingCookieChanges):
(WebKit::WebCookieManagerProxy::setCookieObserverCallback):
(WebKit::WebCookieManagerProxy::cookiesDidChange):
(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
(WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
(WebKit::WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy):
(WebKit::WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy):
* UIProcess/WebCookieManagerProxy.h:
* UIProcess/WebCookieManagerProxy.messages.in:
* UIProcess/WebFrameProxy.h:
* UIProcess/WebProcessPool.cpp:
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::processPoolForCookieStorageOperations):
(WebKit::WebsiteDataStore::processPools):
* UIProcess/WebsiteData/WebsiteDataStore.h:
* WebProcess/Cookies/WebCookieManager.cpp:
(WebKit::WebCookieManager::deleteCookie):
(WebKit::WebCookieManager::deleteAllCookiesModifiedSince):
(WebKit::WebCookieManager::getAllCookies):
(WebKit::WebCookieManager::getCookies):
(WebKit::WebCookieManager::setCookie):
(WebKit::WebCookieManager::setCookies):
(WebKit::WebCookieManager::setHTTPCookieAcceptPolicy):
* WebProcess/Cookies/WebCookieManager.h:
* WebProcess/Cookies/WebCookieManager.messages.in:
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformCookieh">trunk/Source/WebCore/platform/Cookie.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkNetworkStorageSessionh">trunk/Source/WebCore/platform/network/NetworkStorageSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcocoaNetworkStorageSessionCocoamm">trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworksoupNetworkStorageSessionSoupcpp">trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp</a></li>
<li><a href="#trunkSourceWebKit2CMakeListstxt">trunk/Source/WebKit2/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesssoupNetworkProcessSoupcpp">trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIAPIObjecth">trunk/Source/WebKit2/Shared/API/APIObject.h</a></li>
<li><a href="#trunkSourceWebKit2SharedCocoaAPIObjectmm">trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIWebsiteDataStorecpp">trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIWebsiteDataStoreh">trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKCookieManagercpp">trunk/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKWebsiteDataStoreRefcpp">trunk/Source/WebKit2/UIProcess/API/C/WKWebsiteDataStoreRef.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKProcessPoolmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataStoremm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataStorePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitCookieManagercpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebCookieManagerProxycpp">trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebCookieManagerProxyh">trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebCookieManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebFrameProxyh">trunk/Source/WebKit2/UIProcess/WebFrameProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolcpp">trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolh">trunk/Source/WebKit2/UIProcess/WebProcessPool.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessCookiesWebCookieManagercpp">trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessCookiesWebCookieManagerh">trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessCookiesWebCookieManagermessagesin">trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStoragecpp">trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStorageh">trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKHTTPCookieStorageh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKHTTPCookieStoragemm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKHTTPCookieStorageInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaWKHTTPCookieStoragemm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKHTTPCookieStorage.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebCore/ChangeLog        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2017-03-13 Brady Eidson <beidson@apple.com>
+
+ WKWebView provides no access to cookies.
+ https://bugs.webkit.org/show_bug.cgi?id=140191
+
+ Reviewed by Tim Horton.
+
+ Covered by API tests.
+
+ * platform/Cookie.h:
+
+ * platform/network/NetworkStorageSession.h:
+ * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+ (WebCore::NetworkStorageSession::setCookie):
+ (WebCore::NetworkStorageSession::deleteCookie):
+ (WebCore::nsCookiesToCookieVector):
+ (WebCore::NetworkStorageSession::getAllCookies):
+ (WebCore::NetworkStorageSession::getCookies):
+
+ * platform/network/soup/NetworkStorageSessionSoup.cpp:
+ (WebCore::NetworkStorageSession::deleteCookie):
+ (WebCore::NetworkStorageSession::getAllCookies):
+ (WebCore::NetworkStorageSession::getCookies):
+
</ins><span class="cx"> 2017-03-13 Devin Rousso <webkit@devinrousso.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Event Listeners section is missing 'once', 'passive' event listener flags
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformCookieh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Cookie.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Cookie.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebCore/platform/Cookie.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">
</span><span class="cx"> #ifdef __OBJC__
</span><span class="cx"> WEBCORE_EXPORT Cookie(NSHTTPCookie *);
</span><del>- operator NSHTTPCookie *() const;
</del><ins>+ WEBCORE_EXPORT operator NSHTTPCookie *() const;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> String name;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkNetworkStorageSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -100,7 +100,11 @@
</span><span class="cx"> NetworkingContext* context() const;
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ WEBCORE_EXPORT void setCookie(const Cookie&);
</ins><span class="cx"> WEBCORE_EXPORT void setCookies(const Vector<Cookie>&, const URL&, const URL& mainDocumentURL);
</span><ins>+ WEBCORE_EXPORT void deleteCookie(const Cookie&);
+ WEBCORE_EXPORT Vector<Cookie> getAllCookies();
+ WEBCORE_EXPORT Vector<Cookie> getCookies(const URL&);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> static HashMap<SessionID, std::unique_ptr<NetworkStorageSession>>& globalSessionMap();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcocoaNetworkStorageSessionCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -32,6 +32,13 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+void NetworkStorageSession::setCookie(const Cookie& cookie)
+{
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [nsCookieStorage() setCookie:(NSHTTPCookie *)cookie];
+ END_BLOCK_OBJC_EXCEPTIONS;
+}
+
</ins><span class="cx"> void NetworkStorageSession::setCookies(const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL)
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<NSMutableArray> nsCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:cookies.size()]);
</span><span class="lines">@@ -43,6 +50,31 @@
</span><span class="cx"> END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void NetworkStorageSession::deleteCookie(const Cookie& cookie)
+{
+ [nsCookieStorage() deleteCookie:(NSHTTPCookie *)cookie];
+}
+
+static Vector<Cookie> nsCookiesToCookieVector(NSArray<NSHTTPCookie *> *nsCookies)
+{
+ Vector<Cookie> cookies;
+ cookies.reserveInitialCapacity(nsCookies.count);
+ for (NSHTTPCookie *nsCookie in nsCookies)
+ cookies.uncheckedAppend(nsCookie);
+
+ return cookies;
+}
+
+Vector<Cookie> NetworkStorageSession::getAllCookies()
+{
+ return nsCookiesToCookieVector(nsCookieStorage().cookies);
+}
+
+Vector<Cookie> NetworkStorageSession::getCookies(const URL& url)
+{
+ return nsCookiesToCookieVector([nsCookieStorage() cookiesForURL:(NSURL *)url]);
+}
+
</ins><span class="cx"> NSHTTPCookieStorage *NetworkStorageSession::nsCookieStorage() const
</span><span class="cx"> {
</span><span class="cx"> auto cfCookieStorage = cookieStorage();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworksoupNetworkStorageSessionSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -304,7 +304,21 @@
</span><span class="cx"> soup_cookie_jar_add_cookie(cookieStorage(), toSoupCookie(cookie));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void NetworkStorageSession::deleteCookie(const Cookie&)
+{
+ // FIXME: Implement for WK2 to use.
+}
</ins><span class="cx">
</span><ins>+Vector<Cookie> NetworkStorageSession::getAllCookies()
+{
+ // FIXME: Implement for WK2 to use.
+}
+
+Vector<Cookie> NetworkStorageSession::getCookies(const URL&)
+{
+ // FIXME: Implement for WK2 to use.
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // USE(SOUP)
</span></span></pre></div>
<a id="trunkSourceWebKit2CMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/CMakeLists.txt (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/CMakeLists.txt        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/CMakeLists.txt        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -333,6 +333,7 @@
</span><span class="cx"> UIProcess/API/APIContentExtensionStore.cpp
</span><span class="cx"> UIProcess/API/APIExperimentalFeature.cpp
</span><span class="cx"> UIProcess/API/APIFrameInfo.cpp
</span><ins>+ UIProcess/API/APIHTTPCookieStorage.cpp
</ins><span class="cx"> UIProcess/API/APIHitTestResult.cpp
</span><span class="cx"> UIProcess/API/APINavigation.cpp
</span><span class="cx"> UIProcess/API/APINavigationData.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -1,3 +1,118 @@
</span><ins>+2017-03-13 Brady Eidson <beidson@apple.com>
+
+ WKWebView provides no access to cookies.
+ https://bugs.webkit.org/show_bug.cgi?id=140191
+
+ Reviewed by Tim Horton.
+
+ This adds a new WKHTTPCookieManager SPI.
+ It follows the NSHTTPCookieStorage API but asynchronous (with completion handlers).
+
+ * CMakeLists.txt:
+ * WebKit2.xcodeproj/project.pbxproj:
+
+ * Shared/API/APIObject.h:
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject):
+
+ * UIProcess/API/APIHTTPCookieStorage.cpp: Added.
+ (API::HTTPCookieStorage::HTTPCookieStorage):
+ (API::HTTPCookieStorage::~HTTPCookieStorage):
+ (API::HTTPCookieStorage::cookies):
+ (API::HTTPCookieStorage::setCookie):
+ (API::HTTPCookieStorage::setCookies):
+ (API::HTTPCookieStorage::deleteCookie):
+ (API::HTTPCookieStorage::removeCookiesSinceDate):
+ (API::HTTPCookieStorage::setHTTPCookieAcceptPolicy):
+ (API::HTTPCookieStorage::getHTTPCookieAcceptPolicy):
+ * UIProcess/API/APIHTTPCookieStorage.h: Added.
+
+ * UIProcess/API/APIWebsiteDataStore.cpp:
+ (API::WebsiteDataStore::defaultDataStore):
+ (API::WebsiteDataStore::httpCookieStorage):
+ * UIProcess/API/APIWebsiteDataStore.h:
+
+ * UIProcess/API/C/WKCookieManager.cpp:
+ (WKCookieManagerDeleteAllCookiesModifiedAfterDate):
+ (WKCookieManagerSetHTTPCookieAcceptPolicy):
+ (WKCookieManagerGetHTTPCookieAcceptPolicy):
+
+ * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+ (WKWebsiteDataStoreGetDefaultDataStore):
+
+ * UIProcess/API/Cocoa/WKProcessPool.mm:
+ (-[WKProcessPool _setCookieAcceptPolicy:]):
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (+[WKWebsiteDataStore defaultDataStore]):
+ (-[WKWebsiteDataStore _httpCookieStorage]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+
+ * UIProcess/API/Cocoa/WKHTTPCookieStorage.h:
+ * UIProcess/API/Cocoa/WKHTTPCookieStorage.mm: Added.
+ (coreCookiesToNSCookies):
+ (-[WKHTTPCookieStorage dealloc]):
+ (-[WKHTTPCookieStorage fetchCookies:]):
+ (-[WKHTTPCookieStorage fetchCookiesForURL:completionHandler:]):
+ (-[WKHTTPCookieStorage setCookie:completionHandler:]):
+ (-[WKHTTPCookieStorage deleteCookie:completionHandler:]):
+ (-[WKHTTPCookieStorage setCookies:forURL:mainDocumentURL:completionHandler:]):
+ (-[WKHTTPCookieStorage removeCookiesSinceDate:completionHandler:]):
+ (-[WKHTTPCookieStorage setCookieAcceptPolicy:completionHandler:]):
+ (kitCookiePolicyToNSCookiePolicy):
+ (-[WKHTTPCookieStorage fetchCookieAcceptPolicy:]):
+ (-[WKHTTPCookieStorage _apiObject]):
+ * UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h.
+ (WebKit::wrapper):
+
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::addSingleCookie):
+
+ * UIProcess/WebCookieManagerProxy.cpp:
+ (WebKit::WebCookieManagerProxy::getHostnamesWithCookies):
+ (WebKit::WebCookieManagerProxy::deleteCookiesForHostname):
+ (WebKit::WebCookieManagerProxy::deleteAllCookies):
+ (WebKit::WebCookieManagerProxy::deleteCookie):
+ (WebKit::WebCookieManagerProxy::deleteAllCookiesModifiedSince):
+ (WebKit::WebCookieManagerProxy::setCookie):
+ (WebKit::WebCookieManagerProxy::setCookies):
+ (WebKit::WebCookieManagerProxy::getAllCookies):
+ (WebKit::WebCookieManagerProxy::getCookies):
+ (WebKit::WebCookieManagerProxy::didSetCookies):
+ (WebKit::WebCookieManagerProxy::didGetCookies):
+ (WebKit::WebCookieManagerProxy::didDeleteCookies):
+ (WebKit::WebCookieManagerProxy::startObservingCookieChanges):
+ (WebKit::WebCookieManagerProxy::stopObservingCookieChanges):
+ (WebKit::WebCookieManagerProxy::setCookieObserverCallback):
+ (WebKit::WebCookieManagerProxy::cookiesDidChange):
+ (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
+ (WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
+ (WebKit::WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy):
+ (WebKit::WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy):
+ * UIProcess/WebCookieManagerProxy.h:
+ * UIProcess/WebCookieManagerProxy.messages.in:
+
+ * UIProcess/WebFrameProxy.h:
+
+ * UIProcess/WebProcessPool.cpp:
+ * UIProcess/WebProcessPool.h:
+
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::processPoolForCookieStorageOperations):
+ (WebKit::WebsiteDataStore::processPools):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+ * WebProcess/Cookies/WebCookieManager.cpp:
+ (WebKit::WebCookieManager::deleteCookie):
+ (WebKit::WebCookieManager::deleteAllCookiesModifiedSince):
+ (WebKit::WebCookieManager::getAllCookies):
+ (WebKit::WebCookieManager::getCookies):
+ (WebKit::WebCookieManager::setCookie):
+ (WebKit::WebCookieManager::setCookies):
+ (WebKit::WebCookieManager::setHTTPCookieAcceptPolicy):
+ * WebProcess/Cookies/WebCookieManager.h:
+ * WebProcess/Cookies/WebCookieManager.messages.in:
+
</ins><span class="cx"> 2017-03-13 John Wilander <wilander@apple.com>
</span><span class="cx">
</span><span class="cx"> Resource Load Statistics: More efficient network process messaging + Fix bug in user interaction reporting
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesssoupNetworkProcessSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx"> supplement<WebCookieManager>()->setCookiePersistentStorage(parameters.cookiePersistentStoragePath,
</span><span class="cx"> parameters.cookiePersistentStorageType);
</span><span class="cx"> }
</span><del>- supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy);
</del><ins>+ supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy, 0);
</ins><span class="cx">
</span><span class="cx"> if (!parameters.languages.isEmpty())
</span><span class="cx"> userPreferredLanguagesChanged(parameters.languages);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPIAPIObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/API/APIObject.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/APIObject.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/Shared/API/APIObject.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx"> FullScreenManager,
</span><span class="cx"> GeolocationManager,
</span><span class="cx"> GeolocationPermissionRequest,
</span><ins>+ HTTPCookieStorage,
</ins><span class="cx"> HitTestResult,
</span><span class="cx"> GeolocationPosition,
</span><span class="cx"> GrammarDetail,
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaAPIObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import "WKContentExtensionInternal.h"
</span><span class="cx"> #import "WKContentExtensionStoreInternal.h"
</span><span class="cx"> #import "WKFrameInfoInternal.h"
</span><ins>+#import "WKHTTPCookieStorageInternal.h"
</ins><span class="cx"> #import "WKNSArray.h"
</span><span class="cx"> #import "WKNSData.h"
</span><span class="cx"> #import "WKNSDictionary.h"
</span><span class="lines">@@ -178,6 +179,10 @@
</span><span class="cx"> wrapper = [WKFrameInfo alloc];
</span><span class="cx"> break;
</span><span class="cx">
</span><ins>+ case Type::HTTPCookieStorage:
+ wrapper = [WKHTTPCookieStorage alloc];
+ break;
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> case Type::HitTestResult:
</span><span class="cx"> wrapper = [_WKHitTestResult alloc];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStoragecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.cpp (0 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.cpp         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -0,0 +1,138 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIHTTPCookieStorage.h"
+
+#include "APIWebsiteDataStore.h"
+#include "WebCookieManagerProxy.h"
+#include "WebProcessPool.h"
+#include <WebCore/Cookie.h>
+
+using namespace WebKit;
+
+namespace API {
+
+HTTPCookieStorage::HTTPCookieStorage(WebsiteDataStore& websiteDataStore)
+ : m_owningDataStore(websiteDataStore)
+{
+}
+
+HTTPCookieStorage::~HTTPCookieStorage()
+{
+}
+
+void HTTPCookieStorage::cookies(Function<void (const Vector<WebCore::Cookie>&)>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->getAllCookies(dataStore.sessionID(), [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](const Vector<WebCore::Cookie>& cookies, CallbackBase::Error error) {
+ completionHandler(cookies);
+ });
+}
+
+void HTTPCookieStorage::cookies(const WebCore::URL& url, Function<void (const Vector<WebCore::Cookie>&)>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->getCookies(dataStore.sessionID(), url, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](const Vector<WebCore::Cookie>& cookies, CallbackBase::Error error) {
+ completionHandler(cookies);
+ });
+}
+
+void HTTPCookieStorage::setCookie(const WebCore::Cookie& cookie, Function<void ()>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->setCookie(dataStore.sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
+ completionHandler();
+ });
+}
+
+void HTTPCookieStorage::setCookies(const Vector<WebCore::Cookie>& cookies, const WebCore::URL& url, const WebCore::URL& mainDocumentURL, Function<void ()>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->setCookies(dataStore.sessionID(), cookies, url, mainDocumentURL, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
+ completionHandler();
+ });
+}
+
+void HTTPCookieStorage::deleteCookie(const WebCore::Cookie& cookie, Function<void ()>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->deleteCookie(dataStore.sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
+ completionHandler();
+ });
+}
+
+void HTTPCookieStorage::removeCookiesSinceDate(std::chrono::system_clock::time_point date, Function<void ()>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->deleteAllCookiesModifiedSince(dataStore.sessionID(), date, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
+ completionHandler();
+ });
+}
+
+void HTTPCookieStorage::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, Function<void ()>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->setHTTPCookieAcceptPolicy(dataStore.sessionID(), policy, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](CallbackBase::Error error) {
+ completionHandler();
+ });
+}
+
+void HTTPCookieStorage::getHTTPCookieAcceptPolicy(Function<void (HTTPCookieAcceptPolicy)>&& completionHandler)
+{
+ auto& dataStore = m_owningDataStore.websiteDataStore();
+ auto pool = dataStore.processPoolForCookieStorageOperations();
+ auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+
+ cookieManager->getHTTPCookieAcceptPolicy(dataStore.sessionID(), [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)](HTTPCookieAcceptPolicy policy, CallbackBase::Error error) {
+ if (error != CallbackBase::Error::None)
+ policy = HTTPCookieAcceptPolicyNever;
+
+ completionHandler(policy);
+ });
+}
+
+} // namespace API
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIHTTPCookieStorageh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.h (0 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include "HTTPCookieAcceptPolicy.h"
+#include <wtf/Function.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class URL;
+struct Cookie;
+}
+
+namespace API {
+
+class WebsiteDataStore;
+
+class HTTPCookieStorage final : public ObjectImpl<Object::Type::HTTPCookieStorage> {
+public:
+ static Ref<HTTPCookieStorage> create(WebsiteDataStore& websiteDataStore)
+ {
+ return adoptRef(*new HTTPCookieStorage(websiteDataStore));
+ }
+
+ virtual ~HTTPCookieStorage();
+
+ void cookies(Function<void (const Vector<WebCore::Cookie>&)>&& completionHandler);
+ void cookies(const WebCore::URL&, Function<void (const Vector<WebCore::Cookie>&)>&& completionHandler);
+
+ void setCookie(const WebCore::Cookie&, Function<void ()>&& completionHandler);
+ void setCookies(const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL, Function<void ()>&& completionHandler);
+ void deleteCookie(const WebCore::Cookie&, Function<void ()>&& completionHandler);
+
+ void removeCookiesSinceDate(std::chrono::system_clock::time_point, Function<void ()>&& completionHandler);
+
+ void setHTTPCookieAcceptPolicy(WebKit::HTTPCookieAcceptPolicy, Function<void ()>&& completionHandler);
+ void getHTTPCookieAcceptPolicy(Function<void (WebKit::HTTPCookieAcceptPolicy)>&& completionHandler);
+
+private:
+ HTTPCookieStorage(WebsiteDataStore&);
+
+ WebsiteDataStore& m_owningDataStore;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -31,13 +31,13 @@
</span><span class="cx">
</span><span class="cx"> namespace API {
</span><span class="cx">
</span><del>-RefPtr<WebsiteDataStore> WebsiteDataStore::defaultDataStore()
</del><ins>+Ref<WebsiteDataStore> WebsiteDataStore::defaultDataStore()
</ins><span class="cx"> {
</span><span class="cx"> WebKit::InitializeWebKit2();
</span><span class="cx">
</span><span class="cx"> static WebsiteDataStore* defaultDataStore = adoptRef(new WebsiteDataStore(defaultDataStoreConfiguration())).leakRef();
</span><span class="cx">
</span><del>- return defaultDataStore;
</del><ins>+ return *defaultDataStore;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Ref<WebsiteDataStore> WebsiteDataStore::createNonPersistentDataStore()
</span><span class="lines">@@ -64,6 +64,14 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+HTTPCookieStorage& WebsiteDataStore::httpCookieStorage()
+{
+ if (!m_apiHTTPCookieStorage)
+ m_apiHTTPCookieStorage = HTTPCookieStorage::create(*this);
+
+ return *m_apiHTTPCookieStorage;
+}
+
</ins><span class="cx"> bool WebsiteDataStore::isPersistent()
</span><span class="cx"> {
</span><span class="cx"> return m_websiteDataStore->isPersistent();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> #ifndef APIWebsiteDataStore_h
</span><span class="cx"> #define APIWebsiteDataStore_h
</span><span class="cx">
</span><del>-#include "APIObject.h"
</del><ins>+#include "APIHTTPCookieStorage.h"
</ins><span class="cx"> #include "WebsiteDataStore.h"
</span><span class="cx"> #include <WebCore/SessionID.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">
</span><span class="cx"> class WebsiteDataStore final : public ObjectImpl<Object::Type::WebsiteDataStore> {
</span><span class="cx"> public:
</span><del>- static RefPtr<WebsiteDataStore> defaultDataStore();
</del><ins>+ static Ref<WebsiteDataStore> defaultDataStore();
</ins><span class="cx"> static Ref<WebsiteDataStore> createNonPersistentDataStore();
</span><span class="cx"> static Ref<WebsiteDataStore> create(WebKit::WebsiteDataStore::Configuration);
</span><span class="cx">
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> void registerSharedResourceLoadObserver();
</span><span class="cx">
</span><span class="cx"> WebKit::WebsiteDataStore& websiteDataStore() { return *m_websiteDataStore; }
</span><ins>+ HTTPCookieStorage& httpCookieStorage();
</ins><span class="cx">
</span><span class="cx"> static String defaultApplicationCacheDirectory();
</span><span class="cx"> static String defaultNetworkCacheDirectory();
</span><span class="lines">@@ -74,6 +75,7 @@
</span><span class="cx"> static String websiteDataDirectoryFileSystemRepresentation(const String& directoryName);
</span><span class="cx">
</span><span class="cx"> RefPtr<WebKit::WebsiteDataStore> m_websiteDataStore;
</span><ins>+ RefPtr<HTTPCookieStorage> m_apiHTTPCookieStorage;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKCookieManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -61,17 +61,17 @@
</span><span class="cx"> using namespace std::chrono;
</span><span class="cx">
</span><span class="cx"> auto time = system_clock::time_point(duration_cast<system_clock::duration>(duration<double>(date)));
</span><del>- toImpl(cookieManagerRef)->deleteAllCookiesModifiedSince(WebCore::SessionID::defaultSessionID(), time);
</del><ins>+ toImpl(cookieManagerRef)->deleteAllCookiesModifiedSince(WebCore::SessionID::defaultSessionID(), time, [](CallbackBase::Error){});
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy)
</span><span class="cx"> {
</span><del>- toImpl(cookieManager)->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
</del><ins>+ toImpl(cookieManager)->setHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [](CallbackBase::Error){});
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback)
</span><span class="cx"> {
</span><del>- toImpl(cookieManager)->getHTTPCookieAcceptPolicy(toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(context, callback));
</del><ins>+ toImpl(cookieManager)->getHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(context, callback));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WKCookieManagerSetCookieStoragePartitioningEnabled(WKCookieManagerRef cookieManager, bool enabled)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKWebsiteDataStoreRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKWebsiteDataStoreRef.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKWebsiteDataStoreRef.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">
</span><span class="cx"> WKWebsiteDataStoreRef WKWebsiteDataStoreGetDefaultDataStore()
</span><span class="cx"> {
</span><del>- return WebKit::toAPI(API::WebsiteDataStore::defaultDataStore().get());
</del><ins>+ return WebKit::toAPI(API::WebsiteDataStore::defaultDataStore().ptr());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WKWebsiteDataStoreRef WKWebsiteDataStoreCreateNonPersistentDataStore()
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKHTTPCookieStorageh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.h (0 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/*!
+ A WKHTTPCookieStorage object allows managing the HTTP cookies associated with a particular WKWebsiteDataStore.
+ */
+WK_CLASS_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface WKHTTPCookieStorage : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
+/*! @abstract Fetches all stored cookies.
+ @param completionHandler A block to invoke with the fetched cookies.
+ */
+- (void)fetchCookies:(void (^)(NSArray<NSHTTPCookie *> *))completionHandler;
+
+/*! @abstract Fetches all of the stored cookies for the given URL.
+ @param completionHandler A block to invoke with the fetched cookies.
+ */
+- (void)fetchCookiesForURL:(NSURL *)url completionHandler:(void (^)(NSArray<NSHTTPCookie *> *))completionHandler;
+
+/*! @abstract Set a cookie.
+ @param cookie The cookie to set.
+ @param completionHandler A block to invoke once the cookie has been stored.
+ */
+- (void)setCookie:(NSHTTPCookie *)cookie completionHandler:(nullable void (^)())completionHandler;
+
+/*! @abstract Adds an array cookies to the cookie store, following the cookie accept policy.
+ @param cookies The cookies to set.
+ @param URL The URL from which the cookies were sent.
+ @param mainDocumentURL The main document URL to be used as a base for the "same domain as main document" policy.
+ @param completionHandler A block to invoke once the cookies have been stored.
+ */
+- (void)setCookies:(NSArray<NSHTTPCookie *> *)cookies forURL:(NSURL *)url mainDocumentURL:(nullable NSURL *)mainDocumentURL completionHandler:(nullable void (^)())completionHandler;
+
+/*! @abstract Delete the specified cookie.
+ @param completionHandler A block to invoke once the cookie has been deleted.
+ */
+- (void)deleteCookie:(NSHTTPCookie *)cookie completionHandler:(nullable void (^)())completionHandler;
+
+/*! @abstract Delete all cookies from the cookie storage since the provided date.
+ @param date The date after which set cookies should be removed.
+ @param completionHandler A block to invoke once the cookies have been deleted.
+ */
+- (void)removeCookiesSinceDate:(NSDate *)date completionHandler:(nullable void (^)())completionHandler;
+
+/*! @abstract Sets the cookie accept policy preference of the receiver.
+ @param policy The cookie accept policy to set.
+ @param completionHandler A block to invoke once the policy has been set.
+ */
+- (void)setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy completionHandler:(nullable void (^)())completionHandler;
+
+/*! @abstract Fetches the cookie accept policy preference of the receiver.
+ @param completionHandler A block to invoke with the fetched policy.
+ */
+- (void)fetchCookieAcceptPolicy:(void (^)(NSHTTPCookieAcceptPolicy))completionHandler;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKHTTPCookieStoragemm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.mm (0 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.mm         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.mm        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -0,0 +1,161 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKHTTPCookieStorageInternal.h"
+
+#if WK_API_ENABLED
+
+#include "HTTPCookieAcceptPolicy.h"
+#include <WebCore/CFNetworkSPI.h>
+#include <WebCore/Cookie.h>
+#include <WebCore/URL.h>
+#include <wtf/RetainPtr.h>
+
+static NSArray<NSHTTPCookie *> *coreCookiesToNSCookies(const Vector<WebCore::Cookie>& coreCookies)
+{
+ NSMutableArray<NSHTTPCookie *> *nsCookies = [NSMutableArray arrayWithCapacity:coreCookies.size()];
+
+ for (auto& cookie : coreCookies)
+ [nsCookies addObject:(NSHTTPCookie *)cookie];
+
+ return nsCookies;
+}
+
+@implementation WKHTTPCookieStorage
+
+- (void)dealloc
+{
+ _cookieStorage->API::HTTPCookieStorage::~HTTPCookieStorage();
+
+ [super dealloc];
+}
+
+- (void)fetchCookies:(void (^)(NSArray<NSHTTPCookie *> *))completionHandler
+{
+ _cookieStorage->cookies([handler = adoptNS([completionHandler copy])](const Vector<WebCore::Cookie>& cookies) {
+ auto rawHandler = (void (^)(NSArray<NSHTTPCookie *> *))handler.get();
+ rawHandler(coreCookiesToNSCookies(cookies));
+ });
+}
+
+- (void)fetchCookiesForURL:(NSURL *)url completionHandler:(void (^)(NSArray<NSHTTPCookie *> *))completionHandler
+{
+ _cookieStorage->cookies(url, [handler = adoptNS([completionHandler copy])](const Vector<WebCore::Cookie>& cookies) {
+ auto rawHandler = (void (^)(NSArray<NSHTTPCookie *> *))handler.get();
+ rawHandler(coreCookiesToNSCookies(cookies));
+ });
+}
+
+- (void)setCookie:(NSHTTPCookie *)cookie completionHandler:(void (^)())completionHandler
+{
+ _cookieStorage->setCookie(cookie, [handler = adoptNS([completionHandler copy])]() {
+ auto rawHandler = (void (^)())handler.get();
+ if (rawHandler)
+ rawHandler();
+ });
+
+}
+
+- (void)deleteCookie:(NSHTTPCookie *)cookie completionHandler:(void (^)())completionHandler
+{
+ _cookieStorage->deleteCookie(cookie, [handler = adoptNS([completionHandler copy])]() {
+ auto rawHandler = (void (^)())handler.get();
+ if (rawHandler)
+ rawHandler();
+ });
+}
+
+- (void)setCookies:(NSArray<NSHTTPCookie *> *)cookies forURL:(NSURL *)URL mainDocumentURL:(NSURL *)mainDocumentURL completionHandler:(void (^)())completionHandler
+{
+ Vector<WebCore::Cookie> coreCookies;
+ coreCookies.reserveInitialCapacity(cookies.count);
+ for (NSHTTPCookie *cookie : cookies)
+ coreCookies.uncheckedAppend(cookie);
+
+ _cookieStorage->setCookies(coreCookies, URL, mainDocumentURL, [handler = adoptNS([completionHandler copy])]() {
+ auto rawHandler = (void (^)())handler.get();
+ if (rawHandler)
+ rawHandler();
+ });
+}
+
+- (void)removeCookiesSinceDate:(NSDate *)date completionHandler:(void (^)())completionHandler
+{
+ auto systemClockTime = std::chrono::system_clock::time_point(std::chrono::duration_cast<std::chrono::system_clock::duration>(std::chrono::duration<double>(date.timeIntervalSince1970)));
+
+ _cookieStorage->removeCookiesSinceDate(systemClockTime, [handler = adoptNS([completionHandler copy])]() {
+ auto rawHandler = (void (^)())handler.get();
+ if (rawHandler)
+ rawHandler();
+ });
+}
+
+- (void)setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy completionHandler:(void (^)())completionHandler
+{
+ _cookieStorage->setHTTPCookieAcceptPolicy(policy, [handler = adoptNS([completionHandler copy])]() {
+ auto rawHandler = (void (^)())handler.get();
+ if (rawHandler)
+ rawHandler();
+ });
+}
+
+static NSHTTPCookieAcceptPolicy kitCookiePolicyToNSCookiePolicy(WebKit::HTTPCookieAcceptPolicy kitPolicy)
+{
+ switch (kitPolicy) {
+ case WebKit::HTTPCookieAcceptPolicyAlways:
+ return NSHTTPCookieAcceptPolicyAlways;
+ case WebKit::HTTPCookieAcceptPolicyNever:
+ return NSHTTPCookieAcceptPolicyNever;
+ case WebKit::HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
+ return NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+ case WebKit::HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
+ // Cast required because of CFNetworkSPI.
+ return static_cast<NSHTTPCookieAcceptPolicy>(NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain);
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return NSHTTPCookieAcceptPolicyNever;
+}
+
+- (void)fetchCookieAcceptPolicy:(void (^)(NSHTTPCookieAcceptPolicy))completionHandler
+{
+ _cookieStorage->getHTTPCookieAcceptPolicy([handler = adoptNS([completionHandler copy])](WebKit::HTTPCookieAcceptPolicy policy) {
+ auto rawHandler = (void (^)(NSHTTPCookieAcceptPolicy))handler.get();
+ rawHandler(kitCookiePolicyToNSCookiePolicy(policy));
+ });
+}
+
+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+ return *_cookieStorage;
+}
+
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKHTTPCookieStorageInternalhfromrev213876trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataStorePrivateh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h (from rev 213876, trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h) (0 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WKHTTPCookieStorage.h"
+
+#if WK_API_ENABLED
+
+#import "APIHTTPCookieStorage.h"
+#import "WKObject.h"
+
+namespace WebKit {
+
+inline WKHTTPCookieStorage *wrapper(API::HTTPCookieStorage& cookieStorage)
+{
+ ASSERT([cookieStorage.wrapper() isKindOfClass:[WKHTTPCookieStorage class]]);
+ return (WKHTTPCookieStorage *)cookieStorage.wrapper();
+}
+
+}
+
+@interface WKHTTPCookieStorage () <WKObject> {
+@package
+ API::ObjectStorage<API::HTTPCookieStorage> _cookieStorage;
+}
+@end
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKProcessPoolmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -196,7 +196,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)_setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
</span><span class="cx"> {
</span><del>- _processPool->supplement<WebKit::WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
</del><ins>+ _processPool->supplement<WebKit::WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [](WebKit::CallbackBase::Error){});
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (id)_objectForBundleParameter:(NSString *)parameter
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">
</span><ins>+#import "WKHTTPCookieStorageInternal.h"
</ins><span class="cx"> #import "WKNSArray.h"
</span><span class="cx"> #import "WKWebsiteDataRecordInternal.h"
</span><span class="cx"> #import "WebsiteDataFetchOption.h"
</span><span class="lines">@@ -38,7 +39,7 @@
</span><span class="cx">
</span><span class="cx"> + (WKWebsiteDataStore *)defaultDataStore
</span><span class="cx"> {
</span><del>- return WebKit::wrapper(*API::WebsiteDataStore::defaultDataStore().get());
</del><ins>+ return WebKit::wrapper(API::WebsiteDataStore::defaultDataStore().get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> + (WKWebsiteDataStore *)nonPersistentDataStore
</span><span class="lines">@@ -194,6 +195,11 @@
</span><span class="cx"> _websiteDataStore->websiteDataStore().setResourceLoadStatisticsEnabled(enabled);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (WKHTTPCookieStorage *)_httpCookieStorage
+{
+ return WebKit::wrapper(_websiteDataStore->httpCookieStorage());
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataStorePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx">
</span><span class="cx"> NS_ASSUME_NONNULL_BEGIN
</span><span class="cx">
</span><ins>+@class WKHTTPCookieStorage;
</ins><span class="cx"> @class _WKWebsiteDataStoreConfiguration;
</span><span class="cx">
</span><span class="cx"> typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) {
</span><span class="lines">@@ -43,6 +44,9 @@
</span><span class="cx">
</span><span class="cx"> @property (nonatomic, setter=_setResourceLoadStatisticsEnabled:) BOOL _resourceLoadStatisticsEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx">
</span><ins>+/*! @abstract Returns the cookie storage representing HTTP cookies in this website data store. */
+@property (nonatomic, readonly) WKHTTPCookieStorage *_httpCookieStorage WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> NS_ASSUME_NONNULL_END
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitCookieManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include "WebKitWebsiteDataManagerPrivate.h"
</span><span class="cx"> #include "WebKitWebsiteDataPrivate.h"
</span><span class="cx"> #include "WebsiteDataRecord.h"
</span><ins>+#include <WebCore/SessionID.h>
</ins><span class="cx"> #include <wtf/glib/GRefPtr.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span><span class="lines">@@ -178,7 +179,7 @@
</span><span class="cx"> g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));
</span><span class="cx">
</span><span class="cx"> for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager))
</span><del>- processPool->supplement<WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
</del><ins>+ processPool->supplement<WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [](CallbackBase::Error){});
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void webkitCookieManagerGetAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef, void* context)
</span><span class="lines">@@ -212,7 +213,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- processPools[0]->supplement<WebCookieManagerProxy>()->getHTTPCookieAcceptPolicy(
</del><ins>+ processPools[0]->supplement<WebCookieManagerProxy>()->getHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(),
</ins><span class="cx"> toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(task.leakRef(), webkitCookieManagerGetAcceptPolicyCallback));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -734,7 +734,7 @@
</span><span class="cx">
</span><span class="cx"> // FIXME: Using activeURL here twice is basically saying "this is always in the context of the main document"
</span><span class="cx"> // which probably isn't accurate.
</span><del>- cookieManager->setCookies(WebCore::SessionID::defaultSessionID(), { cookie }, activeURL, activeURL);
</del><ins>+ cookieManager->setCookies(WebCore::SessionID::defaultSessionID(), { cookie }, activeURL, activeURL, [](CallbackBase::Error){});
</ins><span class="cx">
</span><span class="cx"> callback->sendSuccess();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebCookieManagerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -32,8 +32,11 @@
</span><span class="cx"> #include "WebCookieManagerMessages.h"
</span><span class="cx"> #include "WebCookieManagerProxyMessages.h"
</span><span class="cx"> #include "WebProcessPool.h"
</span><ins>+#include <WebCore/Cookie.h>
</ins><span class="cx"> #include <WebCore/SecurityOriginData.h>
</span><span class="cx">
</span><ins>+using namespace WebCore;
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> const char* WebCookieManagerProxy::supplementName()
</span><span class="lines">@@ -94,7 +97,7 @@
</span><span class="cx"> API::Object::deref();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::getHostnamesWithCookies(WebCore::SessionID sessionID, Function<void (API::Array*, CallbackBase::Error)>&& callbackFunction)
</del><ins>+void WebCookieManagerProxy::getHostnamesWithCookies(SessionID sessionID, Function<void (API::Array*, CallbackBase::Error)>&& callbackFunction)
</ins><span class="cx"> {
</span><span class="cx"> auto callback = ArrayCallback::create(WTFMove(callbackFunction));
</span><span class="cx"> uint64_t callbackID = callback->callbackID();
</span><span class="lines">@@ -114,37 +117,96 @@
</span><span class="cx"> callback->performCallbackWithReturnValue(API::Array::createStringArray(hostnames).ptr());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::deleteCookiesForHostname(WebCore::SessionID sessionID, const String& hostname)
</del><ins>+void WebCookieManagerProxy::deleteCookiesForHostname(SessionID sessionID, const String& hostname)
</ins><span class="cx"> {
</span><span class="cx"> processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteCookiesForHostname(sessionID, hostname));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::deleteAllCookies(WebCore::SessionID sessionID)
</del><ins>+void WebCookieManagerProxy::deleteAllCookies(SessionID sessionID)
</ins><span class="cx"> {
</span><span class="cx"> processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookies(sessionID));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::deleteAllCookiesModifiedSince(WebCore::SessionID sessionID, std::chrono::system_clock::time_point time)
</del><ins>+void WebCookieManagerProxy::deleteCookie(SessionID sessionID, const Cookie& cookie, Function<void (CallbackBase::Error)>&& callbackFunction)
</ins><span class="cx"> {
</span><del>- processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookiesModifiedSince(sessionID, time));
</del><ins>+ auto callback = VoidCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteCookie(sessionID, cookie, callbackID));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::setCookies(WebCore::SessionID sessionID, const Vector<WebCore::Cookie>& cookies, const WebCore::URL& url, const WebCore::URL& mainDocumentURL)
</del><ins>+void WebCookieManagerProxy::deleteAllCookiesModifiedSince(SessionID sessionID, std::chrono::system_clock::time_point time, Function<void (CallbackBase::Error)>&& callbackFunction)
</ins><span class="cx"> {
</span><del>- processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetCookies(sessionID, cookies, url, mainDocumentURL));
</del><ins>+ auto callback = VoidCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookiesModifiedSince(sessionID, time, callbackID));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::startObservingCookieChanges(WebCore::SessionID sessionID)
</del><ins>+void WebCookieManagerProxy::setCookie(SessionID sessionID, const Cookie& cookie, Function<void (CallbackBase::Error)>&& callbackFunction)
</ins><span class="cx"> {
</span><ins>+ auto callback = VoidCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetCookie(sessionID, cookie, callbackID));
+}
+
+void WebCookieManagerProxy::setCookies(SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL, Function<void (CallbackBase::Error)>&& callbackFunction)
+{
+ auto callback = VoidCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetCookies(sessionID, cookies, url, mainDocumentURL, callbackID));
+}
+
+void WebCookieManagerProxy::getAllCookies(SessionID sessionID, Function<void (const Vector<Cookie>&, CallbackBase::Error)>&& callbackFunction)
+{
+ auto callback = GetCookiesCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_getCookiesCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::GetAllCookies(sessionID, callbackID));
+}
+
+void WebCookieManagerProxy::getCookies(SessionID sessionID, const URL& url, Function<void (const Vector<Cookie>&, CallbackBase::Error)>&& callbackFunction)
+{
+ auto callback = GetCookiesCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_getCookiesCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::GetCookies(sessionID, url, callbackID));
+}
+
+void WebCookieManagerProxy::didSetCookies(uint64_t callbackID)
+{
+ m_voidCallbacks.take(callbackID)->performCallback();
+}
+
+void WebCookieManagerProxy::didGetCookies(const Vector<Cookie>& cookies, uint64_t callbackID)
+{
+ m_getCookiesCallbacks.take(callbackID)->performCallbackWithReturnValue(cookies);
+}
+
+void WebCookieManagerProxy::didDeleteCookies(uint64_t callbackID)
+{
+ m_voidCallbacks.take(callbackID)->performCallback();
+}
+
+void WebCookieManagerProxy::startObservingCookieChanges(SessionID sessionID)
+{
</ins><span class="cx"> processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::StartObservingCookieChanges(sessionID));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::stopObservingCookieChanges(WebCore::SessionID sessionID)
</del><ins>+void WebCookieManagerProxy::stopObservingCookieChanges(SessionID sessionID)
</ins><span class="cx"> {
</span><span class="cx"> processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::StopObservingCookieChanges(sessionID));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::setCookieObserverCallback(WebCore::SessionID sessionID, std::function<void ()>&& callback)
</del><ins>+void WebCookieManagerProxy::setCookieObserverCallback(SessionID sessionID, std::function<void ()>&& callback)
</ins><span class="cx"> {
</span><span class="cx"> if (callback)
</span><span class="cx"> m_cookieObservers.set(sessionID, WTFMove(callback));
</span><span class="lines">@@ -152,7 +214,7 @@
</span><span class="cx"> m_cookieObservers.remove(sessionID);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::cookiesDidChange(WebCore::SessionID sessionID)
</del><ins>+void WebCookieManagerProxy::cookiesDidChange(SessionID sessionID)
</ins><span class="cx"> {
</span><span class="cx"> m_client.cookiesDidChange(this);
</span><span class="cx"> if (auto callback = m_cookieObservers.get(sessionID))
</span><span class="lines">@@ -159,7 +221,7 @@
</span><span class="cx"> callback();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
</del><ins>+void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(SessionID, HTTPCookieAcceptPolicy policy, Function<void (CallbackBase::Error)>&& callbackFunction)
</ins><span class="cx"> {
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> if (!processPool()->isUsingTestingNetworkSession())
</span><span class="lines">@@ -172,11 +234,16 @@
</span><span class="cx"> // The policy is not sent to newly created processes (only Soup does that via setInitialHTTPCookieAcceptPolicy()). This is not a serious problem, because:
</span><span class="cx"> // - When testing, we only have one WebProcess and one NetworkProcess, and WebKitTestRunner never restarts them;
</span><span class="cx"> // - When not testing, Cocoa has the policy persisted, and thus new processes use it (even for ephemeral sessions).
</span><del>- processPool()->sendToAllProcesses(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
- processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
</del><ins>+ processPool()->sendToAllProcesses(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy, 0));
+
+ auto callback = VoidCallback::create(WTFMove(callbackFunction));
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, WTFMove(callback));
+
+ processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy, callbackID));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)> callbackFunction)
</del><ins>+void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(SessionID, Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>&& callbackFunction)
</ins><span class="cx"> {
</span><span class="cx"> auto callback = HTTPCookieAcceptPolicyCallback::create(WTFMove(callbackFunction));
</span><span class="cx">
</span><span class="lines">@@ -188,13 +255,12 @@
</span><span class="cx">
</span><span class="cx"> void WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID)
</span><span class="cx"> {
</span><del>- RefPtr<HTTPCookieAcceptPolicyCallback> callback = m_httpCookieAcceptPolicyCallbacks.take(callbackID);
- if (!callback) {
- // FIXME: Log error or assert.
- return;
- }
</del><ins>+ m_httpCookieAcceptPolicyCallbacks.take(callbackID)->performCallbackWithReturnValue(policy);
+}
</ins><span class="cx">
</span><del>- callback->performCallbackWithReturnValue(policy);
</del><ins>+void WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy(uint64_t callbackID)
+{
+ m_voidCallbacks.take(callbackID)->performCallback();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebCookieManagerProxy::setCookieStoragePartitioningEnabled(bool enabled)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebCookieManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx">
</span><span class="cx"> typedef GenericCallback<API::Array*> ArrayCallback;
</span><span class="cx"> typedef GenericCallback<HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
</span><ins>+typedef GenericCallback<const Vector<WebCore::Cookie>&> GetCookiesCallback;
</ins><span class="cx">
</span><span class="cx"> class WebCookieManagerProxy : public API::ObjectImpl<API::Object::Type::CookieManager>, public WebContextSupplement, private IPC::MessageReceiver {
</span><span class="cx"> public:
</span><span class="lines">@@ -66,14 +67,20 @@
</span><span class="cx"> void initializeClient(const WKCookieManagerClientBase*);
</span><span class="cx">
</span><span class="cx"> void getHostnamesWithCookies(WebCore::SessionID, Function<void (API::Array*, CallbackBase::Error)>&&);
</span><ins>+ void deleteCookie(WebCore::SessionID, const WebCore::Cookie&, Function<void (CallbackBase::Error)>&&);
</ins><span class="cx"> void deleteCookiesForHostname(WebCore::SessionID, const String& hostname);
</span><span class="cx"> void deleteAllCookies(WebCore::SessionID);
</span><del>- void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point);
</del><ins>+ void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point, Function<void (CallbackBase::Error)>&&);
</ins><span class="cx">
</span><del>- void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL);
</del><ins>+ void setCookie(WebCore::SessionID, const WebCore::Cookie&, Function<void (CallbackBase::Error)>&&);
+ void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL, Function<void (CallbackBase::Error)>&&);
</ins><span class="cx">
</span><del>- void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
- void getHTTPCookieAcceptPolicy(Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>);
</del><ins>+ void getAllCookies(WebCore::SessionID, Function<void (const Vector<WebCore::Cookie>&, CallbackBase::Error)>&& completionHandler);
+ void getCookies(WebCore::SessionID, const WebCore::URL&, Function<void (const Vector<WebCore::Cookie>&, CallbackBase::Error)>&& completionHandler);
+
+ void setHTTPCookieAcceptPolicy(WebCore::SessionID, HTTPCookieAcceptPolicy, Function<void (CallbackBase::Error)>&&);
+ void getHTTPCookieAcceptPolicy(WebCore::SessionID, Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>&&);
+
</ins><span class="cx"> void setCookieStoragePartitioningEnabled(bool);
</span><span class="cx">
</span><span class="cx"> void startObservingCookieChanges(WebCore::SessionID);
</span><span class="lines">@@ -95,6 +102,11 @@
</span><span class="cx"> void didGetHostnamesWithCookies(const Vector<String>&, uint64_t callbackID);
</span><span class="cx"> void didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID);
</span><span class="cx">
</span><ins>+ void didSetHTTPCookieAcceptPolicy(uint64_t callbackID);
+ void didSetCookies(uint64_t callbackID);
+ void didGetCookies(const Vector<WebCore::Cookie>&, uint64_t callbackID);
+ void didDeleteCookies(uint64_t callbackID);
+
</ins><span class="cx"> void cookiesDidChange(WebCore::SessionID);
</span><span class="cx">
</span><span class="cx"> // WebContextSupplement
</span><span class="lines">@@ -113,6 +125,8 @@
</span><span class="cx">
</span><span class="cx"> HashMap<uint64_t, RefPtr<ArrayCallback>> m_arrayCallbacks;
</span><span class="cx"> HashMap<uint64_t, RefPtr<HTTPCookieAcceptPolicyCallback>> m_httpCookieAcceptPolicyCallbacks;
</span><ins>+ HashMap<uint64_t, RefPtr<VoidCallback>> m_voidCallbacks;
+ HashMap<uint64_t, RefPtr<GetCookiesCallback>> m_getCookiesCallbacks;
</ins><span class="cx">
</span><span class="cx"> HashMap<WebCore::SessionID, std::function<void ()>> m_cookieObservers;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebCookieManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -23,6 +23,11 @@
</span><span class="cx"> messages -> WebCookieManagerProxy {
</span><span class="cx"> DidGetHostnamesWithCookies(Vector<String> hostnames, uint64_t callbackID);
</span><span class="cx"> DidGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID);
</span><del>-
</del><ins>+
+ DidSetHTTPCookieAcceptPolicy(uint64_t callbackID);
+ DidDeleteCookies(uint64_t callbackID);
+ DidSetCookies(uint64_t callbackID);
+ DidGetCookies(Vector<WebCore::Cookie> cookies, uint64_t callbackID);
+
</ins><span class="cx"> CookiesDidChange(WebCore::SessionID sessionID)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebFrameProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebFrameProxy.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebFrameProxy.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebFrameProxy.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "WebFrameListenerProxy.h"
</span><span class="cx"> #include <WebCore/FrameLoaderTypes.h>
</span><span class="cx"> #include <wtf/Forward.h>
</span><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "APIAutomationClient.h"
</span><span class="cx"> #include "APICustomProtocolManagerClient.h"
</span><span class="cx"> #include "APIDownloadClient.h"
</span><ins>+#include "APIHTTPCookieStorage.h"
</ins><span class="cx"> #include "APILegacyContextHistoryClient.h"
</span><span class="cx"> #include "APIPageConfiguration.h"
</span><span class="cx"> #include "APIProcessPoolConfiguration.h"
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -76,6 +76,7 @@
</span><span class="cx"> class AutomationClient;
</span><span class="cx"> class CustomProtocolManagerClient;
</span><span class="cx"> class DownloadClient;
</span><ins>+class HTTPCookieStorage;
</ins><span class="cx"> class LegacyContextHistoryClient;
</span><span class="cx"> class PageConfiguration;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "APIWebsiteDataRecord.h"
</span><span class="cx"> #include "NetworkProcessMessages.h"
</span><span class="cx"> #include "StorageManager.h"
</span><ins>+#include "WebCookieManagerProxy.h"
</ins><span class="cx"> #include "WebProcessMessages.h"
</span><span class="cx"> #include "WebProcessPool.h"
</span><span class="cx"> #include "WebResourceLoadStatisticsStore.h"
</span><span class="lines">@@ -105,6 +106,27 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Ref<WebProcessPool> WebsiteDataStore::processPoolForCookieStorageOperations()
+{
+ // Our concepts of WebProcess, WebProcessPool, WebsiteDataStore, and SessionIDs have all started to overlap
+ // without clear divisions of responsibilities.
+ // In practice, multiple WebProcessPools can contain "the same session", especially since there is currently
+ // only a single default global SessionID.
+ //
+ // This means that multiple NetworkProcesses can be using the same session, which means that multiple
+ // NetworkProcesses can be referring to the same platform cookie storage.
+ //
+ // While this may cause complications with future APIs it is actually fine for implementing the WKHTTPCookieStorage API
+ // because we only need one NetworkProcess to successfully make a requested platform cookie storage change.
+ //
+ // FIXME: We need to start to unravel this mess going forward.
+
+ auto pools = processPools(1);
+ ASSERT(!pools.isEmpty());
+
+ return **pools.begin();
+}
+
</ins><span class="cx"> void WebsiteDataStore::resolveDirectoriesIfNecessary()
</span><span class="cx"> {
</span><span class="cx"> if (m_hasResolvedDirectories)
</span><span class="lines">@@ -1108,7 +1130,7 @@
</span><span class="cx"> m_storageManager->processDidCloseConnection(webProcessProxy, connection);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools() const
</del><ins>+HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools(size_t count) const
</ins><span class="cx"> {
</span><span class="cx"> HashSet<RefPtr<WebProcessPool>> processPools;
</span><span class="cx"> for (auto& process : processes())
</span><span class="lines">@@ -1122,11 +1144,20 @@
</span><span class="cx"> processPools.add(processPool);
</span><span class="cx"> break;
</span><span class="cx"> }
</span><ins>+ } else if (&API::WebsiteDataStore::defaultDataStore()->websiteDataStore() == this) {
+ // If a process pool doesn't have an explicit data store and this is the default WebsiteDataStore,
+ // add that process pool to the set.
+ // FIXME: This behavior is weird and necessitated by the fact that process pools don't always
+ // have a data store; they should.
+ processPools.add(processPool);
</ins><span class="cx"> }
</span><ins>+
+ if (processPools.size() == count)
+ break;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (processPools.isEmpty()) {
</del><ins>+ if (processPools.isEmpty() && count) {
</ins><span class="cx"> auto processPool = WebProcessPool::create(API::ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration(m_configuration));
</span><span class="cx"> processPools.add(processPool.ptr());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -103,6 +103,8 @@
</span><span class="cx">
</span><span class="cx"> StorageManager* storageManager() { return m_storageManager.get(); }
</span><span class="cx">
</span><ins>+ Ref<WebProcessPool> processPoolForCookieStorageOperations();
+
</ins><span class="cx"> private:
</span><span class="cx"> explicit WebsiteDataStore(WebCore::SessionID);
</span><span class="cx"> explicit WebsiteDataStore(Configuration);
</span><span class="lines">@@ -119,7 +121,7 @@
</span><span class="cx"> void platformDestroy();
</span><span class="cx"> static void platformRemoveRecentSearches(std::chrono::system_clock::time_point);
</span><span class="cx">
</span><del>- HashSet<RefPtr<WebProcessPool>> processPools() const;
</del><ins>+ HashSet<RefPtr<WebProcessPool>> processPools(size_t count = std::numeric_limits<size_t>::max()) const;
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx"> Vector<PluginModuleInfo> plugins() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -1063,6 +1063,9 @@
</span><span class="cx">                 51D124351E6DF652002B2820 /* WKURLSchemeHandlerTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D1242F1E6DDDD7002B2820 /* WKURLSchemeHandlerTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
</span><span class="cx">                 51D124361E6DFB39002B2820 /* WKURLSchemeHandlerTask.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124301E6DDDD7002B2820 /* WKURLSchemeHandlerTask.mm */; };
</span><span class="cx">                 51D1243A1E6E0AAB002B2820 /* APIURLSchemeHandlerTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D124381E6DFDB9002B2820 /* APIURLSchemeHandlerTask.cpp */; };
</span><ins>+                51D124911E74BF3C002B2820 /* APIHTTPCookieStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D124821E734AC8002B2820 /* APIHTTPCookieStorage.cpp */; };
+                51D124921E74BF48002B2820 /* WKHTTPCookieStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124851E734AE3002B2820 /* WKHTTPCookieStorage.mm */; };
+                51D124991E763C01002B2820 /* WKHTTPCookieStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D124841E734AE3002B2820 /* WKHTTPCookieStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 51D130531382EAC000351EDD /* SecItemRequestData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */; };
</span><span class="cx">                 51D130541382EAC000351EDD /* SecItemRequestData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D130501382EAC000351EDD /* SecItemRequestData.h */; };
</span><span class="cx">                 51D130551382EAC000351EDD /* SecItemResponseData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D130511382EAC000351EDD /* SecItemResponseData.cpp */; };
</span><span class="lines">@@ -3285,6 +3288,11 @@
</span><span class="cx">                 51D124371E6DFD2A002B2820 /* WKURLSchemeHandlerTaskInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeHandlerTaskInternal.h; sourceTree = "<group>"; };
</span><span class="cx">                 51D124381E6DFDB9002B2820 /* APIURLSchemeHandlerTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIURLSchemeHandlerTask.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51D124391E6DFDB9002B2820 /* APIURLSchemeHandlerTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIURLSchemeHandlerTask.h; sourceTree = "<group>"; };
</span><ins>+                51D124821E734AC8002B2820 /* APIHTTPCookieStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIHTTPCookieStorage.cpp; sourceTree = "<group>"; };
+                51D124831E734AC8002B2820 /* APIHTTPCookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIHTTPCookieStorage.h; sourceTree = "<group>"; };
+                51D124841E734AE3002B2820 /* WKHTTPCookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHTTPCookieStorage.h; sourceTree = "<group>"; };
+                51D124851E734AE3002B2820 /* WKHTTPCookieStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKHTTPCookieStorage.mm; sourceTree = "<group>"; };
+                51D124861E734AE3002B2820 /* WKHTTPCookieStorageInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHTTPCookieStorageInternal.h; sourceTree = "<group>"; };
</ins><span class="cx">                 51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemRequestData.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51D130501382EAC000351EDD /* SecItemRequestData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecItemRequestData.h; sourceTree = "<group>"; };
</span><span class="cx">                 51D130511382EAC000351EDD /* SecItemResponseData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemResponseData.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -5544,6 +5552,9 @@
</span><span class="cx">                                 1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */,
</span><span class="cx">                                 2DF9EEE71A78245500B6CFBE /* WKFrameInfoInternal.h */,
</span><span class="cx">                                 1A6FA21D1BD0435B00AAA650 /* WKFrameInfoPrivate.h */,
</span><ins>+                                51D124841E734AE3002B2820 /* WKHTTPCookieStorage.h */,
+                                51D124851E734AE3002B2820 /* WKHTTPCookieStorage.mm */,
+                                51D124861E734AE3002B2820 /* WKHTTPCookieStorageInternal.h */,
</ins><span class="cx">                                 1A422F8A18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h */,
</span><span class="cx">                                 1AB40EE31BF677E300BA81BE /* WKMenuItemIdentifiers.mm */,
</span><span class="cx">                                 1AB40EE41BF677E300BA81BE /* WKMenuItemIdentifiersPrivate.h */,
</span><span class="lines">@@ -6732,6 +6743,8 @@
</span><span class="cx">                                 2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */,
</span><span class="cx">                                 93A88B421BC8828C00ABA5C2 /* APIHitTestResult.cpp */,
</span><span class="cx">                                 93A88B431BC8828C00ABA5C2 /* APIHitTestResult.h */,
</span><ins>+                                51D124821E734AC8002B2820 /* APIHTTPCookieStorage.cpp */,
+                                51D124831E734AC8002B2820 /* APIHTTPCookieStorage.h */,
</ins><span class="cx">                                 5143B2611DDD0DA00014FAC6 /* APIIconLoadingClient.h */,
</span><span class="cx">                                 7CE4D2061A46775700C7F152 /* APILegacyContextHistoryClient.h */,
</span><span class="cx">                                 1A2464F21891E45100234C5B /* APILoaderClient.h */,
</span><span class="lines">@@ -8515,6 +8528,7 @@
</span><span class="cx">                                 514129941C6428BB0059E714 /* WebIDBConnectionToServer.h in Headers */,
</span><span class="cx">                                 510523741C73D38B007993CB /* WebIDBConnectionToServerMessages.h in Headers */,
</span><span class="cx">                                 BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */,
</span><ins>+                                51D124991E763C01002B2820 /* WKHTTPCookieStorage.h in Headers */,
</ins><span class="cx">                                 1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */,
</span><span class="cx">                                 BC032D8210F4378D0058C15A /* WebInspectorClient.h in Headers */,
</span><span class="cx">                                 A55BA8351BA3E70A007CD33D /* WebInspectorFrontendAPIDispatcher.h in Headers */,
</span><span class="lines">@@ -9767,6 +9781,7 @@
</span><span class="cx">                                 1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */,
</span><span class="cx">                                 1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */,
</span><span class="cx">                                 1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */,
</span><ins>+                                51D124921E74BF48002B2820 /* WKHTTPCookieStorage.mm in Sources */,
</ins><span class="cx">                                 1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
</span><span class="cx">                                 839A2F311E2067450039057E /* HighPerformanceGraphicsUsageSampler.cpp in Sources */,
</span><span class="cx">                                 1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
</span><span class="lines">@@ -9785,6 +9800,7 @@
</span><span class="cx">                                 831EEBBE1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.cpp in Sources */,
</span><span class="cx">                                 832AE2531BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.cpp in Sources */,
</span><span class="cx">                                 83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */,
</span><ins>+                                51D124911E74BF3C002B2820 /* APIHTTPCookieStorage.cpp in Sources */,
</ins><span class="cx">                                 E4436ED01A0D040B00EAD204 /* NetworkCacheStorage.cpp in Sources */,
</span><span class="cx">                                 8310428C1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp in Sources */,
</span><span class="cx">                                 5302583D1DCBBD2200DA89C2 /* NetworkCaptureEvent.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessCookiesWebCookieManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> WebCore::deleteCookiesForHostnames(*storageSession, { hostname });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> void WebCookieManager::deleteAllCookies(SessionID sessionID)
</span><span class="cx"> {
</span><span class="cx"> if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
</span><span class="lines">@@ -78,16 +79,57 @@
</span><span class="cx"> WebCore::deleteAllCookies(*storageSession);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManager::deleteAllCookiesModifiedSince(SessionID sessionID, std::chrono::system_clock::time_point time)
</del><ins>+void WebCookieManager::deleteCookie(SessionID sessionID, const Cookie& cookie, uint64_t callbackID)
</ins><span class="cx"> {
</span><span class="cx"> if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
</span><ins>+ storageSession->deleteCookie(cookie);
+
+ m_process->send(Messages::WebCookieManagerProxy::DidDeleteCookies(callbackID), 0);
+}
+
+void WebCookieManager::deleteAllCookiesModifiedSince(SessionID sessionID, std::chrono::system_clock::time_point time, uint64_t callbackID)
+{
+ if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
</ins><span class="cx"> WebCore::deleteAllCookiesModifiedSince(*storageSession, time);
</span><ins>+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidDeleteCookies(callbackID), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManager::setCookies(WebCore::SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL)
</del><ins>+void WebCookieManager::getAllCookies(SessionID sessionID, uint64_t callbackID)
</ins><span class="cx"> {
</span><ins>+ Vector<Cookie> cookies;
</ins><span class="cx"> if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
</span><ins>+ cookies = storageSession->getAllCookies();
+
+ m_process->send(Messages::WebCookieManagerProxy::DidGetCookies(cookies, callbackID), 0);
+}
+
+void WebCookieManager::getCookies(SessionID sessionID, const URL& url, uint64_t callbackID)
+{
+ Vector<Cookie> cookies;
+ if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
+ cookies = storageSession->getCookies(url);
+
+ m_process->send(Messages::WebCookieManagerProxy::DidGetCookies(cookies, callbackID), 0);
+}
+
+void WebCookieManager::setCookie(WebCore::SessionID sessionID, const Cookie& cookie, uint64_t callbackID)
+{
+ if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
+ storageSession->setCookie(cookie);
+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidSetCookies(callbackID), 0);
+}
+
+void WebCookieManager::setCookies(WebCore::SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL, uint64_t callbackID)
+{
+ if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
</ins><span class="cx"> storageSession->setCookies(cookies, url, mainDocumentURL);
</span><ins>+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidSetCookies(callbackID), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebCookieManager::notifyCookiesDidChange(SessionID sessionID)
</span><span class="lines">@@ -111,9 +153,12 @@
</span><span class="cx"> WebCore::stopObservingCookieChanges(*storageSession);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
</del><ins>+void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, uint64_t callbackID)
</ins><span class="cx"> {
</span><span class="cx"> platformSetHTTPCookieAcceptPolicy(policy);
</span><ins>+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidSetHTTPCookieAcceptPolicy(callbackID), 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebCookieManager::getHTTPCookieAcceptPolicy(uint64_t callbackID)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessCookiesWebCookieManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -56,7 +56,8 @@
</span><span class="cx">
</span><span class="cx"> static const char* supplementName();
</span><span class="cx">
</span><del>- void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
</del><ins>+ void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy, uint64_t callbackID);
+
</ins><span class="cx"> #if USE(SOUP)
</span><span class="cx"> void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
</span><span class="cx"> #endif
</span><span class="lines">@@ -68,11 +69,16 @@
</span><span class="cx"> void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
</span><span class="cx">
</span><span class="cx"> void getHostnamesWithCookies(WebCore::SessionID, uint64_t callbackID);
</span><ins>+
+ void deleteCookie(WebCore::SessionID, const WebCore::Cookie&, uint64_t callbackID);
</ins><span class="cx"> void deleteCookiesForHostname(WebCore::SessionID, const String&);
</span><span class="cx"> void deleteAllCookies(WebCore::SessionID);
</span><del>- void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point);
</del><ins>+ void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point, uint64_t callbackID);
</ins><span class="cx">
</span><del>- void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL);
</del><ins>+ void setCookie(WebCore::SessionID, const WebCore::Cookie&, uint64_t callbackID);
+ void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL, uint64_t callbackID);
+ void getAllCookies(WebCore::SessionID, uint64_t callbackID);
+ void getCookies(WebCore::SessionID, const WebCore::URL&, uint64_t callbackID);
</ins><span class="cx">
</span><span class="cx"> void platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
</span><span class="cx"> void getHTTPCookieAcceptPolicy(uint64_t callbackID);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessCookiesWebCookieManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -27,11 +27,15 @@
</span><span class="cx"> void GetHostnamesWithCookies(WebCore::SessionID sessionID, uint64_t callbackID)
</span><span class="cx"> void DeleteCookiesForHostname(WebCore::SessionID sessionID, String hostname)
</span><span class="cx"> void DeleteAllCookies(WebCore::SessionID sessionID)
</span><del>- void DeleteAllCookiesModifiedSince(WebCore::SessionID sessionID, std::chrono::system_clock::time_point time)
</del><span class="cx">
</span><del>- void SetCookies(WebCore::SessionID sessionID, Vector<WebCore::Cookie> cookies, WebCore::URL url, WebCore::URL mainDocumentURL);
</del><ins>+ void SetCookie(WebCore::SessionID sessionID, struct WebCore::Cookie cookie, uint64_t callbackID)
+ void SetCookies(WebCore::SessionID sessionID, Vector<WebCore::Cookie> cookies, WebCore::URL url, WebCore::URL mainDocumentURL, uint64_t callbackID)
+ void GetAllCookies(WebCore::SessionID sessionID, uint64_t callbackID)
+ void GetCookies(WebCore::SessionID sessionID, WebCore::URL url, uint64_t callbackID)
+ void DeleteCookie(WebCore::SessionID sessionID, struct WebCore::Cookie cookie, uint64_t callbackID)
+ void DeleteAllCookiesModifiedSince(WebCore::SessionID sessionID, std::chrono::system_clock::time_point time, uint64_t callbackID)
</ins><span class="cx">
</span><del>- void SetHTTPCookieAcceptPolicy(uint32_t policy)
</del><ins>+ void SetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID)
</ins><span class="cx"> void GetHTTPCookieAcceptPolicy(uint64_t callbackID)
</span><span class="cx">
</span><span class="cx"> void StartObservingCookieChanges(WebCore::SessionID sessionID)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Tools/ChangeLog        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-03-13 Brady Eidson <beidson@apple.com>
+
+ WKWebView provides no access to cookies.
+ https://bugs.webkit.org/show_bug.cgi?id=140191
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2017-03-13 Carlos Alberto Lopez Perez <clopez@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] install-dependencies needs to install Perl CGI modules on Debian based distros
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (213876 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx">                 51BCEE4F1C84F53B0042C82E /* IndexedDBMultiProcess-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */; };
</span><span class="cx">                 51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */; };
</span><span class="cx">                 51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */; };
</span><ins>+                51D124981E763B02002B2820 /* WKHTTPCookieStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124971E763AF8002B2820 /* WKHTTPCookieStorage.mm */; };
</ins><span class="cx">                 51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
</span><span class="cx">                 51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780371919AFF8001829A2 /* simple3.html */; };
</span><span class="cx">                 51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */; };
</span><span class="lines">@@ -1048,6 +1049,7 @@
</span><span class="cx">                 51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModalAlertsSPI.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModalAlerts.mm; sourceTree = "<group>"; };
</span><span class="cx">                 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "modal-alerts-in-new-about-blank-window.html"; sourceTree = "<group>"; };
</span><ins>+                51D124971E763AF8002B2820 /* WKHTTPCookieStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKHTTPCookieStorage.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageClear.mm; sourceTree = "<group>"; };
</span><span class="cx">                 51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageClear.html; sourceTree = "<group>"; };
</span><span class="lines">@@ -1649,6 +1651,7 @@
</span><span class="cx">                                 5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */,
</span><span class="cx">                                 5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */,
</span><span class="cx">                                 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */,
</span><ins>+                                51D124971E763AF8002B2820 /* WKHTTPCookieStorage.mm */,
</ins><span class="cx">                                 375E0E151D66674400EFEC2C /* WKNSNumber.mm */,
</span><span class="cx">                                 37B47E2E1D64E7CA005F4EFF /* WKObject.mm */,
</span><span class="cx">                                 2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */,
</span><span class="lines">@@ -2729,6 +2732,7 @@
</span><span class="cx">                                 7CCE7EF41A411AE600447C4C /* FindMatches.mm in Sources */,
</span><span class="cx">                                 7C83E0401D0A63E300FEBCF3 /* FirstResponderScrollingPosition.mm in Sources */,
</span><span class="cx">                                 7C83E0BC1D0A650700FEBCF3 /* FixedLayoutSize.mm in Sources */,
</span><ins>+                                51D124981E763B02002B2820 /* WKHTTPCookieStorage.mm in Sources */,
</ins><span class="cx">                                 7CCE7EF51A411AE600447C4C /* ForceRepaint.cpp in Sources */,
</span><span class="cx">                                 37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */,
</span><span class="cx">                                 7CCE7EC01A411A7E00447C4C /* FragmentNavigation.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaWKHTTPCookieStoragemm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKHTTPCookieStorage.mm (0 => 213877)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKHTTPCookieStorage.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKHTTPCookieStorage.mm        2017-03-13 23:00:49 UTC (rev 213877)
</span><span class="lines">@@ -0,0 +1,119 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKFoundation.h>
+#import <WebKit/WKHTTPCookieStorage.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <wtf/RetainPtr.h>
+
+#if WK_API_ENABLED
+
+static bool gotFlag;
+
+TEST(WebKit2, WKHTTPCookieStorage)
+{
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+ [webView loadHTMLString:@"Oh hello" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+
+ RetainPtr<WKHTTPCookieStorage> cookieStorage = [WKWebsiteDataStore defaultDataStore]._httpCookieStorage;
+
+ NSArray<NSHTTPCookie *> *cookies = nil;
+ [cookieStorage fetchCookies:[cookiesPtr = &cookies](NSArray<NSHTTPCookie *> *nsCookies) {
+ *cookiesPtr = [nsCookies retain];
+ gotFlag = true;
+ }];
+
+ TestWebKitAPI::Util::run(&gotFlag);
+
+ ASSERT_EQ(cookies.count, 0u);
+ [cookies release];
+
+ gotFlag = false;
+
+ RetainPtr<NSHTTPCookie> cookie1 = [NSHTTPCookie cookieWithProperties:@{
+ NSHTTPCookiePath: @"/",
+ NSHTTPCookieName: @"CookieName",
+ NSHTTPCookieValue: @"CookieValue",
+ NSHTTPCookieDomain: @".www.webkit.org",
+ NSHTTPCookieSecure: @"TRUE",
+ NSHTTPCookieDiscard: @"TRUE",
+ NSHTTPCookieMaximumAge: @"10000",
+ }];
+
+ RetainPtr<NSHTTPCookie> cookie2 = [NSHTTPCookie cookieWithProperties:@{
+ NSHTTPCookiePath: @"/path",
+ NSHTTPCookieName: @"OtherCookieName",
+ NSHTTPCookieValue: @"OtherCookieValue",
+ NSHTTPCookieDomain: @".www.w3c.org",
+ NSHTTPCookieMaximumAge: @"10000",
+ }];
+
+ [cookieStorage setCookie:cookie1.get() completionHandler:[](){
+ gotFlag = true;
+ }];
+
+ TestWebKitAPI::Util::run(&gotFlag);
+ gotFlag = false;
+
+ [cookieStorage setCookie:cookie2.get() completionHandler:[](){
+ gotFlag = true;
+ }];
+
+ TestWebKitAPI::Util::run(&gotFlag);
+ gotFlag = false;
+
+ [cookieStorage fetchCookies:[cookiesPtr = &cookies](NSArray<NSHTTPCookie *> *nsCookies) {
+ *cookiesPtr = [nsCookies retain];
+ gotFlag = true;
+ }];
+
+ TestWebKitAPI::Util::run(&gotFlag);
+
+ ASSERT_EQ(cookies.count, 2u);
+
+ for (NSHTTPCookie *cookie : cookies) {
+ if ([cookie.name isEqual:@"CookieName"]) {
+ ASSERT_TRUE([cookie1.get().path isEqualToString:cookie.path]);
+ ASSERT_TRUE([cookie1.get().value isEqualToString:cookie.value]);
+ ASSERT_TRUE([cookie1.get().domain isEqualToString:cookie.domain]);
+ ASSERT_TRUE(cookie1.get().secure);
+ ASSERT_TRUE(cookie1.get().sessionOnly);
+ } else {
+ ASSERT_TRUE([cookie2.get().path isEqualToString:cookie.path]);
+ ASSERT_TRUE([cookie2.get().value isEqualToString:cookie.value]);
+ ASSERT_TRUE([cookie2.get().name isEqualToString:cookie.name]);
+ ASSERT_TRUE([cookie2.get().domain isEqualToString:cookie.domain]);
+ ASSERT_FALSE(cookie2.get().secure);
+ ASSERT_FALSE(cookie2.get().sessionOnly);
+ }
+ }
+
+ [cookies release];
+}
+
+#endif
</ins></span></pre>
</div>
</div>
</body>
</html>