Cleanup "addCookie" and its sole user.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Mar 2017 16:44:00 +0000 (16:44 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Mar 2017 16:44:00 +0000 (16:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169486

Reviewed by Brian Burg.

Source/WebCore:

No new tests (Refactor, no behavior change)

* WebCore.xcodeproj/project.pbxproj:

* loader/CookieJar.cpp:
(WebCore::addCookie): Deleted.
* loader/CookieJar.h:

* platform/Cookie.h:
(WebCore::Cookie::Cookie):
(WebCore::CookieHash::hash):
(WebCore::CookieHash::equal):
(WebCore::Cookie::encode):
(WebCore::Cookie::decode):

* platform/CookiesStrategy.h:

* platform/network/NetworkStorageSession.h:

* platform/network/PlatformCookieJar.h:

* platform/network/cf/CookieJarCFNet.cpp:
(WebCore::addCookie): Deleted.

* platform/network/cocoa/CookieCocoa.mm: Copied from Source/WebCore/loader/CookieJar.h.
(WebCore::Cookie::operator NSHTTPCookie *):

* platform/network/cocoa/NetworkStorageSessionCocoa.mm: Copied from Source/WebCore/loader/CookieJar.h.
(WebCore::NetworkStorageSession::setCookies):
(WebCore::NetworkStorageSession::nsCookieStorage):

* platform/network/curl/CookieJarCurl.cpp:
(WebCore::addCookie): Deleted.

* platform/network/mac/CookieJarMac.mm:
(WebCore::deleteCookiesForHostnames):
(WebCore::deleteAllCookiesModifiedSince):
(WebCore::addCookie): Deleted.
(WebCore::cookieStorage): Deleted.

* platform/network/soup/CookieJarSoup.cpp:
(WebCore::toSoupCookie): Deleted.
(WebCore::addCookie): Deleted.

* platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::toSoupCookie):
(WebCore::NetworkStorageSession::setCookies):

Source/WebKit/mac:

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::addCookie): Deleted.

Source/WebKit2:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::addCookie): Deleted.
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<Cookie>::encode): Deleted.
(IPC::ArgumentCoder<Cookie>::decode): Deleted.
* Shared/WebCoreArgumentCoders.h:

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::addSingleCookie):

* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::setCookies):
(WebKit::WebCookieManagerProxy::addCookie): Deleted.
* UIProcess/WebCookieManagerProxy.h:

* WebProcess/Cookies/WebCookieManager.cpp:
(WebKit::WebCookieManager::setCookies):
(WebKit::WebCookieManager::addCookie): Deleted.
* WebProcess/Cookies/WebCookieManager.h:
* WebProcess/Cookies/WebCookieManager.messages.in:

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::addCookie): Deleted.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

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

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/CookieJar.cpp
Source/WebCore/loader/CookieJar.h
Source/WebCore/platform/Cookie.h
Source/WebCore/platform/CookiesStrategy.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/PlatformCookieJar.h
Source/WebCore/platform/network/cf/CookieJarCFNet.cpp
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebCore/platform/network/cocoa/CookieCocoa.mm [new file with mode: 0644]
Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm [new file with mode: 0644]
Source/WebCore/platform/network/curl/CookieJarCurl.cpp
Source/WebCore/platform/network/mac/CookieJarMac.mm
Source/WebCore/platform/network/soup/CookieJarSoup.cpp
Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp
Source/WebKit2/UIProcess/WebCookieManagerProxy.h
Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp
Source/WebKit2/WebProcess/Cookies/WebCookieManager.h
Source/WebKit2/WebProcess/Cookies/WebCookieManager.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h

index 800ac73..3399b5c 100644 (file)
@@ -1,3 +1,58 @@
+2017-03-11  Brady Eidson  <beidson@apple.com>
+
+        Cleanup "addCookie" and its sole user.
+        https://bugs.webkit.org/show_bug.cgi?id=169486
+
+        Reviewed by Brian Burg.
+
+        No new tests (Refactor, no behavior change)
+
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * loader/CookieJar.cpp:
+        (WebCore::addCookie): Deleted.
+        * loader/CookieJar.h:
+
+        * platform/Cookie.h:
+        (WebCore::Cookie::Cookie):
+        (WebCore::CookieHash::hash):
+        (WebCore::CookieHash::equal):
+        (WebCore::Cookie::encode):
+        (WebCore::Cookie::decode):
+
+        * platform/CookiesStrategy.h:
+
+        * platform/network/NetworkStorageSession.h:
+
+        * platform/network/PlatformCookieJar.h:
+
+        * platform/network/cf/CookieJarCFNet.cpp:
+        (WebCore::addCookie): Deleted.
+
+        * platform/network/cocoa/CookieCocoa.mm: Copied from Source/WebCore/loader/CookieJar.h.
+        (WebCore::Cookie::operator NSHTTPCookie *):
+
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm: Copied from Source/WebCore/loader/CookieJar.h.
+        (WebCore::NetworkStorageSession::setCookies):
+        (WebCore::NetworkStorageSession::nsCookieStorage):
+
+        * platform/network/curl/CookieJarCurl.cpp:
+        (WebCore::addCookie): Deleted.
+
+        * platform/network/mac/CookieJarMac.mm:
+        (WebCore::deleteCookiesForHostnames):
+        (WebCore::deleteAllCookiesModifiedSince):
+        (WebCore::addCookie): Deleted.
+        (WebCore::cookieStorage): Deleted.
+
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::toSoupCookie): Deleted.
+        (WebCore::addCookie): Deleted.
+
+        * platform/network/soup/NetworkStorageSessionSoup.cpp:
+        (WebCore::toSoupCookie):
+        (WebCore::NetworkStorageSession::setCookies):
+
 2017-03-10  Alex Christensen  <achristensen@webkit.org>
 
         Fix watch and tv builds after r213294
