Remove cookie API access from WebContent Process
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Mar 2018 21:31:02 +0000 (21:31 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Mar 2018 21:31:02 +0000 (21:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183519
<rdar://problem/35368802>

Reviewed by Alex Christensen.

All cookie access is now handled in the Network Process. However, there are vestiges of the original logic that used CFNetwork APIs in the WebContent process.

This patch removes CFNetwork calls from the WebProcess code paths, since they serve no purpose in modern WebKit.

No tests because this is a code cleanup with no expected change in behavior.

* NetworkProcess/Cookies/mac/WebCookieManagerMac.mm:
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy): Moved from WebFrameNetworkingContext.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::setSharedHTTPCookieStorage): Moved from ChildProcess, since this should only be
called in the NetworkProcess.
* Shared/ChildProcess.h:
* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::setSharedHTTPCookieStorage): Deleted.
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
(WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession): Remove CFNetwork code. This version of
'ensureWebsiteDataStoreSession' is needed to maintain a dictionary on the WebProcess side so we can refer to
the same network session in both the WebContent and Network processes.
(WebKit::WebFrameNetworkingContext::webFrameLoaderClient const):
(WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts): Deleted.
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess): Remove calls to CFNetwork.

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Cookies/mac/WebCookieManagerMac.mm
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Source/WebKit/Shared/ChildProcess.h
Source/WebKit/Shared/mac/ChildProcessMac.mm
Source/WebKit/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h
Source/WebKit/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

index bc4113f..1f445a7 100644 (file)
@@ -1,3 +1,36 @@
+2018-03-09  Brent Fulgham  <bfulgham@apple.com>
+
+        Remove cookie API access from WebContent Process
+        https://bugs.webkit.org/show_bug.cgi?id=183519
+        <rdar://problem/35368802>
+
+        Reviewed by Alex Christensen.
+
+        All cookie access is now handled in the Network Process. However, there are vestiges of the original logic that used CFNetwork APIs in the WebContent process.
+
+        This patch removes CFNetwork calls from the WebProcess code paths, since they serve no purpose in modern WebKit.
+
+        No tests because this is a code cleanup with no expected change in behavior.
+
+        * NetworkProcess/Cookies/mac/WebCookieManagerMac.mm:
+        (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy): Moved from WebFrameNetworkingContext.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::setSharedHTTPCookieStorage): Moved from ChildProcess, since this should only be
+        called in the NetworkProcess.
+        * Shared/ChildProcess.h:
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::setSharedHTTPCookieStorage): Deleted.
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
+        (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession): Remove CFNetwork code. This version of
+        'ensureWebsiteDataStoreSession' is needed to maintain a dictionary on the WebProcess side so we can refer to
+        the same network session in both the WebContent and Network processes.
+        (WebKit::WebFrameNetworkingContext::webFrameLoaderClient const):
+        (WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts): Deleted.
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess): Remove calls to CFNetwork.
+
 2018-03-09  Youenn Fablet  <youenn@apple.com>
 
         ServiceWorkerClientFetch should send data to its resource loader once the didReceiveResponse completion handler is called
index 6b9fe97..96f0bce 100644 (file)
 #import "config.h"
 #import "WebCookieManager.h"
 
+#import "NetworkSession.h"
 #import "WebFrameNetworkingContext.h"
+#import <WebCore/NetworkStorageSession.h>
+#import <pal/spi/cf/CFNetworkSPI.h>
 
 using namespace WebCore;
 
@@ -34,7 +37,12 @@ namespace WebKit {
 
 void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
 {
-    WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(policy);
+    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
+
+    NetworkStorageSession::forEach([&] (const NetworkStorageSession& networkStorageSession) {
+        if (auto cookieStorage = networkStorageSession.cookieStorage())
+            CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
+    });
 }
 
 HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy()
index fcc52d3..23568f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -235,6 +235,10 @@ private:
     // Platform Helpers
     void platformSetURLCacheSize(unsigned urlCacheMemoryCapacity, uint64_t urlCacheDiskCapacity);
 
+#if PLATFORM(MAC)
+    static void setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier);
+#endif
+
     // Connections to WebProcesses.
     Vector<RefPtr<NetworkConnectionToWebProcess>> m_webProcessConnections;
 
index 5471e03..9b68f53 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "NetworkProcess.h"
 
+#import "CookieStorageUtilsCF.h"
 #import "NetworkCache.h"
 #import "NetworkProcessCreationParameters.h"
 #import "NetworkResourceLoader.h"
@@ -204,6 +205,13 @@ void NetworkProcess::clearDiskCache(WallTime modifiedSince, Function<void ()>&&
     clearNSURLCache(m_clearCacheDispatchGroup, modifiedSince, WTFMove(completionHandler));
 }
 
+#if PLATFORM(MAC)
+void NetworkProcess::setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier)
+{
+    [NSHTTPCookieStorage _setSharedHTTPCookieStorage:adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorageFromIdentifyingData(identifier).get()]).get()];
+}
+#endif
+
 void NetworkProcess::setCookieStoragePartitioningEnabled(bool enabled)
 {
     WebCore::NetworkStorageSession::setCookieStoragePartitioningEnabled(enabled);
index 0ca69c1..c6e4edf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -91,10 +91,6 @@ protected:
     virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&);
     virtual void initializeConnection(IPC::Connection*);
 
