Title: [199167] trunk/Source
Revision
199167
Author
[email protected]
Date
2016-04-07 12:00:53 -0700 (Thu, 07 Apr 2016)

Log Message

CookieJar should support adding synthetic cookies for developer tools
https://bugs.webkit.org/show_bug.cgi?id=156091
<rdar://problem/25581340>

Reviewed by Timothy Hatcher.

Source/WebCore:

This patch adds an API that can set an arbitrary cookie in cookie storage
in order to support developer tools and automated testing. It delegates storing
the cookie to a platform implementation.

No new tests because the code isn't used by any clients yet.

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

* platform/Cookie.h:
Remove an outdated comment. This struct is used in many places.

* platform/CookiesStrategy.h: Add new method.
* platform/network/PlatformCookieJar.h: Add new method.
* platform/network/cf/CookieJarCFNet.cpp:
(WebCore::addCookie): Add a stub.
* platform/network/curl/CookieJarCurl.cpp:
(WebCore::addCookie): Add a stub.
* platform/network/mac/CookieJarMac.mm:
(WebCore::addCookie): Add an implementation that turns the WebCore::Cookie into
an NSHTTPCookie and converts it again to CFHTTPCookie if necessary.

* platform/network/soup/CookieJarSoup.cpp:
(WebCore::addCookie): Add a stub.

* platform/spi/cf/CFNetworkSPI.h:
Add -[NSHTTPCookie _CFHTTPCookie] SPI.

Source/WebKit/mac:

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::addCookie):
Add new method override.

Source/WebKit/win:

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.cpp:
Add new method override.

Source/WebKit2:

Plumb the new method through the strategy and out to the network process.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::addCookie):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::addCookie):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (199166 => 199167)


--- trunk/Source/WebCore/ChangeLog	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/ChangeLog	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,3 +1,40 @@
+2016-04-07  Brian Burg  <[email protected]>
+
+        CookieJar should support adding synthetic cookies for developer tools
+        https://bugs.webkit.org/show_bug.cgi?id=156091
+        <rdar://problem/25581340>
+
+        Reviewed by Timothy Hatcher.
+
+        This patch adds an API that can set an arbitrary cookie in cookie storage
+        in order to support developer tools and automated testing. It delegates storing
+        the cookie to a platform implementation.
+
+        No new tests because the code isn't used by any clients yet.
+
+        * loader/CookieJar.cpp:
+        (WebCore::addCookie): Added.
+        * loader/CookieJar.h:
+
+        * platform/Cookie.h:
+        Remove an outdated comment. This struct is used in many places.
+
+        * platform/CookiesStrategy.h: Add new method.
+        * platform/network/PlatformCookieJar.h: Add new method.
+        * platform/network/cf/CookieJarCFNet.cpp:
+        (WebCore::addCookie): Add a stub.
+        * platform/network/curl/CookieJarCurl.cpp:
+        (WebCore::addCookie): Add a stub.
+        * platform/network/mac/CookieJarMac.mm:
+        (WebCore::addCookie): Add an implementation that turns the WebCore::Cookie into
+        an NSHTTPCookie and converts it again to CFHTTPCookie if necessary.
+
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::addCookie): Add a stub.
+
+        * platform/spi/cf/CFNetworkSPI.h:
+        Add -[NSHTTPCookie _CFHTTPCookie] SPI.
+
 2016-04-07  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r199128 and r199141.

Modified: trunk/Source/WebCore/loader/CookieJar.cpp (199166 => 199167)


--- trunk/Source/WebCore/loader/CookieJar.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/loader/CookieJar.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -84,4 +84,9 @@
     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);
 }
+
+}

Modified: trunk/Source/WebCore/loader/CookieJar.h (199166 => 199167)


--- trunk/Source/WebCore/loader/CookieJar.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/loader/CookieJar.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2008, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2008, 2012, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,6 +47,7 @@
 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&);
 
 }
 

Modified: trunk/Source/WebCore/platform/Cookie.h (199166 => 199167)


--- trunk/Source/WebCore/platform/Cookie.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/Cookie.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -31,9 +31,6 @@
 
 namespace WebCore {
 
-    // This struct is currently only used to provide more cookies information
-    // to the Web Inspector.
-
     struct Cookie {
         Cookie() { }
 

Modified: trunk/Source/WebCore/platform/CookiesStrategy.h (199166 => 199167)


--- trunk/Source/WebCore/platform/CookiesStrategy.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/CookiesStrategy.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,6 +45,7 @@
     virtual String cookieRequestHeaderFieldValue(const NetworkStorageSession&, 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() { }

Modified: trunk/Source/WebCore/platform/network/PlatformCookieJar.h (199166 => 199167)


--- trunk/Source/WebCore/platform/network/PlatformCookieJar.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/network/PlatformCookieJar.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2008, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2008, 2012, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,6 +46,7 @@
 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&);

Modified: trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp (199166 => 199167)


--- trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2012, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
 #include "Cookie.h"
 #include "URL.h"
 #include "NetworkStorageSession.h"
+#include "NotImplemented.h"
 #include "SoftLinking.h"
 #include <CFNetwork/CFHTTPCookiesPriv.h>
 #include <CoreFoundation/CoreFoundation.h>
@@ -216,6 +217,12 @@
     }
 }
 
