Deprecate all WKCookieManagerRef functions
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2019 20:42:42 +0000 (20:42 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2019 20:42:42 +0000 (20:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201473

Reviewed by Chris Dumez.

Source/WebKit:

Their use was removed in rdar://problem/55039275
Created replacement C API that more closely resembles the public ObjC API for WebKitTestRunner.

* Shared/API/c/WKBase.h:
* Sources.txt:
* UIProcess/API/APIHTTPCookieStore.cpp:
(API::HTTPCookieStore::deleteAllCookies):
(API::HTTPCookieStore::setHTTPCookieAcceptPolicy):
(API::HTTPCookieStore::deleteCookiesInDefaultUIProcessCookieStore):
(API::HTTPCookieStore::setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore):
* UIProcess/API/APIHTTPCookieStore.h:
* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextSetStorageAccessAPIEnabled):
* UIProcess/API/C/WKContext.h:
* UIProcess/API/C/WKCookieManager.cpp:
(WKCookieManagerGetTypeID):
(WKCookieManagerSetClient):
(WKCookieManagerGetHostnamesWithCookies):
(WKCookieManagerDeleteCookiesForHostname):
(WKCookieManagerDeleteAllCookies):
(WKCookieManagerDeleteAllCookiesModifiedAfterDate):
(WKCookieManagerSetHTTPCookieAcceptPolicy):
(WKCookieManagerGetHTTPCookieAcceptPolicy):
(WKCookieManagerSetStorageAccessAPIEnabled):
(WKCookieManagerStartObservingCookieChanges):
(WKCookieManagerStopObservingCookieChanges):
* UIProcess/API/C/WKCookieManager.h:
* UIProcess/API/C/WKHTTPCookieStoreRef.cpp: Added.
(WKHTTPCookieStoreGetTypeID):
(WKHTTPCookieStoreDeleteAllCookies):
(WKHTTPCookieStoreSetHTTPCookieAcceptPolicy):
* UIProcess/API/C/WKHTTPCookieStoreRef.h: Added.
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreGetHTTPCookieStore):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm:
(API::HTTPCookieStore::deleteCookiesInDefaultUIProcessCookieStore):
(API::toNSHTTPCookieAcceptPolicy):
(API::HTTPCookieStore::setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::setStorageAccessAPIEnabled): Deleted.
* UIProcess/WebCookieManagerProxy.h:
* WebKit.xcodeproj/project.pbxproj:

Tools:

Adopt replacement C API in WebKitTestRunner.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/CookieManager.cpp: Removed, because the functions it tests were removed.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::invoke):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):

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

29 files changed:
Source/WebKit/ChangeLog
Source/WebKit/PlatformWin.cmake
Source/WebKit/Shared/API/c/WKBase.h
Source/WebKit/Sources.txt
Source/WebKit/UIProcess/API/APIHTTPCookieStore.cpp
Source/WebKit/UIProcess/API/APIHTTPCookieStore.h
Source/WebKit/UIProcess/API/C/WKAPICast.h
Source/WebKit/UIProcess/API/C/WKContext.cpp
Source/WebKit/UIProcess/API/C/WKContext.h
Source/WebKit/UIProcess/API/C/WKCookieManager.cpp
Source/WebKit/UIProcess/API/C/WKCookieManager.h
Source/WebKit/UIProcess/API/C/WKHTTPCookieStoreRef.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/API/C/WKHTTPCookieStoreRef.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/UIProcess/WebCookieManagerProxy.cpp
Source/WebKit/UIProcess/WebCookieManagerProxy.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit/CookieManager.cpp [deleted file]
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

index 77dad18..5ff33ff 100644 (file)
@@ -1,3 +1,55 @@
+2019-09-06  Alex Christensen  <achristensen@webkit.org>
+
+        Deprecate all WKCookieManagerRef functions
+        https://bugs.webkit.org/show_bug.cgi?id=201473
+
+        Reviewed by Chris Dumez.
+
+        Their use was removed in rdar://problem/55039275
+        Created replacement C API that more closely resembles the public ObjC API for WebKitTestRunner.
+
+        * Shared/API/c/WKBase.h:
+        * Sources.txt:
+        * UIProcess/API/APIHTTPCookieStore.cpp:
+        (API::HTTPCookieStore::deleteAllCookies):
+        (API::HTTPCookieStore::setHTTPCookieAcceptPolicy):
+        (API::HTTPCookieStore::deleteCookiesInDefaultUIProcessCookieStore):
+        (API::HTTPCookieStore::setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore):
+        * UIProcess/API/APIHTTPCookieStore.h:
+        * UIProcess/API/C/WKAPICast.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetStorageAccessAPIEnabled):
+        * UIProcess/API/C/WKContext.h:
+        * UIProcess/API/C/WKCookieManager.cpp:
+        (WKCookieManagerGetTypeID):
+        (WKCookieManagerSetClient):
+        (WKCookieManagerGetHostnamesWithCookies):
+        (WKCookieManagerDeleteCookiesForHostname):
+        (WKCookieManagerDeleteAllCookies):
+        (WKCookieManagerDeleteAllCookiesModifiedAfterDate):
+        (WKCookieManagerSetHTTPCookieAcceptPolicy):
+        (WKCookieManagerGetHTTPCookieAcceptPolicy):
+        (WKCookieManagerSetStorageAccessAPIEnabled):
+        (WKCookieManagerStartObservingCookieChanges):
+        (WKCookieManagerStopObservingCookieChanges):
+        * UIProcess/API/C/WKCookieManager.h:
+        * UIProcess/API/C/WKHTTPCookieStoreRef.cpp: Added.
+        (WKHTTPCookieStoreGetTypeID):
+        (WKHTTPCookieStoreDeleteAllCookies):
+        (WKHTTPCookieStoreSetHTTPCookieAcceptPolicy):
+        * UIProcess/API/C/WKHTTPCookieStoreRef.h: Added.
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreGetHTTPCookieStore):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+        * UIProcess/API/Cocoa/APIHTTPCookieStoreCocoa.mm:
+        (API::HTTPCookieStore::deleteCookiesInDefaultUIProcessCookieStore):
+        (API::toNSHTTPCookieAcceptPolicy):
+        (API::HTTPCookieStore::setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore):
+        * UIProcess/WebCookieManagerProxy.cpp:
+        (WebKit::WebCookieManagerProxy::setStorageAccessAPIEnabled): Deleted.
+        * UIProcess/WebCookieManagerProxy.h:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-09-06  Darryl Pogue  <darryl@dpogue.ca>
 
         REGRESSION(iOS 12): Keyboard dismissal leaves WKWebView viewport-fit=cover content offscreen