-#if PLATFORM(MAC)
-    static void setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier);
-#endif
-
     virtual bool shouldTerminate() = 0;
     virtual void terminate();
 
index 3e0bf5a..ca28f57 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import "ChildProcess.h"
 
 #import "CodeSigning.h"
-#import "CookieStorageUtilsCF.h"
 #import "QuarantineSPI.h"
 #import "SandboxInitializationParameters.h"
 #import <WebCore/FileSystem.h>
 #import <WebCore/SystemVersion.h>
 #import <mach/mach.h>
 #import <mach/task.h>
-#import <pal/spi/cf/CFNetworkSPI.h>
 #import <pwd.h>
 #import <stdlib.h>
 #import <sysexits.h>
@@ -203,11 +201,6 @@ void ChildProcess::initializeSandbox(const ChildProcessInitializationParameters&
     }
 }
 
-void ChildProcess::setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier)
-{
-    [NSHTTPCookieStorage _setSharedHTTPCookieStorage:adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorageFromIdentifyingData(identifier).get()]).get()];
-}
-
 #if USE(APPKIT)
 void ChildProcess::stopNSAppRunLoop()
 {
index e1ceaec..7e30e94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,7 +25,6 @@
 
 #pragma once
 
-#include "HTTPCookieAcceptPolicy.h"
 #include "WebFrame.h"
 #include <WebCore/FrameNetworkingContext.h>
 #include <pal/SessionID.h>
@@ -44,8 +43,6 @@ public:
     // FIXME: remove platform-specific code and use SessionTracker
     static void ensureWebsiteDataStoreSession(WebsiteDataStoreParameters&&);
 
-    static void setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy);
-
     WebFrameLoaderClient* webFrameLoaderClient() const;
 
 private:
index 63fd97f..a54f4da 100644 (file)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "WebFrameNetworkingContext.h"
 
-#include "CookieStorageUtilsCF.h"
 #include "NetworkSession.h"
 #include "SessionTracker.h"
 #include "WebPage.h"
@@ -39,7 +38,6 @@
 #include <WebCore/Page.h>
 #include <WebCore/ResourceError.h>
 #include <WebCore/Settings.h>
-#include <pal/spi/cf/CFNetworkSPI.h>
 
 using namespace WebCore;
 
@@ -57,26 +55,9 @@ void WebFrameNetworkingContext::ensureWebsiteDataStoreSession(WebsiteDataStorePa
     else
         base = SessionTracker::getIdentifierBase();
 
-    if (!sessionID.isEphemeral())
-        SandboxExtension::consumePermanently(parameters.cookieStoragePathExtensionHandle);
-
-    RetainPtr<CFHTTPCookieStorageRef> uiProcessCookieStorage;
-    if (!sessionID.isEphemeral() && !parameters.uiProcessCookieStorageIdentifier.isEmpty())
-        uiProcessCookieStorage = cookieStorageFromIdentifyingData(parameters.uiProcessCookieStorageIdentifier);
-
-    NetworkStorageSession::ensureSession(sessionID, base + '.' + String::number(sessionID.sessionID()), WTFMove(uiProcessCookieStorage));
+    NetworkStorageSession::ensureSession(sessionID, base + '.' + String::number(sessionID.sessionID()));
 }
 
-void WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy policy)
-{
-    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
-
-    NetworkStorageSession::forEach([&] (const NetworkStorageSession& networkStorageSession) {
-        if (auto cookieStorage = networkStorageSession.cookieStorage())
-            CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
-    });
-}
-    
 bool WebFrameNetworkingContext::localFileContentSniffingEnabled() const
 {
     return frame() && frame()->settings().localFileContentSniffingEnabled();
@@ -119,7 +100,7 @@ NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
 WebFrameLoaderClient* WebFrameNetworkingContext::webFrameLoaderClient() const
 {
     if (!frame())
-        return 0;
+        return nullptr;
 
     return toWebFrameLoaderClient(frame()->loader().client());
 }
index 7da46df..b160b5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -64,7 +64,6 @@
 #import <algorithm>
 #import <dispatch/dispatch.h>
 #import <objc/runtime.h>
-#import <pal/spi/cf/CFNetworkSPI.h>
 #import <pal/spi/cocoa/LaunchServicesSPI.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 #import <pal/spi/cocoa/pthreadSPI.h>
@@ -148,10 +147,6 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
         JSC::processConfigFile(javaScriptConfigFile.latin1().data(), "com.apple.WebKit.WebContent", parameters.uiProcessBundleIdentifier.latin1().data());
     }
 
-#if PLATFORM(MAC)
-    setSharedHTTPCookieStorage(parameters.uiProcessCookieStorageIdentifier);
-#endif
-
     auto urlCache = adoptNS([[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]);
     [NSURLCache setSharedURLCache:urlCache.get()];
 
@@ -183,8 +178,6 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
     [NSApplication _accessibilityInitialize];
 #endif
 
-    _CFNetworkSetATSContext(parameters.networkATSContext.get());
-
 #if TARGET_OS_IPHONE
     // Priority decay on iOS 9 is impacting page load time so we fix the priority of the WebProcess' main thread (rdar://problem/22003112).
     pthread_set_fixedpriority_self();