index b814d31..fb45197 100644 (file)
                51C81B8A0C4422F70019ECE3 /* FTPDirectoryParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */; };
                51CBFC990D10E483002DBF51 /* CachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51D0C5160DAA90B7003B3831 /* JSStorageCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */; };
+               51D1248B1E73627F002B2820 /* NetworkStorageSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */; };
+               51D1248D1E7364AA002B2820 /* CookieCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248C1E736456002B2820 /* CookieCocoa.mm */; };
                51D7236C1BB6174900478CA3 /* IDBResultData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D7236A1BB60BFE00478CA3 /* IDBResultData.cpp */; };
                51D7236D1BB6174900478CA3 /* IDBResultData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D7236B1BB60BFE00478CA3 /* IDBResultData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51D7EFEA1BDE8F8C00E93E10 /* ThreadSafeDataBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 511FAEA91BDC989A00B4AFE4 /* ThreadSafeDataBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryParser.h; sourceTree = "<group>"; };
                51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFramePlatformData.h; sourceTree = "<group>"; };
                51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStorageCustom.cpp; sourceTree = "<group>"; };
+               51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStorageSessionCocoa.mm; sourceTree = "<group>"; };
+               51D1248C1E736456002B2820 /* CookieCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieCocoa.mm; sourceTree = "<group>"; };
                51D7196C181106DF0016DC51 /* DOMWindowIndexedDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowIndexedDatabase.cpp; sourceTree = "<group>"; };
                51D7196D181106DF0016DC51 /* DOMWindowIndexedDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindowIndexedDatabase.h; sourceTree = "<group>"; };
                51D7196E181106DF0016DC51 /* DOMWindowIndexedDatabase.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMWindowIndexedDatabase.idl; sourceTree = "<group>"; };
                7E7DE1FE195CEF2D0035363B /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               51D1248C1E736456002B2820 /* CookieCocoa.mm */,
                                3792917C1987678F00F4B661 /* CredentialCocoa.h */,
                                3792917B1987678F00F4B661 /* CredentialCocoa.mm */,
                                5C9B860B1C21E3C600110F36 /* NetworkLoadMetrics.mm */,
+                               51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */,
                                372ADA37197F47B900FC501E /* ProtectionSpaceCocoa.h */,
                                372ADA39197F687600FC501E /* ProtectionSpaceCocoa.mm */,
                                7E7DE1FC195CEF260035363B /* ResourceRequestCocoa.mm */,
                                CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */,
                                5D8C4DBF1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp in Sources */,
                                FD31609012B026F700C1A359 /* Distance.cpp in Sources */,
+                               51D1248B1E73627F002B2820 /* NetworkStorageSessionCocoa.mm in Sources */,
                                A1E1154413015C3D0054AC8C /* DistantLightSource.cpp in Sources */,
                                B2F34FE90E82F82700F627CD /* DNSCFNet.cpp in Sources */,
                                F293B27E56C112F373FFF27E /* DNSResolveQueue.cpp in Sources */,
                                BCAA90C30A7EBA60008B1229 /* Scrollbar.cpp in Sources */,
                                0F09087F1444FDB200028917 /* ScrollbarTheme.cpp in Sources */,
                                BC14028A0E83680800319717 /* ScrollbarThemeComposite.cpp in Sources */,
+                               51D1248D1E7364AA002B2820 /* CookieCocoa.mm in Sources */,
                                44C991820F3D1E0D00586670 /* ScrollbarThemeIOS.mm in Sources */,
                                BCEF869F0E844E9D00A85CD5 /* ScrollbarThemeMac.mm in Sources */,
                                0FE71405142170B800DB33BA /* ScrollbarThemeMock.cpp in Sources */,
index ef93dff..3e8a785 100644 (file)
@@ -83,9 +83,4 @@ void deleteCookie(const Document& document, const URL& url, const String& cookie
     platformStrategies()->cookiesStrategy()->deleteCookie(storageSession(document), url, cookieName);
 }
 
