[Cocoa] Add SPI to WKProcessPool for enabling cookie storage partitioning
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2016 18:59:20 +0000 (18:59 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Aug 2016 18:59:20 +0000 (18:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160964

Reviewed by Brent Fulgham.

Source/WebCore:

* page/Settings.cpp:
(WebCore::Settings::setCookieStoragePartitioningEnabled): Deleted.
* page/Settings.h:
(WebCore::Settings::cookieStoragePartitioningEnabled): Deleted.
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp: Defined cookieStoragePartitioningEnabled.
(WebCore::NetworkStorageSession::setCookieStoragePartitioningEnabled): Set cookieStoragePartitioningEnabled.
(WebCore::cookieStoragePartition): Used cookieStoragePartitioningEnabled instead of Settings::cookieStoragePartitioningEnabled().

Source/WebKit2:

* NetworkProcess/NetworkProcess.h: Declared setCookieStoragePartitioningEnabled().
* NetworkProcess/NetworkProcess.messages.in: Added message SetCookieStoragePartitioningEnabled.
* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode): Encoded cookieStoragePartitioningEnabled.
(WebKit::NetworkProcessCreationParameters::decode): Decoded cookieStoragePartitioningEnabled.
* NetworkProcess/NetworkProcessCreationParameters.h: Declared cookieStoragePartitioningEnabled.
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
Called NetworkStorageSession::setCookieStoragePartitioningEnabled() given the cookieStoragePartitioningEnabled parameter.
(WebKit::NetworkProcess::setCookieStoragePartitioningEnabled):
Called NetworkStorageSession::setCookieStoragePartitioningEnabled().
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool cookieStoragePartitioningEnabled]): Returned WebProcessPool::cookieStoragePartitioningEnabled().
(-[WKProcessPool setCookieStoragePartitioningEnabled:]): Called WebProcessPool::setCookieStoragePartitioningEnabled().
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h: Declared cookieStoragePartitioningEnabled as a property.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
Set the cookieStoragePartitioningEnabled parameter from m_cookieStoragePartitioningEnabled.
(WebKit::WebProcessPool::setCookieStoragePartitioningEnabled):
Set m_cookieStoragePartitioningEnabled and sent the NetworkProcess::SetCookieStoragePartitioningEnabled message.
* UIProcess/WebProcessPool.h: Declared cookieStoragePartitioningEnabled.

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.cpp
Source/WebKit2/NetworkProcess/NetworkProcessCreationParameters.h
Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit2/UIProcess/WebProcessPool.h

index 883c8d7..dc2f4bc 100644 (file)
@@ -1,3 +1,19 @@
+2016-08-18  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] Add SPI to WKProcessPool for enabling cookie storage partitioning
+        https://bugs.webkit.org/show_bug.cgi?id=160964
+
+        Reviewed by Brent Fulgham.
+
+        * page/Settings.cpp:
+        (WebCore::Settings::setCookieStoragePartitioningEnabled): Deleted.
+        * page/Settings.h:
+        (WebCore::Settings::cookieStoragePartitioningEnabled): Deleted.
+        * platform/network/NetworkStorageSession.h:
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp: Defined cookieStoragePartitioningEnabled.
+        (WebCore::NetworkStorageSession::setCookieStoragePartitioningEnabled): Set cookieStoragePartitioningEnabled.
+        (WebCore::cookieStoragePartition): Used cookieStoragePartitioningEnabled instead of Settings::cookieStoragePartitioningEnabled().
+
 2016-08-18  Eric Carlson  <eric.carlson@apple.com>
 
         AX: Audio Description tracks are not labeled correctly, causing user confusion
index f0ea240..d3b520f 100644 (file)
@@ -83,7 +83,6 @@ bool Settings::gAVFoundationNSURLSessionEnabled = true;
 
 #if PLATFORM(COCOA)
 bool Settings::gQTKitEnabled = false;
-bool Settings::gCookieStoragePartitioningEnabled = false;
 #endif
 
 bool Settings::gMockScrollbarsEnabled = false;
