Title: [137818] trunk/Source/WebKit2
Revision
137818
Author
[email protected]
Date
2012-12-15 16:03:27 -0800 (Sat, 15 Dec 2012)

Log Message

[WebKit2] Register schemes with the network process if it is being used
https://bugs.webkit.org/show_bug.cgi?id=105113

Reviewed by Anders Carlsson.

If a WebContext is using the network process, it needs to be told about
scheme (un)registration rather than the context's web processes.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess): Tell the shared
CustomProtocolManager about schemes registered at process creation time.
(WebKit::NetworkProcess::registerSchemeForCustomProtocol): Tell the
shared CustomProtocolManager about a new scheme.
(WebKit::NetworkProcess::unregisterSchemeForCustomProtocol): Remove a
scheme from the shared CustomProtocolManager.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in: Add registration and
unregistration messages for the NetworkProcess.
* Shared/Network/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode): Encode
urlSchemesRegisteredForCustomProtocols.
(WebKit::NetworkProcessCreationParameters::decode): Decode
urlSchemesRegisteredForCustomProtocols.
* Shared/Network/NetworkProcessCreationParameters.h: Define
urlSchemesRegisteredForCustomProtocols.
* UIProcess/Network/mac/NetworkProcessProxyMac.mm:
(WebKit::NetworkProcessProxy::platformInitializeNetworkProcess): Populate
urlSchemesRegisteredForCustomProtocols with the current set of schemes.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::registerSchemeForCustomProtocol): Send a new
scheme to either the network process or to the context's web processes.
(WebKit::WebContext::unregisterSchemeForCustomProtocol): Ditto for
removing a scheme.
* UIProcess/WebContext.h:
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::platformInitializeWebProcess): Only populate
urlSchemesRegisteredForCustomProtocols if the network process isn't
being used.
(WebKit::WebContext::registerNotificationObservers):
* WebProcess/mac/WebProcessMac.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
urlSchemesRegisteredForCustomProtocols should only be non-empty if the
network process isn't being used. Assert this.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (137817 => 137818)


--- trunk/Source/WebKit2/ChangeLog	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-16 00:03:27 UTC (rev 137818)
@@ -1,3 +1,49 @@
+2012-12-15  Andy Estes  <[email protected]>
+
+        [WebKit2] Register schemes with the network process if it is being used
+        https://bugs.webkit.org/show_bug.cgi?id=105113
+
+        Reviewed by Anders Carlsson.
+
+        If a WebContext is using the network process, it needs to be told about
+        scheme (un)registration rather than the context's web processes.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess): Tell the shared
+        CustomProtocolManager about schemes registered at process creation time.
+        (WebKit::NetworkProcess::registerSchemeForCustomProtocol): Tell the
+        shared CustomProtocolManager about a new scheme.
+        (WebKit::NetworkProcess::unregisterSchemeForCustomProtocol): Remove a
+        scheme from the shared CustomProtocolManager.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in: Add registration and
+        unregistration messages for the NetworkProcess.
+        * Shared/Network/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode): Encode
+        urlSchemesRegisteredForCustomProtocols.
+        (WebKit::NetworkProcessCreationParameters::decode): Decode
+        urlSchemesRegisteredForCustomProtocols.
+        * Shared/Network/NetworkProcessCreationParameters.h: Define
+        urlSchemesRegisteredForCustomProtocols.
+        * UIProcess/Network/mac/NetworkProcessProxyMac.mm:
+        (WebKit::NetworkProcessProxy::platformInitializeNetworkProcess): Populate
+        urlSchemesRegisteredForCustomProtocols with the current set of schemes.
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::registerSchemeForCustomProtocol): Send a new
+        scheme to either the network process or to the context's web processes.
+        (WebKit::WebContext::unregisterSchemeForCustomProtocol): Ditto for
+        removing a scheme.
+        * UIProcess/WebContext.h:
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::platformInitializeWebProcess): Only populate
+        urlSchemesRegisteredForCustomProtocols if the network process isn't
+        being used.
+        (WebKit::WebContext::registerNotificationObservers):
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        urlSchemesRegisteredForCustomProtocols should only be non-empty if the
+        network process isn't being used. Assert this.
+
 2012-12-15  Anders Carlsson  <[email protected]>
 
         Remove the unneeded NetworkProcessCrashed message

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (137817 => 137818)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2012-12-16 00:03:27 UTC (rev 137818)
@@ -30,6 +30,7 @@
 
 #include "ArgumentCoders.h"
 #include "Attachment.h"
