Changeset 160939 in webkit
- Timestamp:
- Dec 20, 2013 3:55:04 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r160923 r160939 1 2013-12-20 Sam Weinig <sam@webkit.org> 2 3 [WK2] Add SPI for using a custom protocol handler 4 https://bugs.webkit.org/show_bug.cgi?id=126089 5 6 Reviewed by Anders Carlsson. 7 8 * UIProcess/API/C/mac/WKContextPrivateMac.h: 9 * UIProcess/API/C/mac/WKContextPrivateMac.mm: 10 (WKContextRegisterSchemeForCustomProtocol): 11 (WKContextUnregisterSchemeForCustomProtocol): 12 * UIProcess/API/Cocoa/WKBrowsingContextController.mm: 13 (+[WKBrowsingContextController registerSchemeForCustomProtocol:]): 14 (+[WKBrowsingContextController unregisterSchemeForCustomProtocol:]): 15 * UIProcess/WebContext.cpp: 16 (WebKit::WebContext::globalURLSchemesWithCustomProtocolHandlers): 17 (WebKit::WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers): 18 (WebKit::WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers): 19 * UIProcess/WebContext.h: 20 * UIProcess/mac/WebContextMac.mm: 21 (WebKit::WebContext::platformInitializeWebProcess): 22 (WebKit::WebContext::platformInitializeNetworkProcess): 23 (WebKit::WebContext::registerNotificationObservers): 24 (WebKit::WebContext::unregisterNotificationObservers): 25 1 26 2013-12-20 Tim Horton <timothy_horton@apple.com> 2 27 -
trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h
r159788 r160939 45 45 WK_EXPORT void WKContextResetHSTSHosts(WKContextRef context); 46 46 47 WK_EXPORT void WKContextRegisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme); 48 WK_EXPORT void WKContextUnregisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme); 49 47 50 /* DEPRECATED - Please use constants from WKPluginInformation instead. */ 48 51 -
trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm
r160608 r160939 106 106 107 107 108 109 void WKContextRegisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme) 110 { 111 WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(toWTFString(scheme)); 112 } 113 114 void WKContextUnregisterSchemeForCustomProtocol(WKContextRef context, WKStringRef scheme) 115 { 116 WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(toWTFString(scheme)); 117 } 118 108 119 /* DEPRECATED - Please use constants from WKPluginInformation instead. */ 109 120 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm
r160787 r160939 177 177 + (void)registerSchemeForCustomProtocol:(NSString *)scheme 178 178 { 179 if (!scheme) 180 return; 181 182 NSString *lowercaseScheme = [scheme lowercaseString]; 183 [[WKBrowsingContextController customSchemes] addObject:lowercaseScheme]; 184 [[NSNotificationCenter defaultCenter] postNotificationName:SchemeForCustomProtocolRegisteredNotificationName object:lowercaseScheme]; 179 WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(scheme); 185 180 } 186 181 187 182 + (void)unregisterSchemeForCustomProtocol:(NSString *)scheme 188 183 { 189 if (!scheme) 190 return; 191 192 NSString *lowercaseScheme = [scheme lowercaseString]; 193 [[WKBrowsingContextController customSchemes] removeObject:lowercaseScheme]; 194 [[NSNotificationCenter defaultCenter] postNotificationName:SchemeForCustomProtocolUnregisteredNotificationName object:lowercaseScheme]; 184 WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(scheme); 195 185 } 196 186 -
trunk/Source/WebKit2/UIProcess/WebContext.cpp
r160922 r160939 65 65 #include <wtf/CurrentTime.h> 66 66 #include <wtf/MainThread.h> 67 #include <wtf/NeverDestroyed.h> 67 68 #include <wtf/RunLoop.h> 68 69 … … 875 876 } 876 877 878 HashSet<String>& WebContext::globalURLSchemesWithCustomProtocolHandlers() 879 { 880 static NeverDestroyed<HashSet<String>> set; 881 return set; 882 } 883 884 void WebContext::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String& urlScheme) 885 { 886 if (!urlScheme) 887 return; 888 889 String schemeLower = urlScheme.lower(); 890 globalURLSchemesWithCustomProtocolHandlers().add(schemeLower); 891 for (auto* context : allContexts()) 892 context->registerSchemeForCustomProtocol(schemeLower); 893 } 894 895 void WebContext::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String& urlScheme) 896 { 897 if (!urlScheme) 898 return; 899 900 String schemeLower = urlScheme.lower(); 901 globalURLSchemesWithCustomProtocolHandlers().remove(schemeLower); 902 for (auto* context : allContexts()) 903 context->unregisterSchemeForCustomProtocol(schemeLower); 904 } 905 877 906 void WebContext::setCacheModel(CacheModel cacheModel) 878 907 { -
trunk/Source/WebKit2/UIProcess/WebContext.h
r160922 r160939 86 86 #endif 87 87 88 #if PLATFORM(MAC)89 extern NSString *SchemeForCustomProtocolRegisteredNotificationName;90 extern NSString *SchemeForCustomProtocolUnregisteredNotificationName;91 #endif92 93 88 class WebContext : public API::ObjectImpl<API::Object::Type::Context>, private CoreIPC::MessageReceiver 94 89 #if ENABLE(NETSCAPE_PLUGIN_API) … … 312 307 bool isURLKnownHSTSHost(const String& urlString, bool privateBrowsingEnabled) const; 313 308 void resetHSTSHosts(); 309 310 #if ENABLE(CUSTOM_PROTOCOLS) 311 void registerSchemeForCustomProtocol(const String&); 312 void unregisterSchemeForCustomProtocol(const String&); 313 314 static HashSet<String>& globalURLSchemesWithCustomProtocolHandlers(); 315 static void registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&); 316 static void unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&); 317 #endif 314 318 315 319 private: … … 392 396 #endif 393 397 394 #if ENABLE(CUSTOM_PROTOCOLS)395 void registerSchemeForCustomProtocol(const String&);396 void unregisterSchemeForCustomProtocol(const String&);397 #endif398 399 398 void addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash); 400 399 void plugInDidReceiveUserInteraction(unsigned plugInOriginHash); … … 470 469 #if PLATFORM(MAC) 471 470 RetainPtr<NSObject> m_enhancedAccessibilityObserver; 472 RetainPtr<NSObject> m_customSchemeRegisteredObserver;473 RetainPtr<NSObject> m_customSchemeUnregisteredObserver;474 475 471 RetainPtr<NSObject> m_automaticTextReplacementNotificationObserver; 476 472 RetainPtr<NSObject> m_automaticSpellingCorrectionNotificationObserver; -
trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm
r159760 r160939 311 311 if (!m_usesNetworkProcess) { 312 312 #endif 313 #if ENABLE(CUSTOM_PROTOCOLS) && WK_API_ENABLED314 for ( NSString *scheme in [WKBrowsingContextController customSchemes])313 #if ENABLE(CUSTOM_PROTOCOLS) 314 for (const auto& scheme : globalURLSchemesWithCustomProtocolHandlers()) 315 315 parameters.urlSchemesRegisteredForCustomProtocols.append(scheme); 316 316 #endif … … 330 330 parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; 331 331 332 #if WK_API_ENABLED333 for ( NSString *scheme in [WKBrowsingContextController customSchemes])332 #if ENABLE(CUSTOM_PROTOCOLS) 333 for (const auto& scheme : globalURLSchemesWithCustomProtocolHandlers()) 334 334 parameters.urlSchemesRegisteredForCustomProtocols.append(scheme); 335 335 #endif … … 574 574 { 575 575 #if !PLATFORM(IOS) 576 m_customSchemeRegisteredObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKit::SchemeForCustomProtocolRegisteredNotificationName object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {577 NSString *scheme = [notification object];578 ASSERT([scheme isKindOfClass:[NSString class]]);579 registerSchemeForCustomProtocol(scheme);580 }];581 582 m_customSchemeUnregisteredObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKit::SchemeForCustomProtocolUnregisteredNotificationName object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *notification) {583 NSString *scheme = [notification object];584 ASSERT([scheme isKindOfClass:[NSString class]]);585 unregisterSchemeForCustomProtocol(scheme);586 }];587 588 576 // Listen for enhanced accessibility changes and propagate them to the WebProcess. 589 577 m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) { … … 618 606 { 619 607 #if !PLATFORM(IOS) 620 [[NSNotificationCenter defaultCenter] removeObserver:m_customSchemeRegisteredObserver.get()]; 621 [[NSNotificationCenter defaultCenter] removeObserver:m_customSchemeUnregisteredObserver.get()]; 622 [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()]; 623 608 [[NSNotificationCenter defaultCenter] removeObserver:m_enhancedAccessibilityObserver.get()]; 624 609 [[NSNotificationCenter defaultCenter] removeObserver:m_automaticTextReplacementNotificationObserver.get()]; 625 610 [[NSNotificationCenter defaultCenter] removeObserver:m_automaticSpellingCorrectionNotificationObserver.get()];
Note: See TracChangeset
for help on using the changeset viewer.