index c2b8666..fc14b20 100644 (file)
@@ -262,6 +262,7 @@ set(WebKit_PUBLIC_FRAMEWORK_HEADERS
     UIProcess/API/C/WKGeolocationManager.h
     UIProcess/API/C/WKGeolocationPermissionRequest.h
     UIProcess/API/C/WKGeolocationPosition.h
+    UIProcess/API/C/WKHTTPCookieStoreRef.h
     UIProcess/API/C/WKHitTestResult.h
     UIProcess/API/C/WKIconDatabase.h
     UIProcess/API/C/WKInspector.h
index 03914b2..eb7b061 100644 (file)
@@ -100,6 +100,7 @@ typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef;
 typedef const struct OpaqueWKGeolocationPermissionRequest* WKGeolocationPermissionRequestRef;
 typedef const struct OpaqueWKGeolocationPosition* WKGeolocationPositionRef;
 typedef const struct OpaqueWKGrammarDetail* WKGrammarDetailRef;
+typedef const struct OpaqueWKHTTPCookieStore* WKHTTPCookieStoreRef;
 typedef const struct OpaqueWKHitTestResult* WKHitTestResultRef;
 typedef const struct OpaqueWKIconDatabase* WKIconDatabaseRef;
 typedef const struct OpaqueWKInspector* WKInspectorRef;
index 313ec0a..ec666be 100644 (file)
@@ -341,6 +341,7 @@ UIProcess/API/C/WKFramePolicyListener.cpp
 UIProcess/API/C/WKGeolocationManager.cpp
 UIProcess/API/C/WKGeolocationPermissionRequest.cpp
 UIProcess/API/C/WKGeolocationPosition.cpp
+UIProcess/API/C/WKHTTPCookieStoreRef.cpp
 UIProcess/API/C/WKHitTestResult.cpp
 UIProcess/API/C/WKIconDatabase.cpp
 UIProcess/API/C/WKInspector.cpp
index e122ee3..1c8583a 100644 (file)
@@ -117,6 +117,38 @@ void HTTPCookieStore::deleteCookie(const WebCore::Cookie& cookie, CompletionHand
     });
 }
 