+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()));

Modified: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp (199166 => 199167)


--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -20,6 +20,7 @@
 #if USE(CURL)
 
 #include "Cookie.h"
+#include "NotImplemented.h"
 #include "URL.h"
 #include "ResourceHandleManager.h"
 
@@ -325,6 +326,12 @@
     // 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

Modified: trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm (199166 => 199167)


--- trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/network/mac/CookieJarMac.mm	2016-04-07 19:00:53 UTC (rev 199167)
@@ -31,6 +31,10 @@
 #import "NetworkStorageSession.h"
 #import "WebCoreSystemInterface.h"
 
+namespace WebCore {
+static NSHTTPCookieStorage *cookieStorage(const NetworkStorageSession&);
+}
+
 #if !USE(CFNETWORK)
 
 #import "Cookie.h"
@@ -242,6 +246,38 @@
     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(CFNETWORK)
+    if (!cookieStorage) {
+        [WebCore::cookieStorage(session) setCookie:httpCookie];
+        return;
+    }
+#endif // !USE(CFNETWORK)
+
+    CFHTTPCookieStorageSetCookie(cookieStorage.get(), [httpCookie _CFHTTPCookie]);
+
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
 void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;

Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp (199166 => 199167)


--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -28,6 +28,7 @@
 #include "GUniquePtrSoup.h"
 #include "URL.h"
 #include "NetworkingContext.h"
+#include "NotImplemented.h"
 #include "PlatformCookieJar.h"
 #include "SoupNetworkSession.h"
 #include <wtf/glib/GRefPtr.h>
@@ -191,6 +192,12 @@
     }
 }
 
+void addCookie(const NetworkStorageSession&, const URL&, const Cookie&)
+{
+    // FIXME: implement this command. <https://webkit.org/b/156295>
+    notImplemented();
+}
+
 void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
     SoupCookieJar* cookieJar = cookieJarForSession(session);

Modified: trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h (199166 => 199167)


--- trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebCore/platform/spi/cf/CFNetworkSPI.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -56,7 +56,7 @@
 #endif
 #endif // defined(__OBJC__) && PLATFORM(COCOA)
 
-#else // PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
+#else // !PLATFORM(WIN) && !USE(APPLE_INTERNAL_SDK)
 
 typedef CF_ENUM(int64_t, _TimingDataOptions)
 {
@@ -69,6 +69,7 @@
 typedef const struct _CFURLRequest* CFURLRequestRef;
 typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
 typedef const struct __CFData* CFDataRef;
+typedef const struct OpaqueCFHTTPCookie* CFHTTPCookieRef;
 typedef struct _CFURLConnection* CFURLConnectionRef;
 typedef struct _CFURLCredentialStorage* CFURLCredentialStorageRef;
 typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
@@ -97,6 +98,10 @@
 - (NSDictionary *)_timingData;
 @end
 
+@interface NSHTTPCookie ()
+- (CFHTTPCookieRef)_CFHTTPCookie;
+@end
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000)
 @interface NSURLSessionConfiguration ()
 @property (assign) _TimingDataOptions _timingDataOptions;
@@ -122,7 +127,7 @@
 
 #endif // defined(__OBJC__)
 
-#endif // PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
+#endif // !PLATFORM(WIN) && !USE(APPLE_INTERNAL_SDK)
 
 EXTERN_C void CFURLRequestSetShouldStartSynchronously(CFURLRequestRef, Boolean);
 
@@ -152,6 +157,7 @@
 #endif
 
 EXTERN_C CFHTTPCookieStorageRef _CFHTTPCookieStorageGetDefault(CFAllocatorRef);
+EXTERN_C void CFHTTPCookieStorageSetCookie(CFHTTPCookieStorageRef, CFHTTPCookieRef);
 EXTERN_C void CFHTTPCookieStorageSetCookieAcceptPolicy(CFHTTPCookieStorageRef, CFHTTPCookieStorageAcceptPolicy);
 EXTERN_C void _CFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);
 EXTERN_C CFURLCredentialStorageRef CFURLCredentialStorageCreate(CFAllocatorRef);