-void addCookie(const Document& document, const URL& url, const Cookie& cookie)
-{
-    platformStrategies()->cookiesStrategy()->addCookie(storageSession(document), url, cookie);
-}
-
 }
index 0a53d96..220a9b9 100644 (file)
@@ -45,6 +45,5 @@ WEBCORE_EXPORT bool cookiesEnabled(const Document&);
 WEBCORE_EXPORT String cookieRequestHeaderFieldValue(const Document&, const URL&);
 WEBCORE_EXPORT bool getRawCookies(const Document&, const URL&, Vector<Cookie>&);
 WEBCORE_EXPORT void deleteCookie(const Document&, const URL&, const String& cookieName);
-WEBCORE_EXPORT void addCookie(const Document&, const URL&, const Cookie&);
 
 } // namespace WebCore
index 961dfe5..724abab 100644 (file)
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
 
+#ifdef __OBJC__
+#include <objc/objc.h>
+#endif
+
 namespace WebCore {
 
-    struct Cookie {
-        Cookie() { }
-
-        Cookie(const String& name, const String& value, const String& domain,
-                const String& path, double expires, bool httpOnly, bool secure,
-                bool session)
-            : name(name)
-            , value(value)
-            , domain(domain)
-            , path(path)
-            , expires(expires)
-            , httpOnly(httpOnly)
-            , secure(secure)
-            , session(session)
-        {
-        }
-
-        String name;
-        String value;
-        String domain;
-        String path;
-        // Expiration date, expressed as milliseconds since the UNIX epoch.
-        double expires;
-        bool httpOnly;
-        bool secure;
-        bool session;
-    };
+struct Cookie {
+    Cookie() { }
 
-    struct CookieHash {
-        static unsigned hash(const Cookie& key)
-        { 
-            return StringHash::hash(key.name) + StringHash::hash(key.domain) + StringHash::hash(key.path) + key.secure;
-        }
+    Cookie(const String& name, const String& value, const String& domain, const String& path, double expires, bool httpOnly, bool secure, bool session)
+        : name(name)
+        , value(value)
+        , domain(domain)
+        , path(path)
+        , expires(expires)
+        , httpOnly(httpOnly)
+        , secure(secure)
+        , session(session)
+    {
+    }
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static bool decode(Decoder&, Cookie&);
+
+#ifdef __OBJC__
+    operator NSHTTPCookie *() const;
+#endif
+
+    String name;
+    String value;
+    String domain;
+    String path;
+    // Expiration date, expressed as milliseconds since the UNIX epoch.
+    double expires;
+    bool httpOnly;
+    bool secure;
+    bool session;
+};
+
+struct CookieHash {
+    static unsigned hash(const Cookie& key)
+    { 
+        return StringHash::hash(key.name) + StringHash::hash(key.domain) + StringHash::hash(key.path) + key.secure;
+    }
+
+    static bool equal(const Cookie& a, const Cookie& b)
+    {
+        return a.name == b.name && a.domain == b.domain && a.path == b.path && a.secure == b.secure;
+    }
+};
+
+template<class Encoder>
+void Cookie::encode(Encoder& encoder) const
+{
+    encoder << name;
+    encoder << value;
+    encoder << domain;
+    encoder << path;
+    encoder << expires;
+    encoder << httpOnly;
+    encoder << secure;
+    encoder << session;
+}
+
+template<class Decoder>
+bool Cookie::decode(Decoder& decoder, Cookie& cookie)
+{
+    if (!decoder.decode(cookie.name))
+        return false;
+    if (!decoder.decode(cookie.value))
+        return false;
+    if (!decoder.decode(cookie.domain))
+        return false;
+    if (!decoder.decode(cookie.path))
+        return false;
+    if (!decoder.decode(cookie.expires))
+        return false;
+    if (!decoder.decode(cookie.httpOnly))
+        return false;
+    if (!decoder.decode(cookie.secure))
+        return false;
+    if (!decoder.decode(cookie.session))
+        return false;
+
+    return true;
+}
 
-        static bool equal(const Cookie& a, const Cookie& b)
-        {
-            return a.name == b.name && a.domain == b.domain && a.path == b.path && a.secure == b.secure;
-        }
-    };
 }
 
 namespace WTF {
index 605dc1f..e049be3 100644 (file)
@@ -45,7 +45,6 @@ public:
     virtual String cookieRequestHeaderFieldValue(SessionID, const URL& firstParty, const URL&) = 0;
     virtual bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>&) = 0;
     virtual void deleteCookie(const NetworkStorageSession&, const URL&, const String& cookieName) = 0;
-    virtual void addCookie(const NetworkStorageSession&, const URL&, const Cookie&) = 0;
 
 protected:
     virtual ~CookiesStrategy() { }
index 62cf2ad..f1489c6 100644 (file)
 typedef struct _SoupCookieJar SoupCookieJar;
 #endif
 