+void HTTPCookieStore::deleteAllCookies(CompletionHandler<void()>&& completionHandler)
+{
+    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
+    if (!pool) {
+        if (!m_owningDataStore->sessionID().isEphemeral())
+            deleteCookiesInDefaultUIProcessCookieStore();
+        RunLoop::main().dispatch(WTFMove(completionHandler));
+        return;
+    }
+
+    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+    cookieManager->deleteAllCookies(m_owningDataStore->sessionID());
+    // FIXME: The CompletionHandler should be passed to WebCookieManagerProxy::deleteAllCookies.
+    RunLoop::main().dispatch(WTFMove(completionHandler));
+}
+
+void HTTPCookieStore::setHTTPCookieAcceptPolicy(WebKit::HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
+{
+    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
+    if (!pool) {
+        if (!m_owningDataStore->sessionID().isEphemeral())
+            setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore(policy);
+        RunLoop::main().dispatch(WTFMove(completionHandler));
+        return;
+    }
+
+    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
+    cookieManager->setHTTPCookieAcceptPolicy(m_owningDataStore->sessionID(), policy, [completionHandler = WTFMove(completionHandler)] (CallbackBase::Error) mutable {
+        completionHandler();
+    });
+}
+
 class APIWebCookieManagerProxyObserver : public WebCookieManagerProxy::Observer {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -246,6 +278,8 @@ void HTTPCookieStore::setCookieInDefaultUIProcessCookieStore(const WebCore::Cook
 void HTTPCookieStore::deleteCookieFromDefaultUIProcessCookieStore(const WebCore::Cookie&) { }
 void HTTPCookieStore::startObservingChangesToDefaultUIProcessCookieStore(Function<void()>&&) { }
 void HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore() { }
+void HTTPCookieStore::deleteCookiesInDefaultUIProcessCookieStore() { }
+void HTTPCookieStore::setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore(WebKit::HTTPCookieAcceptPolicy) { }
 #endif
     
 } // namespace API
index ebf96c8..8f7bf3b 100644 (file)
@@ -42,6 +42,7 @@ class CookieStorageObserver;
 namespace WebKit {
 class WebCookieManagerProxy;
 class WebsiteDataStore;
+enum class HTTPCookieAcceptPolicy : uint8_t;
 }
 
 namespace API {
@@ -61,6 +62,9 @@ public:
     void cookies(CompletionHandler<void(const Vector<WebCore::Cookie>&)>&&);
     void setCookies(const Vector<WebCore::Cookie>&, CompletionHandler<void()>&&);
     void deleteCookie(const WebCore::Cookie&, CompletionHandler<void()>&&);
+    
+    void deleteAllCookies(CompletionHandler<void()>&&);
+    void setHTTPCookieAcceptPolicy(WebKit::HTTPCookieAcceptPolicy, CompletionHandler<void()>&&);
 
     class Observer {
     public:
@@ -86,6 +90,8 @@ private:
     static void deleteCookieFromDefaultUIProcessCookieStore(const WebCore::Cookie&);
     void startObservingChangesToDefaultUIProcessCookieStore(Function<void()>&&);
     void stopObservingChangesToDefaultUIProcessCookieStore();
+    void deleteCookiesInDefaultUIProcessCookieStore();
+    void setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore(WebKit::HTTPCookieAcceptPolicy);
     
     // FIXME: This is a reference cycle.
     Ref<WebKit::WebsiteDataStore> m_owningDataStore;
index 5173755..df6acd8 100644 (file)
@@ -57,6 +57,7 @@ class InternalDebugFeature;
 class ExperimentalFeature;
 class FrameHandle;
 class FrameInfo;
+class HTTPCookieStore;
 class HitTestResult;
 class MessageListener;
 class Navigation;
@@ -133,6 +134,7 @@ WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
 WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy)
 WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequest)
 WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition)
+WK_ADD_API_MAPPING(WKHTTPCookieStoreRef, API::HTTPCookieStore)
 WK_ADD_API_MAPPING(WKHitTestResultRef, API::HitTestResult)
 WK_ADD_API_MAPPING(WKIconDatabaseRef, WebIconDatabase)
 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
index 117905f..a1a55bf 100644 (file)
@@ -417,6 +417,11 @@ bool WKContextGetUsesSingleWebProcess(WKContextRef contextRef)
     return WebKit::toImpl(contextRef)->configuration().usesSingleWebProcess();
 }
 
+void WKContextSetStorageAccessAPIEnabled(WKContextRef contextRef, bool enabled)
+{
+    WebKit::toImpl(contextRef)->setStorageAccessAPIEnabled(enabled);
+}
+
 void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name)
 {
     WebKit::toImpl(contextRef)->setCustomWebContentServiceBundleIdentifier(WebKit::toImpl(name)->string());
index 9a6cbcf..ef6ff1b 100644 (file)
@@ -137,13 +137,15 @@ WK_EXPORT unsigned WKContextGetMaximumNumberOfProcesses(WKContextRef context) WK
 WK_EXPORT void WKContextSetUsesSingleWebProcess(WKContextRef, bool);
 WK_EXPORT bool WKContextGetUsesSingleWebProcess(WKContextRef);
 
+WK_EXPORT void WKContextSetStorageAccessAPIEnabled(WKContextRef, bool enabled);
+
 WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval);
 WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
 
 WK_EXPORT WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef context);
 
 WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context);
-WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context);
+WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context) WK_C_API_DEPRECATED;
 WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);
 WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
 WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
index 0636ea6..7afa8fb 100644 (file)
 
 #include "APIArray.h"
 #include "WKAPICast.h"
-#include "WebCookieManagerProxy.h"
 
 using namespace WebKit;
 
 WKTypeID WKCookieManagerGetTypeID()
 {
-    return toAPI(WebCookieManagerProxy::APIType);
+    return 0;
 }
 
-void WKCookieManagerSetClient(WKCookieManagerRef cookieManagerRef, const WKCookieManagerClientBase* wkClient)
+void WKCookieManagerSetClient(WKCookieManagerRef, const WKCookieManagerClientBase*)
 {
-    toImpl(cookieManagerRef)->initializeClient(wkClient);
 }
 
-void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManagerRef, void* context, WKCookieManagerGetCookieHostnamesFunction callback)
+void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef, void*, WKCookieManagerGetCookieHostnamesFunction)
 {
-    toImpl(cookieManagerRef)->getHostnamesWithCookies(PAL::SessionID::defaultSessionID(), toGenericCallbackFunction(context, callback));
 }
 
-void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManagerRef, WKStringRef hostname)
+void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef, WKStringRef)
 {
-    toImpl(cookieManagerRef)->deleteCookiesForHostnames(PAL::SessionID::defaultSessionID(), { toImpl(hostname)->string() });
 }
 
-void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManagerRef)
+void WKCookieManagerDeleteAllCookies(WKCookieManagerRef)
 {
-    toImpl(cookieManagerRef)->deleteAllCookies(PAL::SessionID::defaultSessionID());
 }
 
-void WKCookieManagerDeleteAllCookiesModifiedAfterDate(WKCookieManagerRef cookieManagerRef, double date)
+void WKCookieManagerDeleteAllCookiesModifiedAfterDate(WKCookieManagerRef, double)
 {
-    toImpl(cookieManagerRef)->deleteAllCookiesModifiedSince(PAL::SessionID::defaultSessionID(), WallTime::fromRawSeconds(date), [](CallbackBase::Error){});
 }
 