@@ -598,11 +597,6 @@ void Settings::setQTKitEnabled(bool enabled)
     gQTKitEnabled = enabled;
     HTMLMediaElement::resetMediaEngines();
 }
-    
-void Settings::setCookieStoragePartitioningEnabled(bool enabled)
-{
-    gCookieStoragePartitioningEnabled = enabled;
-}
 #endif
 
 #if ENABLE(MEDIA_STREAM)
index 6f249a0..e40bd20 100644 (file)
@@ -24,8 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef Settings_h
-#define Settings_h
+#pragma once
 
 #include "ClipboardAccessPolicy.h"
 #include "EditingBehaviorTypes.h"
@@ -206,9 +205,6 @@ public:
 #if PLATFORM(COCOA)
     WEBCORE_EXPORT static void setQTKitEnabled(bool flag);
     static bool isQTKitEnabled() { return gQTKitEnabled; }
-
-    WEBCORE_EXPORT static void setCookieStoragePartitioningEnabled(bool flag);
-    static bool cookieStoragePartitioningEnabled() { return gCookieStoragePartitioningEnabled; }
 #else
     static bool isQTKitEnabled() { return false; }
 #endif
@@ -371,7 +367,6 @@ private:
 
 #if PLATFORM(COCOA)
     WEBCORE_EXPORT static bool gQTKitEnabled;
-    static bool gCookieStoragePartitioningEnabled;
 #endif
 
     static bool gMockScrollbarsEnabled;
@@ -409,5 +404,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif
index cd6c166..589b66e 100644 (file)
@@ -60,6 +60,7 @@ public:
     // May be null, in which case a Foundation default should be used.
     CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
     WEBCORE_EXPORT RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
+    WEBCORE_EXPORT static void setCookieStoragePartitioningEnabled(bool);
 #elif USE(SOUP)
     NetworkStorageSession(SessionID, std::unique_ptr<SoupNetworkSession>);
     ~NetworkStorageSession();
index 7bc4226..9a11d26 100644 (file)
@@ -33,7 +33,6 @@
 #if PLATFORM(COCOA)
 #include "PublicSuffix.h"
 #include "ResourceRequest.h"
-#include "Settings.h"
 #include "WebCoreSystemInterface.h"
 #else
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
@@ -41,6 +40,8 @@
 
 namespace WebCore {
 
+static bool cookieStoragePartitioningEnabled;
+
 NetworkStorageSession::NetworkStorageSession(SessionID sessionID, RetainPtr<CFURLStorageSessionRef> platformSession)
     : m_sessionID(sessionID)
     , m_platformSession(platformSession)
@@ -100,6 +101,11 @@ RetainPtr<CFHTTPCookieStorageRef> NetworkStorageSession::cookieStorage() const
 #endif
 }
 
+void NetworkStorageSession::setCookieStoragePartitioningEnabled(bool enabled)
+{
+    cookieStoragePartitioningEnabled = enabled;
+}
+
 #if PLATFORM(COCOA)
 
 String cookieStoragePartition(const ResourceRequest& request)