+#ifdef __OBJC__
+#include <objc/objc.h>
+#endif
+
 namespace WebCore {
 
 class NetworkingContext;
 class ResourceRequest;
 class SoupNetworkSession;
 
+struct Cookie;
+
 class NetworkStorageSession {
     WTF_MAKE_NONCOPYABLE(NetworkStorageSession); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -61,6 +67,10 @@ public:
     SessionID sessionID() const { return m_sessionID; }
     CredentialStorage& credentialStorage() { return m_credentialStorage; }
 
+#ifdef __OBJC__
+    NSHTTPCookieStorage *nsCookieStorage() const;
+#endif
+
 #if PLATFORM(COCOA) || USE(CFURLCONNECTION)
     NetworkStorageSession(SessionID, RetainPtr<CFURLStorageSessionRef>);
 
@@ -90,6 +100,8 @@ public:
     NetworkingContext* context() const;
 #endif
 
+    WEBCORE_EXPORT void setCookies(const Vector<Cookie>&, const URL&, const URL& mainDocumentURL);
+
 private:
     static HashMap<SessionID, std::unique_ptr<NetworkStorageSession>>& globalSessionMap();
     SessionID m_sessionID;
index d7270c7..d082c8b 100644 (file)
@@ -46,7 +46,6 @@ WEBCORE_EXPORT bool cookiesEnabled(const NetworkStorageSession&, const URL& firs
 WEBCORE_EXPORT String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const URL&);
 WEBCORE_EXPORT bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const URL&, Vector<Cookie>&);
 WEBCORE_EXPORT void deleteCookie(const NetworkStorageSession&, const URL&, const String&);
-WEBCORE_EXPORT void addCookie(const NetworkStorageSession&, const URL&, const Cookie&);
 WEBCORE_EXPORT void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames);
 WEBCORE_EXPORT void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames);
 WEBCORE_EXPORT void deleteAllCookies(const NetworkStorageSession&);
index 563055d..cf92fea 100644 (file)
@@ -218,12 +218,6 @@ void deleteCookie(const NetworkStorageSession& session, const URL& url, const St
     }
 }
 
-void addCookie(const NetworkStorageSession&, const URL&, const Cookie&)
-{
-    // FIXME: implement this command. <https://webkit.org/b/156298>
-    notImplemented();
-}
-
 void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
     RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookies(session.cookieStorage().get()));
index ba06a5b..34eeea1 100644 (file)
@@ -166,4 +166,11 @@ void NetworkStorageSession::setShouldPartitionCookiesForHosts(const Vector<Strin
 
 #endif // HAVE(CFNETWORK_STORAGE_PARTITIONING)
 
+#if !PLATFORM(COCOA)
+void NetworkStorageSession::setCookies(const Vector<Cookie>&, const URL&, const URL&)
+{
+    // FIXME: Implement this. <https://webkit.org/b/156298>
+}
+#endif
+
 }
diff --git a/Source/WebCore/platform/network/cocoa/CookieCocoa.mm b/Source/WebCore/platform/network/cocoa/CookieCocoa.mm
new file mode 100644 (file)
index 0000000..c1122b1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 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. ``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
+ * 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 "Cookie.h"
+
+#import <wtf/BlockObjCExceptions.h>
+
+namespace WebCore {
+
+Cookie::operator NSHTTPCookie *() const
+{
+    // FIXME: existing APIs do not provide a way to set httpOnly without parsing headers from scratch.
+
+    BEGIN_BLOCK_OBJC_EXCEPTIONS
+
+    return [NSHTTPCookie cookieWithProperties:@{
+        NSHTTPCookieName: name,
+        NSHTTPCookieValue: value,
+        NSHTTPCookieDomain: domain,
+        NSHTTPCookiePath: path,
+        NSHTTPCookieDomain: domain,
+        NSHTTPCookieSecure: @(secure),
+        NSHTTPCookieDiscard: @(session),
+        NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSince1970:expires / 1000.0],
+        }];
+
+    END_BLOCK_OBJC_EXCEPTIONS
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm b/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
new file mode 100644 (file)
index 0000000..44aeab7
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2015 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. ``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
+ * 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 "NetworkStorageSession.h"
+
+#import "Cookie.h"
+#import "URL.h"
+#import <wtf/BlockObjCExceptions.h>
+
+namespace WebCore {
+
+void NetworkStorageSession::setCookies(const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL)
+{
+    RetainPtr<NSMutableArray> nsCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:cookies.size()]);
+    for (auto cookie : cookies)
+        [nsCookies addObject:(NSHTTPCookie *)cookie];
+
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    [nsCookieStorage() setCookies:nsCookies.get() forURL:(NSURL *)url mainDocumentURL:(NSURL *)mainDocumentURL];
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+NSHTTPCookieStorage *NetworkStorageSession::nsCookieStorage() const
+{
+    auto cfCookieStorage = cookieStorage();
+    if (!cfCookieStorage || [NSHTTPCookieStorage sharedHTTPCookieStorage]._cookieStorage == cfCookieStorage)
+        return [NSHTTPCookieStorage sharedHTTPCookieStorage];
+
+    return [[[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cfCookieStorage.get()] autorelease];
+}
+
+} // namespace WebCore
index 24a2c74..9b1bb47 100644 (file)
@@ -332,12 +332,6 @@ void deleteCookie(const NetworkStorageSession&, const URL&, const String&)
     // FIXME: Not yet implemented
 }
 