-void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy, void* context, WKCookieManagerSetHTTPCookieAcceptPolicyFunction callback)
+void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef, WKHTTPCookieAcceptPolicy, void*, WKCookieManagerSetHTTPCookieAcceptPolicyFunction)
 {
-    toImpl(cookieManager)->setHTTPCookieAcceptPolicy(PAL::SessionID::defaultSessionID(), toHTTPCookieAcceptPolicy(policy), [context, callback](CallbackBase::Error error) {
-        if (callback)
-            callback(error != CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : nullptr, context);
-    });
 }
 
-void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback)
+void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef, void*, WKCookieManagerGetHTTPCookieAcceptPolicyFunction)
 {
-    toImpl(cookieManager)->getHTTPCookieAcceptPolicy(PAL::SessionID::defaultSessionID(), toGenericCallbackFunction<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy>(context, callback));
 }
 
-void WKCookieManagerSetStorageAccessAPIEnabled(WKCookieManagerRef cookieManager, bool enabled)
+void WKCookieManagerSetStorageAccessAPIEnabled(WKCookieManagerRef, bool)
 {
-    toImpl(cookieManager)->setStorageAccessAPIEnabled(enabled);
 }
 
-void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager)
+void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef)
 {
-    toImpl(cookieManager)->startObservingCookieChanges(PAL::SessionID::defaultSessionID());
 }
 
-void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager)
+void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef)
 {
-    toImpl(cookieManager)->stopObservingCookieChanges(PAL::SessionID::defaultSessionID());
 }
index 73354d2..556b942 100644 (file)
@@ -27,6 +27,7 @@
 #define WKCookieManager_h
 
 #include <WebKit/WKBase.h>
+#include <WebKit/WKDeprecated.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -55,28 +56,28 @@ typedef struct WKCookieManagerClientV0 {
     WKCookieManagerCookiesDidChangeCallback                             cookiesDidChange;
 } WKCookieManagerClientV0;
 
-WK_EXPORT WKTypeID WKCookieManagerGetTypeID();
+WK_EXPORT WKTypeID WKCookieManagerGetTypeID() WK_C_API_DEPRECATED;
 
-WK_EXPORT void WKCookieManagerSetClient(WKCookieManagerRef cookieManager, const WKCookieManagerClientBase* client);
+WK_EXPORT void WKCookieManagerSetClient(WKCookieManagerRef cookieManager, const WKCookieManagerClientBase* client) WK_C_API_DEPRECATED;
 
 typedef void (*WKCookieManagerGetCookieHostnamesFunction)(WKArrayRef, WKErrorRef, void*);
-WK_EXPORT void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetCookieHostnamesFunction function);
+WK_EXPORT void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetCookieHostnamesFunction function) WK_C_API_DEPRECATED;
 
-WK_EXPORT void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManager, WKStringRef hostname);
-WK_EXPORT void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManager);
+WK_EXPORT void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManager, WKStringRef hostname) WK_C_API_DEPRECATED;
+WK_EXPORT void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManager) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKHTTPCookieStoreDeleteAllCookies);
 
 // The time here is relative to the Unix epoch.
-WK_EXPORT void WKCookieManagerDeleteAllCookiesModifiedAfterDate(WKCookieManagerRef cookieManager, double);
+WK_EXPORT void WKCookieManagerDeleteAllCookiesModifiedAfterDate(WKCookieManagerRef cookieManager, double) WK_C_API_DEPRECATED;
 
 typedef void (*WKCookieManagerSetHTTPCookieAcceptPolicyFunction)(WKErrorRef, void*);
-WK_EXPORT void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy, void* context, WKCookieManagerSetHTTPCookieAcceptPolicyFunction callback);
+WK_EXPORT void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy, void* context, WKCookieManagerSetHTTPCookieAcceptPolicyFunction callback) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKHTTPCookieStoreSetHTTPCookieAcceptPolicy);
 typedef void (*WKCookieManagerGetHTTPCookieAcceptPolicyFunction)(WKHTTPCookieAcceptPolicy, WKErrorRef, void*);
-WK_EXPORT void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback);
+WK_EXPORT void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback) WK_C_API_DEPRECATED;
 
-WK_EXPORT void WKCookieManagerSetStorageAccessAPIEnabled(WKCookieManagerRef cookieManager, bool enabled);
+WK_EXPORT void WKCookieManagerSetStorageAccessAPIEnabled(WKCookieManagerRef cookieManager, bool enabled) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKContextSetStorageAccessAPIEnabled);
 
-WK_EXPORT void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager);
-WK_EXPORT void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager);
+WK_EXPORT void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager) WK_C_API_DEPRECATED;
+WK_EXPORT void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager) WK_C_API_DEPRECATED;
 
 #ifdef __cplusplus
 }
