Title: [160949] tags/Safari-538.10/Source/WebKit2

Diff

Modified: tags/Safari-538.10/Source/WebKit2/ChangeLog (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/ChangeLog	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/ChangeLog	2013-12-21 01:05:39 UTC (rev 160949)
@@ -1,3 +1,32 @@
+2013-12-20  Lucas Forschler  <lforsch...@apple.com>
+
+        Merge r160939
+
+    2013-12-20  Sam Weinig  <s...@webkit.org>
+
+            [WK2] Add SPI for using a custom protocol handler
+            https://bugs.webkit.org/show_bug.cgi?id=126089
+
+            Reviewed by Anders Carlsson.
+
+            * UIProcess/API/C/mac/WKContextPrivateMac.h:
+            * UIProcess/API/C/mac/WKContextPrivateMac.mm:
+            (WKContextRegisterSchemeForCustomProtocol):
+            (WKContextUnregisterSchemeForCustomProtocol):
+            * UIProcess/API/Cocoa/WKBrowsingContextController.mm:
+            (+[WKBrowsingContextController registerSchemeForCustomProtocol:]):
+            (+[WKBrowsingContextController unregisterSchemeForCustomProtocol:]):
+            * UIProcess/WebContext.cpp:
+            (WebKit::WebContext::globalURLSchemesWithCustomProtocolHandlers):
+            (WebKit::WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers):
+            (WebKit::WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers):
+            * UIProcess/WebContext.h:
+            * UIProcess/mac/WebContextMac.mm:
+            (WebKit::WebContext::platformInitializeWebProcess):
+            (WebKit::WebContext::platformInitializeNetworkProcess):
+            (WebKit::WebContext::registerNotificationObservers):
+            (WebKit::WebContext::unregisterNotificationObservers):
+
 2013-12-19  Andy Estes  <aes...@apple.com>
 
         Remove WebFilterEvaluator wrappers from WebKitSystemInterface

Modified: tags/Safari-538.10/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h	2013-12-21 01:05:39 UTC (rev 160949)
@@ -44,6 +44,9 @@
 
 WK_EXPORT void WKContextResetHSTSHosts(WKContextRef context);
 
+WK_EXPORT void WKContextRegisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme);
+WK_EXPORT void WKContextUnregisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme);
+
 /* DEPRECATED -  Please use constants from WKPluginInformation instead. */
 
 /* Value type: WKStringRef */

Modified: tags/Safari-538.10/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm	2013-12-21 01:05:39 UTC (rev 160949)
@@ -105,6 +105,17 @@
 }
 
 
+
+void WKContextRegisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme)
+{
+    WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(toWTFString(scheme));
+}
+
+void WKContextUnregisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme)
+{
+    WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(toWTFString(scheme));
+}
+
 /* DEPRECATED -  Please use constants from WKPluginInformation instead. */
 
 WKStringRef WKPlugInInfoPathKey()

Modified: tags/Safari-538.10/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm	2013-12-21 01:05:39 UTC (rev 160949)
@@ -176,22 +176,12 @@
 
 + (void)registerSchemeForCustomProtocol:(NSString *)scheme
 {
-    if (!scheme)
-        return;
-
-    NSString *lowercaseScheme = [scheme lowercaseString];
-    [[WKBrowsingContextController customSchemes] addObject:lowercaseScheme];
-    [[NSNotificationCenter defaultCenter] postNotificationName:SchemeForCustomProtocolRegisteredNotificationName object:lowercaseScheme];
+    WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(scheme);
 }
 
 + (void)unregisterSchemeForCustomProtocol:(NSString *)scheme
 {
-    if (!scheme)
-        return;
-
-    NSString *lowercaseScheme = [scheme lowercaseString];
-    [[WKBrowsingContextController customSchemes] removeObject:lowercaseScheme];
-    [[NSNotificationCenter defaultCenter] postNotificationName:SchemeForCustomProtocolUnregisteredNotificationName object:lowercaseScheme];
+    WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(scheme);
 }
 
 - (void)loadRequest:(NSURLRequest *)request

Modified: tags/Safari-538.10/Source/WebKit2/UIProcess/WebContext.cpp (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/UIProcess/WebContext.cpp	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/UIProcess/WebContext.cpp	2013-12-21 01:05:39 UTC (rev 160949)
@@ -64,6 +64,7 @@
 #include <runtime/Operations.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/RunLoop.h>
 
 #if ENABLE(BATTERY_STATUS)
@@ -874,6 +875,34 @@
     sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsCORSEnabled(urlScheme));
 }
 