-void addCookie(const NetworkStorageSession&, const URL&, const Cookie&)
-{
-    // FIXME: implement this command. <https://webkit.org/b/156296>
-    notImplemented();
-}
-
 void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames)
 {
     // FIXME: Not yet implemented
index c7cc0f0..23f7015 100644 (file)
 #import "WebCoreSystemInterface.h"
 #import <wtf/BlockObjCExceptions.h>
 
-namespace WebCore {
-static NSHTTPCookieStorage *cookieStorage(const NetworkStorageSession&);
-}
-
 #if !USE(CFURLCONNECTION)
 
 #import "Cookie.h"
@@ -260,38 +256,6 @@ void deleteCookie(const NetworkStorageSession& session, const URL& url, const St
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void addCookie(const NetworkStorageSession& session, const URL& url, const Cookie& cookie)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
-
-    // FIXME: existing APIs do not provide a way to set httpOnly without parsing headers from scratch.
-
-    NSURL *originURL = url;
-    NSHTTPCookie *httpCookie = [NSHTTPCookie cookieWithProperties:@{
-        NSHTTPCookieName: cookie.name,
-        NSHTTPCookieValue: cookie.value,
-        NSHTTPCookieDomain: cookie.domain,
-        NSHTTPCookiePath: cookie.path,
-        NSHTTPCookieOriginURL: originURL,
-        NSHTTPCookieSecure: @(cookie.secure),
-        NSHTTPCookieDiscard: @(cookie.session),
-        NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSince1970:cookie.expires / 1000.0],
-    }];
-
-#if !USE(CFURLCONNECTION)
-    if (!cookieStorage) {
-        [WebCore::cookieStorage(session) setCookie:httpCookie];
-        return;
-    }
-#endif // !USE(CFURLCONNECTION)
-
-    CFHTTPCookieStorageSetCookie(cookieStorage.get(), [httpCookie _CFHTTPCookie]);
-
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
 void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -315,15 +279,6 @@ void deleteAllCookies(const NetworkStorageSession& session)
 
 namespace WebCore {
 
-static NSHTTPCookieStorage *cookieStorage(const NetworkStorageSession& session)
-{
-    auto cookieStorage = session.cookieStorage();
-    if (!cookieStorage || [NSHTTPCookieStorage sharedHTTPCookieStorage]._cookieStorage == cookieStorage)
-        return [NSHTTPCookieStorage sharedHTTPCookieStorage];
-
-    return [[[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorage.get()] autorelease];
-}
-
 void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& hostnames)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
@@ -348,7 +303,7 @@ void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vecto
             wkDeleteHTTPCookie(cookieStorage.get(), cookie.get());
     }
 
-    [WebCore::cookieStorage(session) _saveCookies];
+    [session.nsCookieStorage() _saveCookies];
 
     END_BLOCK_OBJC_EXCEPTIONS;
 }
@@ -361,7 +316,7 @@ void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, std::ch
     NSTimeInterval timeInterval = std::chrono::duration_cast<std::chrono::duration<double>>(timePoint.time_since_epoch()).count();
     NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
 
-    NSHTTPCookieStorage *storage = cookieStorage(session);
+    auto *storage = session.nsCookieStorage();
 
     [storage removeCookiesSinceDate:date];
     [storage _saveCookies];
index 31f009d..8e05364 100644 (file)
@@ -144,33 +144,6 @@ void deleteCookie(const NetworkStorageSession& session, const URL& url, const St
     }
 }
 
-static SoupDate* msToSoupDate(double ms)
-{
-    int year = msToYear(ms);
-    int dayOfYear = dayInYear(ms, year);
-    bool leapYear = isLeapYear(year);
-    return soup_date_new(year, monthFromDayInYear(dayOfYear, leapYear), dayInMonthFromDayInYear(dayOfYear, leapYear), msToHours(ms), msToMinutes(ms), static_cast<int>(ms / 1000) % 60);
-}
-
-static SoupCookie* toSoupCookie(const Cookie& cookie)
-{
-    SoupCookie* soupCookie = soup_cookie_new(cookie.name.utf8().data(), cookie.value.utf8().data(),
-        cookie.domain.utf8().data(), cookie.path.utf8().data(), -1);
-    soup_cookie_set_http_only(soupCookie, cookie.httpOnly);
-    soup_cookie_set_secure(soupCookie, cookie.secure);
-    if (!cookie.session) {
-        SoupDate* date = msToSoupDate(cookie.expires);
-        soup_cookie_set_expires(soupCookie, date);
-        soup_date_free(date);
-    }
-    return soupCookie;
-}
-
-void addCookie(const NetworkStorageSession& session, const URL&, const Cookie& cookie)
-{
-    soup_cookie_jar_add_cookie(session.cookieStorage(), toSoupCookie(cookie));
-}
-
 void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
     GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(session.cookieStorage()));