diff --git a/Source/WebKit/UIProcess/API/C/WKHTTPCookieStoreRef.cpp b/Source/WebKit/UIProcess/API/C/WKHTTPCookieStoreRef.cpp
new file mode 100644 (file)
index 0000000..c2b2891
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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 "WKHTTPCookieStoreRef.h"
+
+#include "APIHTTPCookieStore.h"
+#include "WKAPICast.h"
+
+WKTypeID WKHTTPCookieStoreGetTypeID()
+{
+    return WebKit::toAPI(API::HTTPCookieStore::APIType);
+}
+
+void WKHTTPCookieStoreDeleteAllCookies(WKHTTPCookieStoreRef cookieStore, void* context, WKHTTPCookieStoreDeleteAllCookiesFunction callback)
+{
+    WebKit::toImpl(cookieStore)->deleteAllCookies([context, callback] {
+        if (callback)
+            callback(context);
+    });
+}
+
+void WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKHTTPCookieStoreRef cookieStore, WKHTTPCookieAcceptPolicy policy, void* context, WKHTTPCookieStoreSetHTTPCookieAcceptPolicyFunction callback)
+{
+    WebKit::toImpl(cookieStore)->setHTTPCookieAcceptPolicy(WebKit::toHTTPCookieAcceptPolicy(policy), [context, callback] {
+        if (callback)
+            callback(context);
+    });
+}
diff --git a/Source/WebKit/UIProcess/API/C/WKHTTPCookieStoreRef.h b/Source/WebKit/UIProcess/API/C/WKHTTPCookieStoreRef.h
new file mode 100644 (file)
index 0000000..ad875c4
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef WKHTTPCookieStoreRef_h
+#define WKHTTPCookieStoreRef_h
+
+#include <WebKit/WKBase.h>
+#include <WebKit/WKCookieManager.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKHTTPCookieStoreGetTypeID();
+
+typedef void (*WKHTTPCookieStoreDeleteAllCookiesFunction)(void*);
+WK_EXPORT void WKHTTPCookieStoreDeleteAllCookies(WKHTTPCookieStoreRef cookieStore, void* context, WKHTTPCookieStoreDeleteAllCookiesFunction callback);
+    
+typedef void (*WKHTTPCookieStoreSetHTTPCookieAcceptPolicyFunction)(void*);
+WK_EXPORT void WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKHTTPCookieStoreRef cookieStore, WKHTTPCookieAcceptPolicy policy, void* context, WKHTTPCookieStoreSetHTTPCookieAcceptPolicyFunction callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKHTTPCookieStoreRef_h */
index c990416..b2ac11d 100644 (file)
@@ -75,6 +75,11 @@ void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef
     WebKit::toImpl(dataStoreRef)->setResourceLoadStatisticsDebugMode(enable);
 }
 
+WKHTTPCookieStoreRef WKWebsiteDataStoreGetHTTPCookieStore(WKWebsiteDataStoreRef dataStoreRef)
+{
+    return WebKit::toAPI(&WebKit::toImpl(dataStoreRef)->httpCookieStore());
+}
+
 void WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(WKWebsiteDataStoreRef dataStoreRef, bool enable, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler)
 {
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
index 7dec92a..dd0da18 100644 (file)
@@ -37,6 +37,8 @@ WK_EXPORT WKTypeID WKWebsiteDataStoreGetTypeID();
 WK_EXPORT WKWebsiteDataStoreRef WKWebsiteDataStoreGetDefaultDataStore();
 WK_EXPORT WKWebsiteDataStoreRef WKWebsiteDataStoreCreateNonPersistentDataStore();
 
+WK_EXPORT WKHTTPCookieStoreRef WKWebsiteDataStoreGetHTTPCookieStore(WKWebsiteDataStoreRef dataStoreRef);
+
 WK_EXPORT bool WKWebsiteDataStoreGetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef);
 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable);
 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef dataStoreRef, bool enable);
index 880775c..ad19676 100644 (file)
@@ -70,4 +70,30 @@ void HTTPCookieStore::stopObservingChangesToDefaultUIProcessCookieStore()
         observer->stopObserving();
 }
 
+void HTTPCookieStore::deleteCookiesInDefaultUIProcessCookieStore()
+{
+    [[NSHTTPCookieStorage sharedHTTPCookieStorage] removeCookiesSinceDate:[NSDate distantPast]];
+}
+
+static NSHTTPCookieAcceptPolicy toNSHTTPCookieAcceptPolicy(WebKit::HTTPCookieAcceptPolicy policy)
+{
+    switch (policy) {
+    case WebKit::HTTPCookieAcceptPolicy::AlwaysAccept:
+        return NSHTTPCookieAcceptPolicyAlways;
+    case WebKit::HTTPCookieAcceptPolicy::Never:
+        return NSHTTPCookieAcceptPolicyNever;
+    case WebKit::HTTPCookieAcceptPolicy::OnlyFromMainDocumentDomain:
+        return NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+    case WebKit::HTTPCookieAcceptPolicy::ExclusivelyFromMainDocumentDomain:
+        return (NSHTTPCookieAcceptPolicy)NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
+    }
+    ASSERT_NOT_REACHED();
+    return NSHTTPCookieAcceptPolicyAlways;
+}
+
+void HTTPCookieStore::setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore(WebKit::HTTPCookieAcceptPolicy policy)
+{
+    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:toNSHTTPCookieAcceptPolicy(policy)];
+}
+
 } // namespace API
index 9fd6a61..31e71f5 100644 (file)
@@ -544,12 +544,6 @@ void WebProcessPool::setCookieStoragePartitioningEnabled(bool enabled)
     m_cookieStoragePartitioningEnabled = enabled;
 }
 
-void WebProcessPool::setStorageAccessAPIEnabled(bool enabled)
-{
-    m_storageAccessAPIEnabled = enabled;
-    sendToNetworkingProcess(Messages::NetworkProcess::SetStorageAccessAPIEnabled(enabled));
-}
-
 void WebProcessPool::clearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace&& protectionSpace)
 {
     auto sharedStorage = [NSURLCredentialStorage sharedCredentialStorage];
index 7432880..04d0da2 100644 (file)
@@ -268,13 +268,4 @@ void WebCookieManagerProxy::didSetHTTPCookieAcceptPolicy(WebKit::CallbackID call
     m_callbacks.take<VoidCallback>(callbackID)->performCallback();
 }
 
-void WebCookieManagerProxy::setStorageAccessAPIEnabled(bool enabled)
-{
-#if PLATFORM(COCOA)
-    processPool()->sendToNetworkingProcess(Messages::NetworkProcess::SetStorageAccessAPIEnabled(enabled));
-#else
-    UNUSED_PARAM(enabled);
-#endif
-}
-
 } // namespace WebKit