+HashSet<String>& WebContext::globalURLSchemesWithCustomProtocolHandlers()
+{
+    static NeverDestroyed<HashSet<String>> set;
+    return set;
+}
+
+void WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String& urlScheme)
+{
+    if (!urlScheme)
+        return;
+
+    String schemeLower = urlScheme.lower();
+    globalURLSchemesWithCustomProtocolHandlers().add(schemeLower);
+    for (auto* context : allContexts())
+        context->registerSchemeForCustomProtocol(schemeLower);
+}
+
+void WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String& urlScheme)
+{
+    if (!urlScheme)
+        return;
+
+    String schemeLower = urlScheme.lower();
+    globalURLSchemesWithCustomProtocolHandlers().remove(schemeLower);
+    for (auto* context : allContexts())
+        context->unregisterSchemeForCustomProtocol(schemeLower);
+}
+
 void WebContext::setCacheModel(CacheModel cacheModel)
 {
     m_cacheModel = cacheModel;

Modified: tags/Safari-538.10/Source/WebKit2/UIProcess/WebContext.h (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/UIProcess/WebContext.h	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/UIProcess/WebContext.h	2013-12-21 01:05:39 UTC (rev 160949)
@@ -85,11 +85,6 @@
 struct NetworkProcessCreationParameters;
 #endif
 
-#if PLATFORM(MAC)
-extern NSString *SchemeForCustomProtocolRegisteredNotificationName;
-extern NSString *SchemeForCustomProtocolUnregisteredNotificationName;
-#endif
-
 class WebContext : public API::ObjectImpl<API::Object::Type::Context>, private CoreIPC::MessageReceiver
 #if ENABLE(NETSCAPE_PLUGIN_API)
     , private PluginInfoStoreClient
@@ -311,6 +306,15 @@
     bool isURLKnownHSTSHost(const String& urlString, bool privateBrowsingEnabled) const;
     void resetHSTSHosts();
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+    void registerSchemeForCustomProtocol(const String&);
+    void unregisterSchemeForCustomProtocol(const String&);
+
+    static HashSet<String>& globalURLSchemesWithCustomProtocolHandlers();
+    static void registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
+    static void unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
+#endif
+
 private:
     void platformInitialize();
 
@@ -390,11 +394,6 @@
     void unregisterNotificationObservers();
 #endif
 
-#if ENABLE(CUSTOM_PROTOCOLS)
-    void registerSchemeForCustomProtocol(const String&);
-    void unregisterSchemeForCustomProtocol(const String&);
-#endif
-
     void addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash);
     void plugInDidReceiveUserInteraction(unsigned plugInOriginHash);
 
@@ -468,9 +467,6 @@
 
 #if PLATFORM(MAC)
     RetainPtr<NSObject> m_enhancedAccessibilityObserver;
-    RetainPtr<NSObject> m_customSchemeRegisteredObserver;
-    RetainPtr<NSObject> m_customSchemeUnregisteredObserver;
-
     RetainPtr<NSObject> m_automaticTextReplacementNotificationObserver;
     RetainPtr<NSObject> m_automaticSpellingCorrectionNotificationObserver;
 #if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090

Modified: tags/Safari-538.10/Source/WebKit2/UIProcess/mac/WebContextMac.mm (160948 => 160949)


--- tags/Safari-538.10/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2013-12-21 00:59:14 UTC (rev 160948)
+++ tags/Safari-538.10/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2013-12-21 01:05:39 UTC (rev 160949)
@@ -310,8 +310,8 @@
 #if ENABLE(NETWORK_PROCESS)
     if (!m_usesNetworkProcess) {
 #endif
-#if ENABLE(CUSTOM_PROTOCOLS) && WK_API_ENABLED
-        for (NSString *scheme in [WKBrowsingContextController customSchemes])
+#if ENABLE(CUSTOM_PROTOCOLS)
+        for (const auto& scheme : globalURLSchemesWithCustomProtocolHandlers())
             parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
 #endif
 #if ENABLE(NETWORK_PROCESS)
@@ -329,8 +329,8 @@
     parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
     parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
 
-#if WK_API_ENABLED
-    for (NSString *scheme in [WKBrowsingContextController customSchemes])
+#if ENABLE(CUSTOM_PROTOCOLS)
+    for (const auto& scheme : globalURLSchemesWithCustomProtocolHandlers())
         parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
 #endif
 
@@ -573,18 +573,6 @@
 void WebContext::registerNotificationObservers()
 {
 #if !PLATFORM(IOS)
-    m_customSchemeRegisteredObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKit::SchemeForCustomProtocolRegisteredNotificationName object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {
-        NSString *scheme = [notification object];
-        ASSERT([scheme isKindOfClass:[NSString class]]);
-        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]]);
-        unregisterSchemeForCustomProtocol(scheme);
-    }];
-
     // Listen for enhanced accessibility changes and propagate them to the WebProcess.
     m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
         setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]);
@@ -617,10 +605,7 @@
 void WebContext::unregisterNotificationObservers()
 {
 #if !PLATFORM(IOS)
-    [[NSNotificationCenter defaultCenter] removeObserver:m_customSchemeRegisteredObserver.get()];
-    [[NSNotificationCenter defaultCenter] removeObserver:m_customSchemeUnregisteredObserver.get()];
-    [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];
-    
+    [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()];    
     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()];
     [[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to