index 8417691..249bd82 100644 (file)
 
 #if USE(SOUP)
 
+#include "Cookie.h"
 #include "ResourceHandle.h"
 #include "SoupNetworkSession.h"
 #include <libsoup/soup.h>
+#include <wtf/DateMath.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/glib/GUniquePtr.h>
@@ -274,6 +276,35 @@ void NetworkStorageSession::saveCredentialToPersistentStorage(const ProtectionSp
 #endif
 }
 
+static SoupDate* msToSoupDate(double ms)
+{
+    int year = msToYear(ms);
+    int dayOfYear = dayInYear(ms, year);
+    bool leapYear = isLeapYear(year);
+    return soup_date_new(year, monthFromDayInYear(dayOfYear, leapYear), dayInMonthFromDayInYear(dayOfYear, leapYear), msToHours(ms), msToMinutes(ms), static_cast<int>(ms / 1000) % 60);
+}
+
+static SoupCookie* toSoupCookie(const Cookie& cookie)
+{
+    SoupCookie* soupCookie = soup_cookie_new(cookie.name.utf8().data(), cookie.value.utf8().data(),
+        cookie.domain.utf8().data(), cookie.path.utf8().data(), -1);
+    soup_cookie_set_http_only(soupCookie, cookie.httpOnly);
+    soup_cookie_set_secure(soupCookie, cookie.secure);
+    if (!cookie.session) {
+        SoupDate* date = msToSoupDate(cookie.expires);
+        soup_cookie_set_expires(soupCookie, date);
+        soup_date_free(date);
+    }
+    return soupCookie;
+}
+
+void NetworkStorageSession::setCookies(const Vector<Cookie>& cookies, const URL&, const URL&)
+{
+    for (auto cookie : cookies)
+        soup_cookie_jar_add_cookie(cookieStorage(), toSoupCookie(cookie));
+}
+
+
 } // namespace WebCore
 
 #endif // USE(SOUP)
index 9e22f76..7d4abaf 100644 (file)
@@ -1,3 +1,14 @@
+2017-03-11  Brady Eidson  <beidson@apple.com>
+
+        Cleanup "addCookie" and its sole user.
+        https://bugs.webkit.org/show_bug.cgi?id=169486
+
+        Reviewed by Brian Burg.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::addCookie): Deleted.
+
 2017-03-10  Alex Christensen  <achristensen@webkit.org>
 
         Fix watch and tv builds after r213294
index a60271b..ca938be 100644 (file)
@@ -55,7 +55,6 @@ private:
     String cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&) override;
     bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&) override;
     void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const String&) override;
-    void addCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const WebCore::Cookie&) override;
 
     // WebCore::PasteboardStrategy
 #if PLATFORM(IOS)
index 19ff5e0..ac2fb44 100644 (file)
@@ -110,11 +110,6 @@ void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, c
     WebCore::deleteCookie(session, url, cookieName);
 }
 
-void WebPlatformStrategies::addCookie(const NetworkStorageSession& session, const URL& url, const Cookie& cookie)
-{
-    WebCore::addCookie(session, url, cookie);
-}
-
 void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName)
 {
     PlatformPasteboard(pasteboardName).getTypes(types);
index 4f84507..560ad5b 100644 (file)
@@ -1,3 +1,38 @@
+2017-03-11  Brady Eidson  <beidson@apple.com>
+
+        Cleanup "addCookie" and its sole user.
+        https://bugs.webkit.org/show_bug.cgi?id=169486
+
+        Reviewed by Brian Burg.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::addCookie): Deleted.
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<Cookie>::encode): Deleted.
+        (IPC::ArgumentCoder<Cookie>::decode): Deleted.
+        * Shared/WebCoreArgumentCoders.h:
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::addSingleCookie):
+
+        * UIProcess/WebCookieManagerProxy.cpp:
+        (WebKit::WebCookieManagerProxy::setCookies):
+        (WebKit::WebCookieManagerProxy::addCookie): Deleted.
+        * UIProcess/WebCookieManagerProxy.h:
+
+        * WebProcess/Cookies/WebCookieManager.cpp:
+        (WebKit::WebCookieManager::setCookies):
+        (WebKit::WebCookieManager::addCookie): Deleted.
+        * WebProcess/Cookies/WebCookieManager.h:
+        * WebProcess/Cookies/WebCookieManager.messages.in:
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::addCookie): Deleted.
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2017-03-10  Alex Christensen  <achristensen@webkit.org>
 
         Fix watch and tv builds after r213294
