Diff
Modified: trunk/Source/WebCore/ChangeLog (213876 => 213877)
--- 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)
@@ -1,3 +1,27 @@
+2017-03-13 Brady Eidson <[email protected]>
+
+ 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):
+
2017-03-13 Devin Rousso <[email protected]>
Web Inspector: Event Listeners section is missing 'once', 'passive' event listener flags
Modified: trunk/Source/WebCore/platform/Cookie.h (213876 => 213877)
--- 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)
@@ -58,7 +58,7 @@
#ifdef __OBJC__
WEBCORE_EXPORT Cookie(NSHTTPCookie *);
- operator NSHTTPCookie *() const;
+ WEBCORE_EXPORT operator NSHTTPCookie *() const;
#endif
String name;
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (213876 => 213877)
--- 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)
@@ -100,7 +100,11 @@
NetworkingContext* context() const;
#endif
+ WEBCORE_EXPORT void setCookie(const Cookie&);
WEBCORE_EXPORT void setCookies(const Vector<Cookie>&, const URL&, const URL& mainDocumentURL);
+ WEBCORE_EXPORT void deleteCookie(const Cookie&);
+ WEBCORE_EXPORT Vector<Cookie> getAllCookies();
+ WEBCORE_EXPORT Vector<Cookie> getCookies(const URL&);
private:
static HashMap<SessionID, std::unique_ptr<NetworkStorageSession>>& globalSessionMap();
Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm (213876 => 213877)
--- 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)
@@ -32,6 +32,13 @@
namespace WebCore {
+void NetworkStorageSession::setCookie(const Cookie& cookie)
+{
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [nsCookieStorage() setCookie:(NSHTTPCookie *)cookie];
+ END_BLOCK_OBJC_EXCEPTIONS;
+}
+
void NetworkStorageSession::setCookies(const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL)
{
RetainPtr<NSMutableArray> nsCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:cookies.size()]);
@@ -43,6 +50,31 @@
END_BLOCK_OBJC_EXCEPTIONS;
}
+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]);
+}
+
NSHTTPCookieStorage *NetworkStorageSession::nsCookieStorage() const
{
auto cfCookieStorage = cookieStorage();
Modified: trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp (213876 => 213877)
--- 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)
@@ -304,7 +304,21 @@
soup_cookie_jar_add_cookie(cookieStorage(), toSoupCookie(cookie));
}
+void NetworkStorageSession::deleteCookie(const Cookie&)
+{
+ // FIXME: Implement for WK2 to use.
+}
+Vector<Cookie> NetworkStorageSession::getAllCookies()
+{
+ // FIXME: Implement for WK2 to use.
+}
+
+Vector<Cookie> NetworkStorageSession::getCookies(const URL&)
+{
+ // FIXME: Implement for WK2 to use.
+}
+
} // namespace WebCore
#endif // USE(SOUP)
Modified: trunk/Source/WebKit2/CMakeLists.txt (213876 => 213877)
--- 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)
@@ -333,6 +333,7 @@
UIProcess/API/APIContentExtensionStore.cpp
UIProcess/API/APIExperimentalFeature.cpp
UIProcess/API/APIFrameInfo.cpp
+ UIProcess/API/APIHTTPCookieStorage.cpp
UIProcess/API/APIHitTestResult.cpp
UIProcess/API/APINavigation.cpp
UIProcess/API/APINavigationData.cpp
Modified: trunk/Source/WebKit2/ChangeLog (213876 => 213877)
--- 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)
@@ -1,3 +1,118 @@
+2017-03-13 Brady Eidson <[email protected]>
+
+ 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:
+
2017-03-13 John Wilander <[email protected]>
Resource Load Statistics: More efficient network process messaging + Fix bug in user interaction reporting
Modified: trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp (213876 => 213877)
--- 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)
@@ -124,7 +124,7 @@
supplement<WebCookieManager>()->setCookiePersistentStorage(parameters.cookiePersistentStoragePath,
parameters.cookiePersistentStorageType);
}
- supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy);
+ supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy, 0);
if (!parameters.languages.isEmpty())
userPreferredLanguagesChanged(parameters.languages);
Modified: trunk/Source/WebKit2/Shared/API/APIObject.h (213876 => 213877)
--- 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)
@@ -116,6 +116,7 @@
FullScreenManager,
GeolocationManager,
GeolocationPermissionRequest,
+ HTTPCookieStorage,
HitTestResult,
GeolocationPosition,
GrammarDetail,
Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (213876 => 213877)
--- 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)
@@ -36,6 +36,7 @@
#import "WKContentExtensionInternal.h"
#import "WKContentExtensionStoreInternal.h"
#import "WKFrameInfoInternal.h"
+#import "WKHTTPCookieStorageInternal.h"
#import "WKNSArray.h"
#import "WKNSData.h"
#import "WKNSDictionary.h"
@@ -178,6 +179,10 @@
wrapper = [WKFrameInfo alloc];
break;
+ case Type::HTTPCookieStorage:
+ wrapper = [WKHTTPCookieStorage alloc];
+ break;
+
#if PLATFORM(MAC)
case Type::HitTestResult:
wrapper = [_WKHitTestResult alloc];
Added: trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.cpp (0 => 213877)
--- 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)
@@ -0,0 +1,138 @@
+/*
+ * 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
Added: trunk/Source/WebKit2/UIProcess/API/APIHTTPCookieStorage.h (0 => 213877)
--- 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)
@@ -0,0 +1,69 @@
+/*
+ * 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;
+};
+
+}
Modified: trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp (213876 => 213877)
--- 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)
@@ -31,13 +31,13 @@
namespace API {
-RefPtr<WebsiteDataStore> WebsiteDataStore::defaultDataStore()
+Ref<WebsiteDataStore> WebsiteDataStore::defaultDataStore()
{
WebKit::InitializeWebKit2();
static WebsiteDataStore* defaultDataStore = adoptRef(new WebsiteDataStore(defaultDataStoreConfiguration())).leakRef();
- return defaultDataStore;
+ return *defaultDataStore;
}
Ref<WebsiteDataStore> WebsiteDataStore::createNonPersistentDataStore()
@@ -64,6 +64,14 @@
{
}
+HTTPCookieStorage& WebsiteDataStore::httpCookieStorage()
+{
+ if (!m_apiHTTPCookieStorage)
+ m_apiHTTPCookieStorage = HTTPCookieStorage::create(*this);
+
+ return *m_apiHTTPCookieStorage;
+}
+
bool WebsiteDataStore::isPersistent()
{
return m_websiteDataStore->isPersistent();
Modified: trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h (213876 => 213877)
--- 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)
@@ -26,7 +26,7 @@
#ifndef APIWebsiteDataStore_h
#define APIWebsiteDataStore_h
-#include "APIObject.h"
+#include "APIHTTPCookieStorage.h"
#include "WebsiteDataStore.h"
#include <WebCore/SessionID.h>
#include <wtf/text/WTFString.h>
@@ -35,7 +35,7 @@
class WebsiteDataStore final : public ObjectImpl<Object::Type::WebsiteDataStore> {
public:
- static RefPtr<WebsiteDataStore> defaultDataStore();
+ static Ref<WebsiteDataStore> defaultDataStore();
static Ref<WebsiteDataStore> createNonPersistentDataStore();
static Ref<WebsiteDataStore> create(WebKit::WebsiteDataStore::Configuration);
@@ -49,6 +49,7 @@
void registerSharedResourceLoadObserver();
WebKit::WebsiteDataStore& websiteDataStore() { return *m_websiteDataStore; }
+ HTTPCookieStorage& httpCookieStorage();
static String defaultApplicationCacheDirectory();
static String defaultNetworkCacheDirectory();
@@ -74,6 +75,7 @@
static String websiteDataDirectoryFileSystemRepresentation(const String& directoryName);
RefPtr<WebKit::WebsiteDataStore> m_websiteDataStore;
+ RefPtr<HTTPCookieStorage> m_apiHTTPCookieStorage;
};
}
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp (213876 => 213877)
--- 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)
@@ -61,17 +61,17 @@
using namespace std::chrono;
auto time = system_clock::time_point(duration_cast<system_clock::duration>(duration<double>(date)));
- toImpl(cookieManagerRef)->deleteAllCookiesModifiedSince(WebCore::SessionID::defaultSessionID(), time);
+ toImpl(cookieManagerRef)->deleteAllCookiesModifiedSince(WebCore::SessionID::defaultSessionID(), time, [](CallbackBase::Error){});
}
void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy)
{
- toImpl(cookieManager)->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+ toImpl(cookieManager)->setHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [](CallbackBase::Error){});
}
void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback)
{
- toImpl(cookieManager)->getHTTPCookieAcceptPolicy(toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(context, callback));
+ toImpl(cookieManager)->getHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(context, callback));
}
void WKCookieManagerSetCookieStoragePartitioningEnabled(WKCookieManagerRef cookieManager, bool enabled)
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (213876 => 213877)
--- 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)
@@ -37,7 +37,7 @@
WKWebsiteDataStoreRef WKWebsiteDataStoreGetDefaultDataStore()
{
- return WebKit::toAPI(API::WebsiteDataStore::defaultDataStore().get());
+ return WebKit::toAPI(API::WebsiteDataStore::defaultDataStore().ptr());
}
WKWebsiteDataStoreRef WKWebsiteDataStoreCreateNonPersistentDataStore()
Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.h (0 => 213877)
--- 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)
@@ -0,0 +1,92 @@
+/*
+ * 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
Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorage.mm (0 => 213877)
--- 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)
@@ -0,0 +1,161 @@
+/*
+ * 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
Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKHTTPCookieStorageInternal.h (from rev 213876, trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h) (0 => 213877)
--- 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)
@@ -0,0 +1,49 @@
+/*
+ * 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
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm (213876 => 213877)
--- 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)
@@ -196,7 +196,7 @@
- (void)_setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
{
- _processPool->supplement<WebKit::WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+ _processPool->supplement<WebKit::WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [](WebKit::CallbackBase::Error){});
}
- (id)_objectForBundleParameter:(NSString *)parameter
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (213876 => 213877)
--- 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)
@@ -28,6 +28,7 @@
#if WK_API_ENABLED
+#import "WKHTTPCookieStorageInternal.h"
#import "WKNSArray.h"
#import "WKWebsiteDataRecordInternal.h"
#import "WebsiteDataFetchOption.h"
@@ -38,7 +39,7 @@
+ (WKWebsiteDataStore *)defaultDataStore
{
- return WebKit::wrapper(*API::WebsiteDataStore::defaultDataStore().get());
+ return WebKit::wrapper(API::WebsiteDataStore::defaultDataStore().get());
}
+ (WKWebsiteDataStore *)nonPersistentDataStore
@@ -194,6 +195,11 @@
_websiteDataStore->websiteDataStore().setResourceLoadStatisticsEnabled(enabled);
}
+- (WKHTTPCookieStorage *)_httpCookieStorage
+{
+ return WebKit::wrapper(_websiteDataStore->httpCookieStorage());
+}
+
@end
#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (213876 => 213877)
--- 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)
@@ -29,6 +29,7 @@
NS_ASSUME_NONNULL_BEGIN
+@class WKHTTPCookieStorage;
@class _WKWebsiteDataStoreConfiguration;
typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) {
@@ -43,6 +44,9 @@
@property (nonatomic, setter=_setResourceLoadStatisticsEnabled:) BOOL _resourceLoadStatisticsEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0));
+/*! @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));
+
@end
NS_ASSUME_NONNULL_END
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitCookieManager.cpp (213876 => 213877)
--- 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)
@@ -27,6 +27,7 @@
#include "WebKitWebsiteDataManagerPrivate.h"
#include "WebKitWebsiteDataPrivate.h"
#include "WebsiteDataRecord.h"
+#include <WebCore/SessionID.h>
#include <wtf/glib/GRefPtr.h>
#include <wtf/text/CString.h>
@@ -178,7 +179,7 @@
g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));
for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager))
- processPool->supplement<WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+ processPool->supplement<WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [](CallbackBase::Error){});
}
static void webkitCookieManagerGetAcceptPolicyCallback(WKHTTPCookieAcceptPolicy policy, WKErrorRef, void* context)
@@ -212,7 +213,7 @@
return;
}
- processPools[0]->supplement<WebCookieManagerProxy>()->getHTTPCookieAcceptPolicy(
+ processPools[0]->supplement<WebCookieManagerProxy>()->getHTTPCookieAcceptPolicy(WebCore::SessionID::defaultSessionID(),
toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(task.leakRef(), webkitCookieManagerGetAcceptPolicyCallback));
}
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (213876 => 213877)
--- 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)
@@ -734,7 +734,7 @@
// FIXME: Using activeURL here twice is basically saying "this is always in the context of the main document"
// which probably isn't accurate.
- cookieManager->setCookies(WebCore::SessionID::defaultSessionID(), { cookie }, activeURL, activeURL);
+ cookieManager->setCookies(WebCore::SessionID::defaultSessionID(), { cookie }, activeURL, activeURL, [](CallbackBase::Error){});
callback->sendSuccess();
}
Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp (213876 => 213877)
--- 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)
@@ -32,8 +32,11 @@
#include "WebCookieManagerMessages.h"
#include "WebCookieManagerProxyMessages.h"
#include "WebProcessPool.h"
+#include <WebCore/Cookie.h>
#include <WebCore/SecurityOriginData.h>
+using namespace WebCore;
+
namespace WebKit {
const char* WebCookieManagerProxy::supplementName()
@@ -94,7 +97,7 @@
API::Object::deref();
}
-void WebCookieManagerProxy::getHostnamesWithCookies(WebCore::SessionID sessionID, Function<void (API::Array*, CallbackBase::Error)>&& callbackFunction)
+void WebCookieManagerProxy::getHostnamesWithCookies(SessionID sessionID, Function<void (API::Array*, CallbackBase::Error)>&& callbackFunction)
{
auto callback = ArrayCallback::create(WTFMove(callbackFunction));
uint64_t callbackID = callback->callbackID();
@@ -114,37 +117,96 @@
callback->performCallbackWithReturnValue(API::Array::createStringArray(hostnames).ptr());
}
-void WebCookieManagerProxy::deleteCookiesForHostname(WebCore::SessionID sessionID, const String& hostname)
+void WebCookieManagerProxy::deleteCookiesForHostname(SessionID sessionID, const String& hostname)
{
processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteCookiesForHostname(sessionID, hostname));
}
-void WebCookieManagerProxy::deleteAllCookies(WebCore::SessionID sessionID)
+void WebCookieManagerProxy::deleteAllCookies(SessionID sessionID)
{
processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookies(sessionID));
}
-void WebCookieManagerProxy::deleteAllCookiesModifiedSince(WebCore::SessionID sessionID, std::chrono::system_clock::time_point time)
+void WebCookieManagerProxy::deleteCookie(SessionID sessionID, const Cookie& cookie, Function<void (CallbackBase::Error)>&& callbackFunction)
{
- processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookiesModifiedSince(sessionID, time));
+ 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));
}
-void WebCookieManagerProxy::setCookies(WebCore::SessionID sessionID, const Vector<WebCore::Cookie>& cookies, const WebCore::URL& url, const WebCore::URL& mainDocumentURL)
+void WebCookieManagerProxy::deleteAllCookiesModifiedSince(SessionID sessionID, std::chrono::system_clock::time_point time, Function<void (CallbackBase::Error)>&& callbackFunction)
{
- processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetCookies(sessionID, cookies, url, mainDocumentURL));
+ 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));
}
-void WebCookieManagerProxy::startObservingCookieChanges(WebCore::SessionID sessionID)
+void WebCookieManagerProxy::setCookie(SessionID sessionID, const Cookie& cookie, 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::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)
+{
processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::StartObservingCookieChanges(sessionID));
}
-void WebCookieManagerProxy::stopObservingCookieChanges(WebCore::SessionID sessionID)
+void WebCookieManagerProxy::stopObservingCookieChanges(SessionID sessionID)
{
processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::StopObservingCookieChanges(sessionID));
}
-void WebCookieManagerProxy::setCookieObserverCallback(WebCore::SessionID sessionID, std::function<void ()>&& callback)
+void WebCookieManagerProxy::setCookieObserverCallback(SessionID sessionID, std::function<void ()>&& callback)
{
if (callback)
m_cookieObservers.set(sessionID, WTFMove(callback));
@@ -152,7 +214,7 @@
m_cookieObservers.remove(sessionID);
}
-void WebCookieManagerProxy::cookiesDidChange(WebCore::SessionID sessionID)
+void WebCookieManagerProxy::cookiesDidChange(SessionID sessionID)
{
m_client.cookiesDidChange(this);
if (auto callback = m_cookieObservers.get(sessionID))
@@ -159,7 +221,7 @@
callback();
}
-void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(SessionID, HTTPCookieAcceptPolicy policy, Function<void (CallbackBase::Error)>&& callbackFunction)
{
#if PLATFORM(COCOA)
if (!processPool()->isUsingTestingNetworkSession())
@@ -172,11 +234,16 @@
// The policy is not sent to newly created processes (only Soup does that via setInitialHTTPCookieAcceptPolicy()). This is not a serious problem, because:
// - When testing, we only have one WebProcess and one NetworkProcess, and WebKitTestRunner never restarts them;
// - When not testing, Cocoa has the policy persisted, and thus new processes use it (even for ephemeral sessions).
- processPool()->sendToAllProcesses(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
- processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
+ 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));
}
-void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)> callbackFunction)
+void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(SessionID, Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>&& callbackFunction)
{
auto callback = HTTPCookieAcceptPolicyCallback::create(WTFMove(callbackFunction));
@@ -188,13 +255,12 @@
void WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID)
{
- RefPtr<HTTPCookieAcceptPolicyCallback> callback = m_httpCookieAcceptPolicyCallbacks.take(callbackID);
- if (!callback) {
- // FIXME: Log error or assert.
- return;
- }
+ m_httpCookieAcceptPolicyCallbacks.take(callbackID)->performCallbackWithReturnValue(policy);
+}
- callback->performCallbackWithReturnValue(policy);
+void WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy(uint64_t callbackID)
+{
+ m_voidCallbacks.take(callbackID)->performCallback();
}
void WebCookieManagerProxy::setCookieStoragePartitioningEnabled(bool enabled)
Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.h (213876 => 213877)
--- 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)
@@ -55,6 +55,7 @@
typedef GenericCallback<API::Array*> ArrayCallback;
typedef GenericCallback<HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
+typedef GenericCallback<const Vector<WebCore::Cookie>&> GetCookiesCallback;
class WebCookieManagerProxy : public API::ObjectImpl<API::Object::Type::CookieManager>, public WebContextSupplement, private IPC::MessageReceiver {
public:
@@ -66,14 +67,20 @@
void initializeClient(const WKCookieManagerClientBase*);
void getHostnamesWithCookies(WebCore::SessionID, Function<void (API::Array*, CallbackBase::Error)>&&);
+ void deleteCookie(WebCore::SessionID, const WebCore::Cookie&, Function<void (CallbackBase::Error)>&&);
void deleteCookiesForHostname(WebCore::SessionID, const String& hostname);
void deleteAllCookies(WebCore::SessionID);
- void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point);
+ void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point, Function<void (CallbackBase::Error)>&&);
- void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL);
+ 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)>&&);
- void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
- void getHTTPCookieAcceptPolicy(Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>);
+ 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)>&&);
+
void setCookieStoragePartitioningEnabled(bool);
void startObservingCookieChanges(WebCore::SessionID);
@@ -95,6 +102,11 @@
void didGetHostnamesWithCookies(const Vector<String>&, uint64_t callbackID);
void didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID);
+ void didSetHTTPCookieAcceptPolicy(uint64_t callbackID);
+ void didSetCookies(uint64_t callbackID);
+ void didGetCookies(const Vector<WebCore::Cookie>&, uint64_t callbackID);
+ void didDeleteCookies(uint64_t callbackID);
+
void cookiesDidChange(WebCore::SessionID);
// WebContextSupplement
@@ -113,6 +125,8 @@
HashMap<uint64_t, RefPtr<ArrayCallback>> m_arrayCallbacks;
HashMap<uint64_t, RefPtr<HTTPCookieAcceptPolicyCallback>> m_httpCookieAcceptPolicyCallbacks;
+ HashMap<uint64_t, RefPtr<VoidCallback>> m_voidCallbacks;
+ HashMap<uint64_t, RefPtr<GetCookiesCallback>> m_getCookiesCallbacks;
HashMap<WebCore::SessionID, std::function<void ()>> m_cookieObservers;
Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in (213876 => 213877)
--- 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)
@@ -23,6 +23,11 @@
messages -> WebCookieManagerProxy {
DidGetHostnamesWithCookies(Vector<String> hostnames, uint64_t callbackID);
DidGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID);
-
+
+ DidSetHTTPCookieAcceptPolicy(uint64_t callbackID);
+ DidDeleteCookies(uint64_t callbackID);
+ DidSetCookies(uint64_t callbackID);
+ DidGetCookies(Vector<WebCore::Cookie> cookies, uint64_t callbackID);
+
CookiesDidChange(WebCore::SessionID sessionID)
}
Modified: trunk/Source/WebKit2/UIProcess/WebFrameProxy.h (213876 => 213877)
--- 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)
@@ -31,6 +31,7 @@
#include "WebFrameListenerProxy.h"
#include <WebCore/FrameLoaderTypes.h>
#include <wtf/Forward.h>
+#include <wtf/Function.h>
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (213876 => 213877)
--- 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)
@@ -30,6 +30,7 @@
#include "APIAutomationClient.h"
#include "APICustomProtocolManagerClient.h"
#include "APIDownloadClient.h"
+#include "APIHTTPCookieStorage.h"
#include "APILegacyContextHistoryClient.h"
#include "APIPageConfiguration.h"
#include "APIProcessPoolConfiguration.h"
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (213876 => 213877)
--- 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)
@@ -76,6 +76,7 @@
class AutomationClient;
class CustomProtocolManagerClient;
class DownloadClient;
+class HTTPCookieStorage;
class LegacyContextHistoryClient;
class PageConfiguration;
}
Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (213876 => 213877)
--- 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)
@@ -30,6 +30,7 @@
#include "APIWebsiteDataRecord.h"
#include "NetworkProcessMessages.h"
#include "StorageManager.h"
+#include "WebCookieManagerProxy.h"
#include "WebProcessMessages.h"
#include "WebProcessPool.h"
#include "WebResourceLoadStatisticsStore.h"
@@ -105,6 +106,27 @@
}
}
+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();
+}
+
void WebsiteDataStore::resolveDirectoriesIfNecessary()
{
if (m_hasResolvedDirectories)
@@ -1108,7 +1130,7 @@
m_storageManager->processDidCloseConnection(webProcessProxy, connection);
}
-HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools() const
+HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools(size_t count) const
{
HashSet<RefPtr<WebProcessPool>> processPools;
for (auto& process : processes())
@@ -1122,11 +1144,20 @@
processPools.add(processPool);
break;
}
+ } 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);
}
+
+ if (processPools.size() == count)
+ break;
}
}
- if (processPools.isEmpty()) {
+ if (processPools.isEmpty() && count) {
auto processPool = WebProcessPool::create(API::ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration(m_configuration));
processPools.add(processPool.ptr());
}
Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (213876 => 213877)
--- 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)
@@ -103,6 +103,8 @@
StorageManager* storageManager() { return m_storageManager.get(); }
+ Ref<WebProcessPool> processPoolForCookieStorageOperations();
+
private:
explicit WebsiteDataStore(WebCore::SessionID);
explicit WebsiteDataStore(Configuration);
@@ -119,7 +121,7 @@
void platformDestroy();
static void platformRemoveRecentSearches(std::chrono::system_clock::time_point);
- HashSet<RefPtr<WebProcessPool>> processPools() const;
+ HashSet<RefPtr<WebProcessPool>> processPools(size_t count = std::numeric_limits<size_t>::max()) const;
#if ENABLE(NETSCAPE_PLUGIN_API)
Vector<PluginModuleInfo> plugins() const;
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (213876 => 213877)
--- 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)
@@ -1063,6 +1063,9 @@
51D124351E6DF652002B2820 /* WKURLSchemeHandlerTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D1242F1E6DDDD7002B2820 /* WKURLSchemeHandlerTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
51D124361E6DFB39002B2820 /* WKURLSchemeHandlerTask.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124301E6DDDD7002B2820 /* WKURLSchemeHandlerTask.mm */; };
51D1243A1E6E0AAB002B2820 /* APIURLSchemeHandlerTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D124381E6DFDB9002B2820 /* APIURLSchemeHandlerTask.cpp */; };
+ 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, ); }; };
51D130531382EAC000351EDD /* SecItemRequestData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */; };
51D130541382EAC000351EDD /* SecItemRequestData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D130501382EAC000351EDD /* SecItemRequestData.h */; };
51D130551382EAC000351EDD /* SecItemResponseData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D130511382EAC000351EDD /* SecItemResponseData.cpp */; };
@@ -3285,6 +3288,11 @@
51D124371E6DFD2A002B2820 /* WKURLSchemeHandlerTaskInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeHandlerTaskInternal.h; sourceTree = "<group>"; };
51D124381E6DFDB9002B2820 /* APIURLSchemeHandlerTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIURLSchemeHandlerTask.cpp; sourceTree = "<group>"; };
51D124391E6DFDB9002B2820 /* APIURLSchemeHandlerTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIURLSchemeHandlerTask.h; sourceTree = "<group>"; };
+ 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>"; };
51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemRequestData.cpp; sourceTree = "<group>"; };
51D130501382EAC000351EDD /* SecItemRequestData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecItemRequestData.h; sourceTree = "<group>"; };
51D130511382EAC000351EDD /* SecItemResponseData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemResponseData.cpp; sourceTree = "<group>"; };
@@ -5544,6 +5552,9 @@
1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */,
2DF9EEE71A78245500B6CFBE /* WKFrameInfoInternal.h */,
1A6FA21D1BD0435B00AAA650 /* WKFrameInfoPrivate.h */,
+ 51D124841E734AE3002B2820 /* WKHTTPCookieStorage.h */,
+ 51D124851E734AE3002B2820 /* WKHTTPCookieStorage.mm */,
+ 51D124861E734AE3002B2820 /* WKHTTPCookieStorageInternal.h */,
1A422F8A18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h */,
1AB40EE31BF677E300BA81BE /* WKMenuItemIdentifiers.mm */,
1AB40EE41BF677E300BA81BE /* WKMenuItemIdentifiersPrivate.h */,
@@ -6732,6 +6743,8 @@
2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */,
93A88B421BC8828C00ABA5C2 /* APIHitTestResult.cpp */,
93A88B431BC8828C00ABA5C2 /* APIHitTestResult.h */,
+ 51D124821E734AC8002B2820 /* APIHTTPCookieStorage.cpp */,
+ 51D124831E734AC8002B2820 /* APIHTTPCookieStorage.h */,
5143B2611DDD0DA00014FAC6 /* APIIconLoadingClient.h */,
7CE4D2061A46775700C7F152 /* APILegacyContextHistoryClient.h */,
1A2464F21891E45100234C5B /* APILoaderClient.h */,
@@ -8515,6 +8528,7 @@
514129941C6428BB0059E714 /* WebIDBConnectionToServer.h in Headers */,
510523741C73D38B007993CB /* WebIDBConnectionToServerMessages.h in Headers */,
BCCF6ABD12C91EF9008F9C35 /* WebImage.h in Headers */,
+ 51D124991E763C01002B2820 /* WKHTTPCookieStorage.h in Headers */,
1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */,
BC032D8210F4378D0058C15A /* WebInspectorClient.h in Headers */,
A55BA8351BA3E70A007CD33D /* WebInspectorFrontendAPIDispatcher.h in Headers */,
@@ -9767,6 +9781,7 @@
1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */,
1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */,
1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */,
+ 51D124921E74BF48002B2820 /* WKHTTPCookieStorage.mm in Sources */,
1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
839A2F311E2067450039057E /* HighPerformanceGraphicsUsageSampler.cpp in Sources */,
1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
@@ -9785,6 +9800,7 @@
831EEBBE1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.cpp in Sources */,
832AE2531BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.cpp in Sources */,
83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */,
+ 51D124911E74BF3C002B2820 /* APIHTTPCookieStorage.cpp in Sources */,
E4436ED01A0D040B00EAD204 /* NetworkCacheStorage.cpp in Sources */,
8310428C1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp in Sources */,
5302583D1DCBBD2200DA89C2 /* NetworkCaptureEvent.cpp in Sources */,
Modified: trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp (213876 => 213877)
--- 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)
@@ -72,6 +72,7 @@
WebCore::deleteCookiesForHostnames(*storageSession, { hostname });
}
+
void WebCookieManager::deleteAllCookies(SessionID sessionID)
{
if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
@@ -78,16 +79,57 @@
WebCore::deleteAllCookies(*storageSession);
}
-void WebCookieManager::deleteAllCookiesModifiedSince(SessionID sessionID, std::chrono::system_clock::time_point time)
+void WebCookieManager::deleteCookie(SessionID sessionID, const Cookie& cookie, uint64_t callbackID)
{
if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
+ 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))
WebCore::deleteAllCookiesModifiedSince(*storageSession, time);
+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidDeleteCookies(callbackID), 0);
}
-void WebCookieManager::setCookies(WebCore::SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL)
+void WebCookieManager::getAllCookies(SessionID sessionID, uint64_t callbackID)
{
+ Vector<Cookie> cookies;
if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
+ 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))
storageSession->setCookies(cookies, url, mainDocumentURL);
+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidSetCookies(callbackID), 0);
}
void WebCookieManager::notifyCookiesDidChange(SessionID sessionID)
@@ -111,9 +153,12 @@
WebCore::stopObservingCookieChanges(*storageSession);
}
-void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, uint64_t callbackID)
{
platformSetHTTPCookieAcceptPolicy(policy);
+
+ if (callbackID)
+ m_process->send(Messages::WebCookieManagerProxy::DidSetHTTPCookieAcceptPolicy(callbackID), 0);
}
void WebCookieManager::getHTTPCookieAcceptPolicy(uint64_t callbackID)
Modified: trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.h (213876 => 213877)
--- 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)
@@ -56,7 +56,8 @@
static const char* supplementName();
- void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
+ void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy, uint64_t callbackID);
+
#if USE(SOUP)
void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
#endif
@@ -68,11 +69,16 @@
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
void getHostnamesWithCookies(WebCore::SessionID, uint64_t callbackID);
+
+ void deleteCookie(WebCore::SessionID, const WebCore::Cookie&, uint64_t callbackID);
void deleteCookiesForHostname(WebCore::SessionID, const String&);
void deleteAllCookies(WebCore::SessionID);
- void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point);
+ void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point, uint64_t callbackID);
- void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL);
+ 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);
void platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
void getHTTPCookieAcceptPolicy(uint64_t callbackID);
Modified: trunk/Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in (213876 => 213877)
--- 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)
@@ -27,11 +27,15 @@
void GetHostnamesWithCookies(WebCore::SessionID sessionID, uint64_t callbackID)
void DeleteCookiesForHostname(WebCore::SessionID sessionID, String hostname)
void DeleteAllCookies(WebCore::SessionID sessionID)
- void DeleteAllCookiesModifiedSince(WebCore::SessionID sessionID, std::chrono::system_clock::time_point time)
- void SetCookies(WebCore::SessionID sessionID, Vector<WebCore::Cookie> cookies, WebCore::URL url, WebCore::URL mainDocumentURL);
+ 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)
- void SetHTTPCookieAcceptPolicy(uint32_t policy)
+ void SetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID)
void GetHTTPCookieAcceptPolicy(uint64_t callbackID)
void StartObservingCookieChanges(WebCore::SessionID sessionID)
Modified: trunk/Tools/ChangeLog (213876 => 213877)
--- trunk/Tools/ChangeLog 2017-03-13 22:52:41 UTC (rev 213876)
+++ trunk/Tools/ChangeLog 2017-03-13 23:00:49 UTC (rev 213877)
@@ -1,3 +1,12 @@
+2017-03-13 Brady Eidson <[email protected]>
+
+ WKWebView provides no access to cookies.
+ https://bugs.webkit.org/show_bug.cgi?id=140191
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
2017-03-13 Carlos Alberto Lopez Perez <[email protected]>
[GTK] install-dependencies needs to install Perl CGI modules on Debian based distros
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (213876 => 213877)
--- 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)
@@ -152,6 +152,7 @@
51BCEE4F1C84F53B0042C82E /* IndexedDBMultiProcess-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */; };
51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */; };
51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */; };
+ 51D124981E763B02002B2820 /* WKHTTPCookieStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124971E763AF8002B2820 /* WKHTTPCookieStorage.mm */; };
51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780371919AFF8001829A2 /* simple3.html */; };
51E6A8941D2F1C0A00C004B6 /* LocalStorageClear.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */; };
@@ -1048,6 +1049,7 @@
51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModalAlertsSPI.cpp; sourceTree = "<group>"; };
51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModalAlerts.mm; sourceTree = "<group>"; };
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>"; };
+ 51D124971E763AF8002B2820 /* WKHTTPCookieStorage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKHTTPCookieStorage.mm; sourceTree = "<group>"; };
51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalStorageClear.mm; sourceTree = "<group>"; };
51E6A8951D2F1C7700C004B6 /* LocalStorageClear.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LocalStorageClear.html; sourceTree = "<group>"; };
@@ -1649,6 +1651,7 @@
5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */,
5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */,
1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */,
+ 51D124971E763AF8002B2820 /* WKHTTPCookieStorage.mm */,
375E0E151D66674400EFEC2C /* WKNSNumber.mm */,
37B47E2E1D64E7CA005F4EFF /* WKObject.mm */,
2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */,
@@ -2729,6 +2732,7 @@
7CCE7EF41A411AE600447C4C /* FindMatches.mm in Sources */,
7C83E0401D0A63E300FEBCF3 /* FirstResponderScrollingPosition.mm in Sources */,
7C83E0BC1D0A650700FEBCF3 /* FixedLayoutSize.mm in Sources */,
+ 51D124981E763B02002B2820 /* WKHTTPCookieStorage.mm in Sources */,
7CCE7EF51A411AE600447C4C /* ForceRepaint.cpp in Sources */,
37B47E301D64E7CA005F4EFF /* WKObject.mm in Sources */,
7CCE7EC01A411A7E00447C4C /* FragmentNavigation.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKHTTPCookieStorage.mm (0 => 213877)
--- 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)
@@ -0,0 +1,119 @@
+/*
+ * 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