Modified: trunk/Source/WebKit/mac/ChangeLog (199166 => 199167)


--- trunk/Source/WebKit/mac/ChangeLog	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,3 +1,16 @@
+2016-04-07  Brian Burg  <[email protected]>
+
+        CookieJar should support adding synthetic cookies for developer tools
+        https://bugs.webkit.org/show_bug.cgi?id=156091
+        <rdar://problem/25581340>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::addCookie):
+        Add new method override.
+
 2016-04-06  Alex Christensen  <[email protected]>
 
         Fix CMake DumpRenderTree

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h (199166 => 199167)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -56,8 +56,8 @@
     String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, 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::PluginStrategy
     void refreshPlugins() override;
     void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&) override;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm (199166 => 199167)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2016-04-07 19:00:53 UTC (rev 199167)
@@ -112,6 +112,11 @@
     WebCore::deleteCookie(session, url, cookieName);
 }
 
+void WebPlatformStrategies::addCookie(const NetworkStorageSession& session, const URL& url, const Cookie& cookie)
+{
+    WebCore::addCookie(session, url, cookie);
+}
+
 void WebPlatformStrategies::refreshPlugins()
 {
     [[WebPluginDatabase sharedDatabaseIfExists] refresh];

Modified: trunk/Source/WebKit/win/ChangeLog (199166 => 199167)


--- trunk/Source/WebKit/win/ChangeLog	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit/win/ChangeLog	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,3 +1,15 @@
+2016-04-07  Brian Burg  <[email protected]>
+
+        CookieJar should support adding synthetic cookies for developer tools
+        https://bugs.webkit.org/show_bug.cgi?id=156091
+        <rdar://problem/25581340>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.cpp:
+        Add new method override.
+
 2016-03-24  Said Abou-Hallawa  <sabouhallawa@apple,com>
 
         Change NativeImagePtr for CG to be RetainPtr<CGImageRef>

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp (199166 => 199167)


--- trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -104,6 +104,11 @@
     WebCore::deleteCookie(session, url, cookieName);
 }
 
+void WebPlatformStrategies::addCookie(const NetworkStorageSession& session, const URL& url, const Cookie& cookie)
+{
+    WebCore::addCookie(session, url, cookie);
+}
+
 void WebPlatformStrategies::refreshPlugins()
 {
     PluginDatabase::installedPlugins()->refresh();

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h (199166 => 199167)


--- trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -52,6 +52,7 @@
     virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::URL& firstParty, const WebCore::URL&);
     virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&);
     virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const String&);
+    virtual void addCookie(const WebCore::NetworkStorageSession&, const WebCore::URL&, const WebCore::Cookie&);
 
     // WebCore::PluginStrategy
     virtual void refreshPlugins();

Modified: trunk/Source/WebKit2/ChangeLog (199166 => 199167)


--- trunk/Source/WebKit2/ChangeLog	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit2/ChangeLog	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,3 +1,21 @@
+2016-04-07  Brian Burg  <[email protected]>
+
+        CookieJar should support adding synthetic cookies for developer tools
+        https://bugs.webkit.org/show_bug.cgi?id=156091
+        <rdar://problem/25581340>
+
+        Reviewed by Timothy Hatcher.
+
+        Plumb the new method through the strategy and out to the network process.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::addCookie):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::addCookie):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2016-04-06  Alex Christensen  <[email protected]>
 
         Compile WebKitTestRunner with CMake on Mac

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (199166 => 199167)


--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -249,6 +249,11 @@
     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);

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (199166 => 199167)


--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -86,6 +86,7 @@
     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);

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (199166 => 199167)


--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2016-04-07 19:00:53 UTC (rev 199167)
@@ -38,6 +38,7 @@
     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)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (199166 => 199167)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011, 2012, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012, 2015, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -155,6 +155,11 @@
     WebProcess::singleton().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::DeleteCookie(SessionTracker::sessionID(session), url, cookieName), 0);
 }
 
+void WebPlatformStrategies::addCookie(const NetworkStorageSession& session, const URL& url, const Cookie& cookie)
+{
+    WebProcess::singleton().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::AddCookie(SessionTracker::sessionID(session), url, cookie), 0);
+}
+
 // PluginStrategy
 
 void WebPlatformStrategies::refreshPlugins()

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (199166 => 199167)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2016-04-07 18:38:15 UTC (rev 199166)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2016-04-07 19:00:53 UTC (rev 199167)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2012, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -58,6 +58,7 @@
     String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, 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::PluginStrategy
     void refreshPlugins() override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to