index 673ad64..2c90d4c 100644 (file)
@@ -80,8 +80,6 @@ public:
     void setHTTPCookieAcceptPolicy(PAL::SessionID, HTTPCookieAcceptPolicy, Function<void (CallbackBase::Error)>&&);
     void getHTTPCookieAcceptPolicy(PAL::SessionID, Function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>&&);
 
-    void setStorageAccessAPIEnabled(bool);
-
     void startObservingCookieChanges(PAL::SessionID);
     void stopObservingCookieChanges(PAL::SessionID);
 
index e32eb43..48db582 100644 (file)
@@ -408,6 +408,14 @@ void WebProcessPool::setLegacyCustomProtocolManagerClient(std::unique_ptr<API::C
 #endif
 }
 
+void WebProcessPool::setStorageAccessAPIEnabled(bool enabled)
+{
+    m_storageAccessAPIEnabled = enabled;
+#if PLATFORM(COCOA)
+    sendToNetworkingProcess(Messages::NetworkProcess::SetStorageAccessAPIEnabled(enabled));
+#endif
+}
+
 void WebProcessPool::setCustomWebContentServiceBundleIdentifier(const String& customWebContentServiceBundleIdentifier)
 {
     // Guard against API misuse.
index f94367f..fa631e0 100644 (file)
@@ -465,11 +465,11 @@ public:
 #if PLATFORM(COCOA)
     bool cookieStoragePartitioningEnabled() const { return m_cookieStoragePartitioningEnabled; }
     void setCookieStoragePartitioningEnabled(bool);
-    bool storageAccessAPIEnabled() const { return m_storageAccessAPIEnabled; }
-    void setStorageAccessAPIEnabled(bool);
 
     void clearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace&&);
 #endif
+    bool storageAccessAPIEnabled() const { return m_storageAccessAPIEnabled; }
+    void setStorageAccessAPIEnabled(bool);
 
     static uint64_t registerProcessPoolCreationListener(Function<void(WebProcessPool&)>&&);
     static void unregisterProcessPoolCreationListener(uint64_t identifier);
@@ -756,8 +756,8 @@ private:
 
 #if PLATFORM(COCOA)
     bool m_cookieStoragePartitioningEnabled { false };
-    bool m_storageAccessAPIEnabled { false };
 #endif
+    bool m_storageAccessAPIEnabled { false };
 
     struct Paths {
         String injectedBundlePath;
index 24a43fb..6270df6 100644 (file)
                5C4B9D8B210A8CCF008F14D1 /* UndoOrRedo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4B9D8A210A8C46008F14D1 /* UndoOrRedo.h */; };
                5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5C66A4B52320962400EA4D44 /* WKHTTPCookieStoreRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C66A4B42320961400EA4D44 /* WKHTTPCookieStoreRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5C795D70229F373F003FF1C4 /* WKContextMenuElementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE0C369229F2D4A003695F0 /* WKContextMenuElementInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
                5C795D71229F3757003FF1C4 /* WKContextMenuElementInfoPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE0C36A229F2D4A003695F0 /* WKContextMenuElementInfoPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5C7FB47021E97DC5009E3241 /* WebCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7FB46F21E97C0C009E3241 /* WebCookieJar.h */; };
                        compilerSpec = com.apple.compilers.proxy.script;
                        filePatterns = "*.h";
                        fileType = pattern.proxy;
-                       inputFiles = (
-                       );
                        isEditable = 1;
                        outputFiles = (
                                "$(HEADER_OUTPUT_DIR)/$(INPUT_FILE_NAME)",
                5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFields.h; sourceTree = "<group>"; };
                5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICustomHeaderFields.h; sourceTree = "<group>"; };
                5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; };
+               5C66A4B32320961300EA4D44 /* WKHTTPCookieStoreRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKHTTPCookieStoreRef.cpp; sourceTree = "<group>"; };
+               5C66A4B42320961400EA4D44 /* WKHTTPCookieStoreRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHTTPCookieStoreRef.h; sourceTree = "<group>"; };
                5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; };
                5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImplCocoa.h; sourceTree = "<group>"; };
                5C74300E21500492004BFA17 /* WKWebProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcess.h; sourceTree = "<group>"; };
                                BC0E619612D6CD120012A72A /* WKGeolocationPosition.h */,
                                B62E730F143047A60069EC35 /* WKHitTestResult.cpp */,
                                B62E7311143047B00069EC35 /* WKHitTestResult.h */,
+                               5C66A4B32320961300EA4D44 /* WKHTTPCookieStoreRef.cpp */,
+                               5C66A4B42320961400EA4D44 /* WKHTTPCookieStoreRef.h */,
                                5110AE0A133C16CB0072717A /* WKIconDatabase.cpp */,
                                5110AE0B133C16CB0072717A /* WKIconDatabase.h */,
                                1C8E293812761E5B00BC7BD0 /* WKInspector.cpp */,
                                1A422F8B18B29B5400D8CD96 /* WKHistoryDelegatePrivate.h in Headers */,
                                B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */,
                                51D124991E763C01002B2820 /* WKHTTPCookieStore.h in Headers */,