@@ -119,7 +125,7 @@ static inline bool hostIsInDomain(StringView host, StringView domain)
 
 String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource)
 {
-    if (!Settings::cookieStoragePartitioningEnabled())
+    if (!cookieStoragePartitioningEnabled)
         return emptyString();
 
     String firstPartyDomain = firstPartyForCookies.host();
index 3e51438..3c29387 100644 (file)
@@ -1,3 +1,32 @@
+2016-08-18  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] Add SPI to WKProcessPool for enabling cookie storage partitioning
+        https://bugs.webkit.org/show_bug.cgi?id=160964
+
+        Reviewed by Brent Fulgham.
+
+        * NetworkProcess/NetworkProcess.h: Declared setCookieStoragePartitioningEnabled().
+        * NetworkProcess/NetworkProcess.messages.in: Added message SetCookieStoragePartitioningEnabled.
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode): Encoded cookieStoragePartitioningEnabled.
+        (WebKit::NetworkProcessCreationParameters::decode): Decoded cookieStoragePartitioningEnabled.
+        * NetworkProcess/NetworkProcessCreationParameters.h: Declared cookieStoragePartitioningEnabled.
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+        Called NetworkStorageSession::setCookieStoragePartitioningEnabled() given the cookieStoragePartitioningEnabled parameter.
+        (WebKit::NetworkProcess::setCookieStoragePartitioningEnabled):
+        Called NetworkStorageSession::setCookieStoragePartitioningEnabled().
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool cookieStoragePartitioningEnabled]): Returned WebProcessPool::cookieStoragePartitioningEnabled().
+        (-[WKProcessPool setCookieStoragePartitioningEnabled:]): Called WebProcessPool::setCookieStoragePartitioningEnabled().
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: Declared cookieStoragePartitioningEnabled as a property.
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        Set the cookieStoragePartitioningEnabled parameter from m_cookieStoragePartitioningEnabled.
+        (WebKit::WebProcessPool::setCookieStoragePartitioningEnabled):
+        Set m_cookieStoragePartitioningEnabled and sent the NetworkProcess::SetCookieStoragePartitioningEnabled message.
+        * UIProcess/WebProcessPool.h: Declared cookieStoragePartitioningEnabled.
+
 2016-08-17  Anders Carlsson  <andersca@apple.com>
 
         Add support for additional networks
index 915069f..719945d 100644 (file)
@@ -218,6 +218,7 @@ private:
 
 #if PLATFORM(COCOA)
     void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&);
+    void setCookieStoragePartitioningEnabled(bool);
 
     // FIXME: We'd like to be able to do this without the #ifdef, but WorkQueue + BinarySemaphore isn't good enough since
     // multiple requests to clear the cache can come in before previous requests complete, and we need to wait for all of them.
index 959c13a..df40cf0 100644 (file)
@@ -57,6 +57,7 @@ messages -> NetworkProcess LegacyReceiver {
     SetProcessSuppressionEnabled(bool flag)
 #if PLATFORM(COCOA)
     SetQOS(int latencyQOS, int throughputQOS)
+    SetCookieStoragePartitioningEnabled(bool enabled)
 #endif
 
     AllowSpecificHTTPSCertificateForHost(WebCore::CertificateInfo certificate, String host)
index bc35404..21379e8 100644 (file)
@@ -74,6 +74,7 @@ void NetworkProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) con
 #if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
     IPC::encode(encoder, networkATSContext.get());
 #endif
+    encoder << cookieStoragePartitioningEnabled;
 #endif
 #if USE(SOUP)
     encoder << cookiePersistentStoragePath;
@@ -146,6 +147,8 @@ bool NetworkProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, Net
     if (!IPC::decode(decoder, result.networkATSContext))
         return false;
 #endif
+    if (!decoder.decode(result.cookieStoragePartitioningEnabled))
+        return false;
 #endif
 
 #if USE(SOUP)
index 5688194..4292ce9 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef NetworkProcessCreationParameters_h
-#define NetworkProcessCreationParameters_h
+#pragma once
 
 #include "Attachment.h"
 #include "CacheModel.h"
@@ -87,6 +86,7 @@ struct NetworkProcessCreationParameters {
 #if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
     RetainPtr<CFDataRef> networkATSContext;
 #endif
+    bool cookieStoragePartitioningEnabled;
 #endif
 
 #if USE(SOUP)
@@ -103,5 +103,3 @@ struct NetworkProcessCreationParameters {
 };
 
 } // namespace WebKit