index 1416242..1f92ce8 100644 (file)
@@ -279,11 +279,6 @@ void NetworkConnectionToWebProcess::deleteCookie(SessionID sessionID, const URL&
     WebCore::deleteCookie(storageSession(sessionID), url, cookieName);
 }
 
-void NetworkConnectionToWebProcess::addCookie(SessionID sessionID, const URL& url, const Cookie& cookie)
-{
-    WebCore::addCookie(storageSession(sessionID), url, cookie);
-}
-
 void NetworkConnectionToWebProcess::registerFileBlobURL(const URL& url, const String& path, const SandboxExtension::Handle& extensionHandle, const String& contentType)
 {
     RefPtr<SandboxExtension> extension = SandboxExtension::create(extensionHandle);
index 9729314..24cf0b0 100644 (file)
@@ -91,7 +91,6 @@ private:
     void cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
     void getRawCookies(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&);
     void deleteCookie(WebCore::SessionID, const WebCore::URL&, const String& cookieName);
-    void addCookie(WebCore::SessionID, const WebCore::URL&, const WebCore::Cookie&);
 
     void registerFileBlobURL(const WebCore::URL&, const String& path, const SandboxExtension::Handle&, const String& contentType);
     void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>&&, const String& contentType);
index a263a4e..0b39d7e 100644 (file)
@@ -38,7 +38,6 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver {
     CookieRequestHeaderFieldValue(WebCore::SessionID sessionID, WebCore::URL firstParty, WebCore::URL url) -> (String result)
     GetRawCookies(WebCore::SessionID sessionID, WebCore::URL firstParty, WebCore::URL url) -> (Vector<WebCore::Cookie> cookies)
     DeleteCookie(WebCore::SessionID sessionID, WebCore::URL url, String cookieName)
-    AddCookie(WebCore::SessionID sessionID, WebCore::URL url, struct WebCore::Cookie cookie)
 
     RegisterFileBlobURL(WebCore::URL url, String path, WebKit::SandboxExtension::Handle extensionHandle, String contentType)
     RegisterBlobURL(WebCore::URL url, Vector<WebCore::BlobPart> blobParts, String contentType)
index 84ccf8f..90f6ebb 100644 (file)
@@ -31,7 +31,6 @@
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/BlobPart.h>
 #include <WebCore/CertificateInfo.h>
-#include <WebCore/Cookie.h>
 #include <WebCore/Credential.h>
 #include <WebCore/Cursor.h>
 #include <WebCore/DatabaseDetails.h>
@@ -1284,41 +1283,6 @@ bool ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder, CompositionUn
     return true;
 }
 
-
-void ArgumentCoder<Cookie>::encode(Encoder& encoder, const Cookie& cookie)
-{
-    encoder << cookie.name;
-    encoder << cookie.value;
-    encoder << cookie.domain;
-    encoder << cookie.path;
-    encoder << cookie.expires;
-    encoder << cookie.httpOnly;
-    encoder << cookie.secure;
-    encoder << cookie.session;
-}
-
-bool ArgumentCoder<Cookie>::decode(Decoder& decoder, Cookie& cookie)
-{
-    if (!decoder.decode(cookie.name))
-        return false;
-    if (!decoder.decode(cookie.value))
-        return false;
-    if (!decoder.decode(cookie.domain))
-        return false;
-    if (!decoder.decode(cookie.path))
-        return false;
-    if (!decoder.decode(cookie.expires))
-        return false;
-    if (!decoder.decode(cookie.httpOnly))
-        return false;
-    if (!decoder.decode(cookie.secure))
-        return false;
-    if (!decoder.decode(cookie.session))
-        return false;
-
-    return true;
-}
-
 void ArgumentCoder<DatabaseDetails>::encode(Encoder& encoder, const DatabaseDetails& details)
 {
     encoder << details.name();
index 742277e..efb7b17 100644 (file)
@@ -83,7 +83,6 @@ class UserStyleSheet;
 class UserScript;
 class URL;
 struct CompositionUnderline;
-struct Cookie;
 struct DictationAlternative;
 struct DictionaryPopupInfo;
 struct EventTrackingRegions;
@@ -405,11 +404,6 @@ template<> struct ArgumentCoder<WebCore::CompositionUnderline> {
     static bool decode(Decoder&, WebCore::CompositionUnderline&);
 };
 
-template<> struct ArgumentCoder<WebCore::Cookie> {
-    static void encode(Encoder&, const WebCore::Cookie&);
-    static bool decode(Decoder&, WebCore::Cookie&);
-};
-
 template<> struct ArgumentCoder<WebCore::DatabaseDetails> {
     static void encode(Encoder&, const WebCore::DatabaseDetails&);
     static bool decode(Decoder&, WebCore::DatabaseDetails&);
index de5be9e..48cadc7 100644 (file)
@@ -727,7 +727,10 @@ void WebAutomationSession::addSingleCookie(ErrorString& errorString, const Strin
         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(MissingParameter, "The parameter 'httpOnly' was not found.");
 
     WebCookieManagerProxy* cookieManager = m_processPool->supplement<WebCookieManagerProxy>();
-    cookieManager->addCookie(WebCore::SessionID::defaultSessionID(), cookie, activeURL.host());
+
+    // 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);
 
     callback->sendSuccess();
 }
index 08a7979..5d81fad 100644 (file)
@@ -129,9 +129,9 @@ void WebCookieManagerProxy::deleteAllCookiesModifiedSince(WebCore::SessionID ses
     processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookiesModifiedSince(sessionID, time));
 }
 
-void WebCookieManagerProxy::addCookie(WebCore::SessionID sessionID, const WebCore::Cookie& cookie, const String& hostname)
+void WebCookieManagerProxy::setCookies(WebCore::SessionID sessionID, const Vector<WebCore::Cookie>& cookies, const WebCore::URL& url, const WebCore::URL& mainDocumentURL)
 {
-    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::AddCookie(sessionID, cookie, hostname));
+    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetCookies(sessionID, cookies, url, mainDocumentURL));
 }
 
 void WebCookieManagerProxy::startObservingCookieChanges(WebCore::SessionID sessionID)