+                               5C66A4B52320962400EA4D44 /* WKHTTPCookieStoreRef.h in Headers */,
                                5110AE0D133C16CB0072717A /* WKIconDatabase.h in Headers */,
                                5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */,
                                BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */,
index 62a5348..af04c5e 100644 (file)
@@ -1,3 +1,24 @@
+2019-09-06  Alex Christensen  <achristensen@webkit.org>
+
+        Deprecate all WKCookieManagerRef functions
+        https://bugs.webkit.org/show_bug.cgi?id=201473
+
+        Reviewed by Chris Dumez.
+
+        Adopt replacement C API in WebKitTestRunner.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/CookieManager.cpp: Removed, because the functions it tests were removed.
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        (WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::invoke):
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::initializeWebViewConfiguration):
+
 2019-09-06  Tim Horton  <timothy_horton@apple.com>
 
         Marking up a note on iOS results in a PDF with no contents
index 2394b53..cbeca3a 100644 (file)
@@ -195,7 +195,6 @@ if (ENABLE_WEBKIT)
     set(TestWebKit_SOURCES
         Tests/WebKit/AboutBlankLoad.cpp
         Tests/WebKit/CanHandleRequest.cpp
-        Tests/WebKit/CookieManager.cpp
         Tests/WebKit/DOMWindowExtensionBasic.cpp
         Tests/WebKit/DOMWindowExtensionNoCache.cpp
         Tests/WebKit/DocumentStartUserScriptAlertCrash.cpp
index 9573b23..fb11dde 100644 (file)
                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 /* WKHTTPCookieStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D124971E763AF8002B2820 /* WKHTTPCookieStore.mm */; };
-               51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
                51D8C1902267B26D00797E40 /* PDFLinkReferrer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D8C18F2267B26700797E40 /* PDFLinkReferrer.mm */; };
                51DB16CE1F085137001FA4C5 /* WebViewIconLoading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51DB16CD1F085047001FA4C5 /* WebViewIconLoading.mm */; };
                51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
                F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DidAssociateFormControls_Bundle.cpp; sourceTree = "<group>"; };
                F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DidAssociateFormControls.cpp; sourceTree = "<group>"; };
                F6B7BE9617469B7E008A3445 /* associate-form-controls.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "associate-form-controls.html"; sourceTree = "<group>"; };
-               F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieManager.cpp; sourceTree = "<group>"; };
                F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache_Bundle.cpp; sourceTree = "<group>"; };
                F6F49C6715545C8D0007F39D /* DOMWindowExtensionNoCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtensionNoCache.cpp; sourceTree = "<group>"; };
                F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
                                BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */,
                                1A50AA1C1A2A4E7000F4C345 /* CloseFromWithinCreatePage.cpp */,
                                7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */,
-                               F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */,
                                F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */,
                                F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */,
                                9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */,
                                CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */,
                                5C3B1D2622A74F6700BCF4D0 /* ContextMenus.mm in Sources */,
                                5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */,