-
-#endif // NetworkProcessCreationParameters_h
index 4ce5aa2..695d16f 100644 (file)
@@ -86,6 +86,8 @@ void NetworkProcess::platformInitializeNetworkProcessCocoa(const NetworkProcessC
     setSharedHTTPCookieStorage(parameters.uiProcessCookieStorageIdentifier);
 #endif
 
+    WebCore::NetworkStorageSession::setCookieStoragePartitioningEnabled(parameters.cookieStoragePartitioningEnabled);
+
     // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
     // - memory cache size passed from UI process is always ignored;
     // - disk cache size passed from UI process is effectively a minimum size.
@@ -235,4 +237,9 @@ void NetworkProcess::clearDiskCache(std::chrono::system_clock::time_point modifi
 #endif
 }
 
+void NetworkProcess::setCookieStoragePartitioningEnabled(bool enabled)
+{
+    WebCore::NetworkStorageSession::setCookieStoragePartitioningEnabled(enabled);
+}
+
 }
index 8c5c9a4..a92be2f 100644 (file)
@@ -290,6 +290,16 @@ static WebKit::HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(NSHTTPCookieAccep
     _processPool->terminateDatabaseProcess();
 }
 
+- (BOOL)cookieStoragePartitioningEnabled
+{
+    return _processPool->cookieStoragePartitioningEnabled();
+}
+
+- (void)setCookieStoragePartitioningEnabled:(BOOL)enabled
+{
+    _processPool->setCookieStoragePartitioningEnabled(enabled);
+}
+
 @end
 
 #endif // WK_API_ENABLED
index d539a54..4d3b488 100644 (file)
@@ -64,6 +64,8 @@
 // Test only. Should be called only while no web content processes are running.
 - (void)_terminateDatabaseProcess;
 
+@property (nonatomic) BOOL cookieStoragePartitioningEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @end
 
 #endif
index 8fbfce9..65c17e3 100644 (file)
@@ -27,6 +27,7 @@
 #import "WebProcessPool.h"
 
 #import "NetworkProcessCreationParameters.h"
+#import "NetworkProcessMessages.h"
 #import "NetworkProcessProxy.h"
 #import "PluginProcessManager.h"
 #import "SandboxUtilities.h"
@@ -247,6 +248,8 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara
     ASSERT(parameters.uiProcessCookieStorageIdentifier.isEmpty());
     parameters.uiProcessCookieStorageIdentifier.append(CFDataGetBytePtr(cookieStorageData.get()), CFDataGetLength(cookieStorageData.get()));
 #endif
+
+    parameters.cookieStoragePartitioningEnabled = cookieStoragePartitioningEnabled();
 }
 
 void WebProcessPool::platformInvalidateContext()
@@ -516,6 +519,12 @@ void WebProcessPool::resetHSTSHostsAddedAfterDate(double startDateIntervalSince1
 #endif
 }
 
+void WebProcessPool::setCookieStoragePartitioningEnabled(bool enabled)
+{
+    m_cookieStoragePartitioningEnabled = enabled;
+    sendToNetworkingProcess(Messages::NetworkProcess::SetCookieStoragePartitioningEnabled(enabled));
+}
+
 int networkProcessLatencyQOS()
 {
     static const int qos = [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitNetworkProcessLatencyQOS"];
index 0584bc0..4e0658f 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebProcessPool_h
-#define WebProcessPool_h
+#pragma once
 
 #include "APIDictionary.h"
 #include "APIObject.h"
@@ -374,6 +373,11 @@ public:
     void setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>&);
 #endif
 
+#if PLATFORM(COCOA)
+    bool cookieStoragePartitioningEnabled() const { return m_cookieStoragePartitioningEnabled; }
+    void setCookieStoragePartitioningEnabled(bool);
+#endif
+
 private:
     void platformInitialize();
 
@@ -550,6 +554,10 @@ private:
 #if ENABLE(GAMEPAD)
     HashSet<WebProcessProxy*> m_processesUsingGamepads;
 #endif
+
+#if PLATFORM(COCOA)
+    bool m_cookieStoragePartitioningEnabled { false };
+#endif
 };
 
 template<typename T>
@@ -618,5 +626,3 @@ void WebProcessPool::sendToOneProcess(T&& message)
 }
 
 } // namespace WebKit
-
-#endif // UIProcessPool_h