+#include "CustomProtocolManager.h"
 #include "Logging.h"
 #include "NetworkConnectionToWebProcess.h"
 #include "NetworkProcessCreationParameters.h"
@@ -111,6 +112,11 @@
 
     if (parameters.privateBrowsingEnabled)
         RemoteNetworkingContext::ensurePrivateBrowsingSession();
+
+#if ENABLE(CUSTOM_PROTOCOLS)
+    for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
+        CustomProtocolManager::shared().registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
+#endif
 }
 
 void NetworkProcess::createNetworkConnectionToWebProcess()
@@ -141,6 +147,18 @@
     RemoteNetworkingContext::destroyPrivateBrowsingSession();
 }
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+void NetworkProcess::registerSchemeForCustomProtocol(const String& scheme)
+{
+    CustomProtocolManager::shared().registerScheme(scheme);
+}
+
+void NetworkProcess::unregisterSchemeForCustomProtocol(const String& scheme)
+{
+    CustomProtocolManager::shared().unregisterScheme(scheme);
+}
+#endif
+
 } // namespace WebKit
 
 #endif // ENABLE(NETWORK_PROCESS)

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (137817 => 137818)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2012-12-16 00:03:27 UTC (rev 137818)
@@ -73,6 +73,11 @@
     void ensurePrivateBrowsingSession();
     void destroyPrivateBrowsingSession();
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+    void registerSchemeForCustomProtocol(const String&);
+    void unregisterSchemeForCustomProtocol(const String&);
+#endif
+
     // The connection to the UI process.
     RefPtr<CoreIPC::Connection> m_uiConnection;
 

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in (137817 => 137818)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in	2012-12-16 00:03:27 UTC (rev 137818)
@@ -35,6 +35,11 @@
 #if PLATFORM(MAC)
     SetApplicationIsOccluded(bool flag)
 #endif
+
+#if ENABLE(CUSTOM_PROTOCOLS)
+    RegisterSchemeForCustomProtocol(WTF::String name)
+    UnregisterSchemeForCustomProtocol(WTF::String name)
+#endif
 }
 
 #endif // ENABLE(NETWORK_PROCESS)

Modified: trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp (137817 => 137818)


--- trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp	2012-12-16 00:03:27 UTC (rev 137818)
@@ -43,6 +43,9 @@
     encoder << uiProcessBundleIdentifier;
 #endif
     encoder << privateBrowsingEnabled;
+#if ENABLE(CUSTOM_PROTOCOLS)
+    encoder << urlSchemesRegisteredForCustomProtocols;
+#endif
 }
 
 bool NetworkProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, NetworkProcessCreationParameters& result)
@@ -55,6 +58,10 @@
 #endif
     if (!decoder->decode(result.privateBrowsingEnabled))
         return false;
+#if ENABLE(CUSTOM_PROTOCOLS)
+    if (!decoder->decode(result.urlSchemesRegisteredForCustomProtocols))
+        return false;
+#endif
 
     return true;
 }

Modified: trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h (137817 => 137818)


--- trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h	2012-12-16 00:03:27 UTC (rev 137818)
@@ -49,6 +49,10 @@
 #endif
 
     bool privateBrowsingEnabled;
+
+#if ENABLE(CUSTOM_PROTOCOLS)
+    Vector<String> urlSchemesRegisteredForCustomProtocols;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm (137817 => 137818)


--- trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm	2012-12-16 00:03:27 UTC (rev 137818)
@@ -28,6 +28,7 @@
 
 #import "NetworkProcessCreationParameters.h"
 #import "NetworkProcessMessages.h"
+#import "WKBrowsingContextControllerInternal.h"
 
 #if ENABLE(NETWORK_PROCESS)
 