index 65d047c..4ad676c 100644 (file)
@@ -69,7 +69,8 @@ public:
     void deleteCookiesForHostname(WebCore::SessionID, const String& hostname);
     void deleteAllCookies(WebCore::SessionID);
     void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point);
-    void addCookie(WebCore::SessionID, const WebCore::Cookie&, const String& hostname);
+
+    void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL);
 
     void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
     void getHTTPCookieAcceptPolicy(std::function<void (HTTPCookieAcceptPolicy, CallbackBase::Error)>);
index 4bf6773..9e21f78 100644 (file)
@@ -30,6 +30,7 @@
 #include "WebCookieManagerMessages.h"
 #include "WebCookieManagerProxyMessages.h"
 #include "WebCoreArgumentCoders.h"
+#include <WebCore/Cookie.h>
 #include <WebCore/CookieStorage.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/PlatformCookieJar.h>
@@ -83,10 +84,10 @@ void WebCookieManager::deleteAllCookiesModifiedSince(SessionID sessionID, std::c
         WebCore::deleteAllCookiesModifiedSince(*storageSession, time);
 }
 
-void WebCookieManager::addCookie(SessionID sessionID, const Cookie& cookie, const String& hostname)
+void WebCookieManager::setCookies(WebCore::SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL)
 {
     if (auto* storageSession = NetworkStorageSession::storageSession(sessionID))
-        WebCore::addCookie(*storageSession, URL(URL(), hostname), cookie);
+        storageSession->setCookies(cookies, url, mainDocumentURL);
 }
 
 void WebCookieManager::notifyCookiesDidChange(SessionID sessionID)
index 7ed658f..db27d20 100644 (file)
 #include <stdint.h>
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
 
 #if USE(SOUP)
 #include "SoupCookiePersistentStorageType.h"
 #endif
 
 namespace WebCore {
+class URL;
 struct Cookie;
 }
 
@@ -69,7 +71,8 @@ private:
     void deleteCookiesForHostname(WebCore::SessionID, const String&);
     void deleteAllCookies(WebCore::SessionID);
     void deleteAllCookiesModifiedSince(WebCore::SessionID, std::chrono::system_clock::time_point);
-    void addCookie(WebCore::SessionID, const WebCore::Cookie&, const String& hostname);
+
+    void setCookies(WebCore::SessionID, const Vector<WebCore::Cookie>&, const WebCore::URL&, const WebCore::URL& mainDocumentURL);
 
     void platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
     void getHTTPCookieAcceptPolicy(uint64_t callbackID);
index 5d51536..00e7b65 100644 (file)
@@ -28,7 +28,8 @@
     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 AddCookie(WebCore::SessionID sessionID, struct WebCore::Cookie cookie, String hostname)
+
+    void SetCookies(WebCore::SessionID sessionID, Vector<WebCore::Cookie> cookies, WebCore::URL url, WebCore::URL mainDocumentURL);
 
     void SetHTTPCookieAcceptPolicy(uint32_t policy)
     void GetHTTPCookieAcceptPolicy(uint64_t callbackID)
index c03970a..bf4bdae 100644 (file)
@@ -155,11 +155,6 @@ void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, c
     WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::DeleteCookie(session.sessionID(), url, cookieName), 0);
 }
 
-void WebPlatformStrategies::addCookie(const NetworkStorageSession& session, const URL& url, const Cookie& cookie)
-{
-    WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::AddCookie(session.sessionID(), url, cookie), 0);
-}
-
 #if PLATFORM(COCOA)
 // PasteboardStrategy
 
index c69ea51..355d8a6 100644 (file)
@@ -56,7 +56,6 @@ private:
     String cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&) override;
     bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&) override;
     void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const String&) override;
-    void addCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const WebCore::Cookie&) override;
 
     // WebCore::PasteboardStrategy
 #if PLATFORM(IOS)