-                               51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */,
                                5C19A5241FD0F60100EEA323 /* CookiePrivateBrowsing.mm in Sources */,
                                9B1F6F781F90558400B55744 /* CopyHTML.mm in Sources */,
                                9999108B1F393C96008AD455 /* Copying.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit/CookieManager.cpp b/Tools/TestWebKitAPI/Tests/WebKit/CookieManager.cpp
deleted file mode 100644 (file)
index 840c6c5..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2010 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"
-
-#if WK_HAVE_C_SPI
-
-#include "PlatformUtilities.h"
-#include "PlatformWebView.h"
-#include <WebKit/WKCookieManager.h>
-#include <WebKit/WKRetainPtr.h>
-
-namespace TestWebKitAPI {
-
-static bool testDone;
-// Make sure that the policy on the machine running the test is not changed after running the test.
-static WKHTTPCookieAcceptPolicy userPolicy;
-static WKHTTPCookieAcceptPolicy testPolicy;
-static WKRetainPtr<WKContextRef> wkContext;
-
-static void didGetTestHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy, WKErrorRef, void* context)
-{
-    EXPECT_EQ(reinterpret_cast<void*>(0x1234578), context);
-    EXPECT_EQ(testPolicy, policy);
-
-    WKCookieManagerRef cookieManager = WKContextGetCookieManager(wkContext.get());
-    WKCookieManagerSetHTTPCookieAcceptPolicy(cookieManager, userPolicy, nullptr, nullptr);
-
-    testDone = true;
-}
-
-static void didGetUserHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy, WKErrorRef, void* context)
-{
-    EXPECT_EQ(reinterpret_cast<void*>(0x1234578), context);
-
-    userPolicy = policy;
-
-    // Make sure to choose a policy different from the policy the user currently has set.
-    testPolicy = (userPolicy + 1) % 3;
-    WKCookieManagerRef cookieManager = WKContextGetCookieManager(wkContext.get());
-    WKCookieManagerSetHTTPCookieAcceptPolicy(cookieManager, testPolicy, nullptr, nullptr);
-    WKCookieManagerGetHTTPCookieAcceptPolicy(cookieManager, reinterpret_cast<void*>(0x1234578), didGetTestHTTPCookieAcceptPolicy);
-}
-
-static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*)
-{
-    WKCookieManagerRef cookieManager = WKContextGetCookieManager(wkContext.get());
-    WKCookieManagerGetHTTPCookieAcceptPolicy(cookieManager, reinterpret_cast<void*>(0x1234578), didGetUserHTTPCookieAcceptPolicy);
-}
-
-TEST(WebKit, CookieManager)
-{
-    wkContext.adopt(WKContextCreateWithConfiguration(nullptr));
-    PlatformWebView webView(wkContext.get());
-
-    WKPageNavigationClientV0 loaderClient;
-    memset(&loaderClient, 0, sizeof(loaderClient));
-
-    loaderClient.base.version = 0;
-    loaderClient.didFinishNavigation = didFinishNavigation;
-
-    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
-
-    WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
-
-    Util::run(&testDone);
-}
-
-} // namespace TestWebKitAPI
-
-#endif
index 5dd210d..3668d18 100644 (file)
 #include <WebKit/WKAuthenticationDecisionListener.h>
 #include <WebKit/WKContextConfigurationRef.h>
 #include <WebKit/WKContextPrivate.h>
-#include <WebKit/WKCookieManager.h>
 #include <WebKit/WKCredential.h>
 #include <WebKit/WKFrameHandleRef.h>
 #include <WebKit/WKFrameInfoRef.h>
+#include <WebKit/WKHTTPCookieStoreRef.h>
 #include <WebKit/WKIconDatabase.h>
 #include <WebKit/WKMessageListener.h>
 #include <WebKit/WKMockDisplay.h>
@@ -871,7 +871,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
     WKPreferencesSetBeaconAPIEnabled(preferences, true);
     WKPreferencesSetDirectoryUploadEnabled(preferences, true);
 
-    WKCookieManagerDeleteAllCookies(WKContextGetCookieManager(m_context.get()));
+    WKHTTPCookieStoreDeleteAllCookies(WKWebsiteDataStoreGetHTTPCookieStore(WKContextGetWebsiteDataStore(m_context.get())), nullptr, nullptr);
 
     WKPreferencesSetMockCaptureDevicesEnabled(preferences, true);
     
@@ -2098,7 +2098,7 @@ void TestController::didReceiveSynchronousMessageFromInjectedBundle(WKStringRef
 
     auto setHTTPCookieAcceptPolicy = [&] (WKHTTPCookieAcceptPolicy policy, CompletionHandler<void(WKTypeRef)>&& completionHandler) {
         auto context = new CompletionHandler<void(WKTypeRef)>(WTFMove(completionHandler));
-        WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(this->context()), policy, context, [] (WKErrorRef error, void* context) {
+        WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(WKContextGetWebsiteDataStore(m_context.get())), policy, context, [] (void* context) {
             auto completionHandlerPointer = static_cast<CompletionHandler<void(WKTypeRef)>*>(context);
             (*completionHandlerPointer)(nullptr);
             delete completionHandlerPointer;
index 9f87db2..dc3a5f4 100644 (file)
@@ -33,9 +33,9 @@
 #include "UIScriptController.h"
 #include "WebCoreTestSupport.h"
 #include <WebKit/WKContextPrivate.h>
-#include <WebKit/WKCookieManager.h>
 #include <WebKit/WKData.h>
 #include <WebKit/WKDictionary.h>
+#include <WebKit/WKHTTPCookieStoreRef.h>
 #include <WebKit/WKInspector.h>
 #include <WebKit/WKPagePrivate.h>
 #include <WebKit/WKRetainPtr.h>
@@ -164,7 +164,7 @@ void TestInvocation::invoke()
 
     TestController::singleton().setShouldLogHistoryClientCallbacks(shouldLogHistoryClientCallbacks());
 
-    WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, nullptr, nullptr);
+    WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(WKContextGetWebsiteDataStore(TestController::singleton().context())), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, nullptr, nullptr);
 
     // FIXME: We should clear out visited links here.
 
@@ -912,7 +912,7 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
 
     if (WKStringIsEqualToUTF8CString(messageName, "SetStorageAccessAPIEnabled")) {
         WKBooleanRef accept = static_cast<WKBooleanRef>(messageBody);
-        WKCookieManagerSetStorageAccessAPIEnabled(WKContextGetCookieManager(TestController::singleton().context()), WKBooleanGetValue(accept));
+        WKContextSetStorageAccessAPIEnabled(TestController::singleton().context(), WKBooleanGetValue(accept));
         return nullptr;
     }
 
index 6e4f5c8..4c40157 100644 (file)
@@ -36,7 +36,6 @@
 #import <Security/SecItem.h>
 #import <WebKit/WKContextConfigurationRef.h>
 #import <WebKit/WKContextPrivate.h>
-#import <WebKit/WKCookieManager.h>
 #import <WebKit/WKPreferencesRefPrivate.h>
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKStringCF.h>
@@ -69,7 +68,7 @@ void initializeWebViewConfiguration(const char* libraryPath, WKStringRef injecte
     globalWebViewConfiguration._allowUniversalAccessFromFileURLs = YES;
     globalWebViewConfiguration._applePayEnabled = YES;
 
-    WKCookieManagerSetStorageAccessAPIEnabled(WKContextGetCookieManager(context), true);
+    WKContextSetStorageAccessAPIEnabled(context, true);
 
     WKWebsiteDataStore* poolWebsiteDataStore = (__bridge WKWebsiteDataStore *)WKContextGetWebsiteDataStore((__bridge WKContextRef)globalWebViewConfiguration.processPool);
     if (libraryPath) {