@@ -39,6 +40,9 @@
 {
     parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
     parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
+    
+    for (NSString *scheme in [WKBrowsingContextController customSchemes])
+        parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
 }
 
 void NetworkProcessProxy::setApplicationIsOccluded(bool applicationIsOccluded)

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (137817 => 137818)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-16 00:03:27 UTC (rev 137818)
@@ -1113,4 +1113,28 @@
     m_plugInAutoStartProvider.addAutoStartOrigin(pageOrigin, plugInOriginHash);
 }
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+void WebContext::registerSchemeForCustomProtocol(const WTF::String& scheme)
+{
+#if ENABLE(NETWORK_PROCESS)
+    if (m_usesNetworkProcess) {
+        NetworkProcessManager::shared().process()->send(Messages::NetworkProcess::RegisterSchemeForCustomProtocol(scheme), 0);
+        return;
+    }
+#endif
+    sendToAllProcesses(Messages::WebProcess::RegisterSchemeForCustomProtocol(scheme));
+}
+
+void WebContext::unregisterSchemeForCustomProtocol(const WTF::String& scheme)
+{
+#if ENABLE(NETWORK_PROCESS)
+    if (m_usesNetworkProcess) {
+        NetworkProcessManager::shared().process()->send(Messages::NetworkProcess::UnregisterSchemeForCustomProtocol(scheme), 0);
+        return;
+    }
+#endif
+    sendToAllProcesses(Messages::WebProcess::UnregisterSchemeForCustomProtocol(scheme));
+}
+#endif
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (137817 => 137818)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-16 00:03:27 UTC (rev 137818)
@@ -337,6 +337,11 @@
     void unregisterNotificationObservers();
 #endif
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+    void registerSchemeForCustomProtocol(const String&);
+    void unregisterSchemeForCustomProtocol(const String&);
+#endif
+
     void addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash);
 
     CoreIPC::MessageReceiverMap m_messageReceiverMap;

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (137817 => 137818)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2012-12-16 00:03:27 UTC (rev 137818)
@@ -128,10 +128,15 @@
     SandboxExtension::createHandle(parameters.uiProcessBundleResourcePath, SandboxExtension::ReadOnly, parameters.uiProcessBundleResourcePathExtensionHandle);
 
     parameters.uiProcessBundleIdentifier = String([[NSBundle mainBundle] bundleIdentifier]);
-    
-    NSArray *schemes = [[WKBrowsingContextController customSchemes] allObjects];
-    for (size_t i = 0; i < [schemes count]; ++i)
-        parameters.urlSchemesRegisteredForCustomProtocols.append([schemes objectAtIndex:i]);
+
+#if ENABLE(NETWORK_PROCESS)
+    if (!m_usesNetworkProcess) {
+#endif
+        for (NSString *scheme in [WKBrowsingContextController customSchemes])
+            parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
+#if ENABLE(NETWORK_PROCESS)
+    }
+#endif
 }
 
 void WebContext::platformInvalidateContext()
@@ -346,13 +351,13 @@
     m_customSchemeRegisteredObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKit::SchemeForCustomProtocolRegisteredNotificationName object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
         NSString *scheme = [notification object];
         ASSERT([scheme isKindOfClass:[NSString class]]);
-        sendToAllProcesses(Messages::WebProcess::RegisterSchemeForCustomProtocol(scheme));
+        registerSchemeForCustomProtocol(scheme);
     }];
     
     m_customSchemeUnregisteredObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKit::SchemeForCustomProtocolUnregisteredNotificationName object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
         NSString *scheme = [notification object];
         ASSERT([scheme isKindOfClass:[NSString class]]);
-        sendToAllProcesses(Messages::WebProcess::UnregisterSchemeForCustomProtocol(scheme));
+        unregisterSchemeForCustomProtocol(scheme);
     }];
     
     // Listen for enhanced accessibility changes and propagate them to the WebProcess.

Modified: trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm (137817 => 137818)


--- trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm	2012-12-15 23:43:15 UTC (rev 137817)
+++ trunk/Source/WebKit2/WebProcess/mac/WebProcessMac.mm	2012-12-16 00:03:27 UTC (rev 137818)
@@ -283,6 +283,7 @@
     Method methodToPatch = class_getInstanceMethod([NSApplication class], @selector(accessibilityFocusedUIElement));
     method_setImplementation(methodToPatch, (IMP)NSApplicationAccessibilityFocusedUIElement);
     
+    ASSERT(parameters.urlSchemesRegisteredForCustomProtocols.isEmpty() || !m_usesNetworkProcess);
     for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
         CustomProtocolManager::shared().registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
     
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to