Changeset 182648 in webkit
- Timestamp:
- Apr 10, 2015 6:45:04 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r182623 r182648 1 2015-04-08 Sam Weinig <sam@webkit.org> 2 3 Allow LaunchServices to handle URLs on link navigations 4 <rdar://problem/19446826> 5 https://bugs.webkit.org/show_bug.cgi?id=143544 6 7 Reviewed by Anders Carlsson. 8 9 * wtf/Platform.h: 10 Add HAVE macro for this functionality. 11 1 12 2015-04-09 Andy Estes <aestes@apple.com> 2 13 -
trunk/Source/WTF/wtf/Platform.h
r182623 r182648 539 539 #define WTF_USE_QUICK_LOOK 1 540 540 541 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000 542 #define HAVE_APP_LINKS 1 543 #endif 544 541 545 #if CPU(ARM64) 542 546 #define ENABLE_JIT_CONSTANT_BLINDING 0 -
trunk/Source/WebCore/ChangeLog
r182642 r182648 1 2015-04-08 Sam Weinig <sam@webkit.org> 2 3 Allow LaunchServices to handle URLs on link navigations 4 <rdar://problem/19446826> 5 https://bugs.webkit.org/show_bug.cgi?id=143544 6 7 Reviewed by Anders Carlsson. 8 9 * WebCore.xcodeproj/project.pbxproj: 10 * platform/spi/ios/LaunchServicesSPI.h: Added. 11 Add new SPI header. 12 1 13 2015-04-10 Bem Jones-Bey <bjonesbe@adobe.com> 2 14 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r182630 r182648 2509 2509 7C4C96DE1AD4483500365A50 /* JSReadableStreamReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C96DA1AD4483500365A50 /* JSReadableStreamReader.cpp */; }; 2510 2510 7C4C96DF1AD4483500365A50 /* JSReadableStreamReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C4C96DB1AD4483500365A50 /* JSReadableStreamReader.h */; }; 2511 7C4C96E31AD44ABF00365A50 /* LaunchServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C4C96E21AD44ABF00365A50 /* LaunchServicesSPI.h */; }; 2511 2512 7C4EDD741A7B607800198C4D /* FontCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C4EDD731A7B607800198C4D /* FontCocoa.mm */; }; 2512 2513 7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */; }; … … 5854 5855 CE12523D1A1676CD00864480 /* QuartzCoreSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE12523C1A1676CD00864480 /* QuartzCoreSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5855 5856 CE1252411A16B1B600864480 /* MediaPlayerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252401A16B1B600864480 /* MediaPlayerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5856 CE1252431A16C01A00864480 /* CoreUISPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252421A16C01A00864480 /* CoreUISPI.h */; };5857 CE1252431A16C01A00864480 /* CoreUISPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252421A16C01A00864480 /* CoreUISPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5857 5858 CE1252451A16C22500864480 /* DynamicLinkerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252441A16C22500864480 /* DynamicLinkerSPI.h */; }; 5858 5859 CE1252471A16C2C200864480 /* NSPointerFunctionsSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252461A16C2C200864480 /* NSPointerFunctionsSPI.h */; }; … … 9760 9761 7C4C96DA1AD4483500365A50 /* JSReadableStreamReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamReader.cpp; sourceTree = "<group>"; }; 9761 9762 7C4C96DB1AD4483500365A50 /* JSReadableStreamReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamReader.h; sourceTree = "<group>"; }; 9763 7C4C96E21AD44ABF00365A50 /* LaunchServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LaunchServicesSPI.h; path = ios/LaunchServicesSPI.h; sourceTree = "<group>"; }; 9762 9764 7C4EDD731A7B607800198C4D /* FontCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCocoa.mm; sourceTree = "<group>"; }; 9763 9765 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorOverlay.cpp; sourceTree = "<group>"; }; … … 18732 18734 CE1252421A16C01A00864480 /* CoreUISPI.h */, 18733 18735 CEC337AE1A46086D009B8523 /* GraphicsServicesSPI.h */, 18736 7C4C96E21AD44ABF00365A50 /* LaunchServicesSPI.h */, 18737 CE1252401A16B1B600864480 /* MediaPlayerSPI.h */, 18734 18738 CE1252481A16C3BC00864480 /* MobileGestaltSPI.h */, 18735 CE1252401A16B1B600864480 /* MediaPlayerSPI.h */,18739 6FAD4A561A9D0FAE009F7D3C /* OpenGLESSPI.h */, 18736 18740 CE1252381A166FA000864480 /* QuickLookSPI.h */, 18737 6FAD4A561A9D0FAE009F7D3C /* OpenGLESSPI.h */,18738 18741 ); 18739 18742 name = ios; … … 25479 25482 B2FA3DD10AB75A6F000E5AC4 /* JSSVGPathSegLinetoHorizontalAbs.h in Headers */, 25480 25483 B2FA3DD30AB75A6F000E5AC4 /* JSSVGPathSegLinetoHorizontalRel.h in Headers */, 25484 7C4C96E31AD44ABF00365A50 /* LaunchServicesSPI.h in Headers */, 25481 25485 B2FA3DD50AB75A6F000E5AC4 /* JSSVGPathSegLinetoRel.h in Headers */, 25482 25486 B2FA3DD70AB75A6F000E5AC4 /* JSSVGPathSegLinetoVerticalAbs.h in Headers */, -
trunk/Source/WebKit/mac/ChangeLog
r182638 r182648 1 2015-04-08 Sam Weinig <sam@webkit.org> 2 3 Allow LaunchServices to handle URLs on link navigations 4 <rdar://problem/19446826> 5 https://bugs.webkit.org/show_bug.cgi?id=143544 6 7 Reviewed by Anders Carlsson. 8 9 * Configurations/WebKitLegacy.xcconfig: 10 Link MobileCoreServices. 11 12 * WebCoreSupport/WebFrameLoaderClient.h: 13 * WebCoreSupport/WebFrameLoaderClient.mm: 14 (shouldTryAppLink): 15 (WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction): 16 (WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): 17 (WebFrameLoaderClient::setUpPolicyListener): 18 Only let LaunchServices have a crack at the URL if the navigation is: 19 1) a main frame navigation 20 2) a result of a user gesture 21 1 22 2015-04-10 Alexey Proskuryakov <ap@apple.com> 2 23 -
trunk/Source/WebKit/mac/Configurations/WebKitLegacy.xcconfig
r181273 r182648 72 72 UMBRELLA_FRAMEWORKS_DIR = $(PRODUCTION_FRAMEWORKS_DIR)/WebKit.framework/Versions/A/Frameworks; 73 73 74 OTHER_LDFLAGS[sdk=iphone*] = $(inherited) -lobjc -lsqlite3 -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework OpenGLES - lMobileGestalt;74 OTHER_LDFLAGS[sdk=iphone*] = $(inherited) -lobjc -lsqlite3 -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework OpenGLES -framework MobileCoreServices -lMobileGestalt; 75 75 OTHER_LDFLAGS[sdk=macosx*] = $(inherited) -framework Carbon -framework Cocoa -framework DiskArbitration -framework IOKit -framework OpenGL; 76 76 -
trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
r182032 r182648 222 222 virtual RemoteAXObjectRef accessibilityRemoteObject() override { return 0; } 223 223 224 RetainPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction );224 RetainPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction, NSURL *appLinkURL = nil); 225 225 226 226 NSDictionary *actionDictionary(const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>) const; -
trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
r181791 r182648 152 152 #endif 153 153 154 #if HAVE(APP_LINKS) 155 #import <WebCore/LaunchServicesSPI.h> 156 #import <WebCore/WebCoreThreadRun.h> 157 #endif 158 154 159 #if ENABLE(CONTENT_FILTERING) 155 160 #import <WebCore/PolicyChecker.h> … … 173 178 RefPtr<Frame> _frame; 174 179 FramePolicyFunction _policyFunction; 180 #if HAVE(APP_LINKS) 181 RetainPtr<NSURL> _appLinkURL; 182 #endif 175 183 } 176 184 177 185 - (id)initWithFrame:(Frame*)frame policyFunction:(FramePolicyFunction)policyFunction; 186 #if HAVE(APP_LINKS) 187 - (id)initWithFrame:(Frame*)frame policyFunction:(FramePolicyFunction)policyFunction appLinkURL:(NSURL *)url; 188 #endif 189 178 190 - (void)invalidate; 179 191 … … 872 884 } 873 885 886 887 static BOOL shouldTryAppLink(WebView *webView, const NavigationAction& action, Frame* targetFrame) 888 { 889 #if HAVE(APP_LINKS) 890 BOOL mainFrameNavigation = !targetFrame || targetFrame->isMainFrame(); 891 if (!mainFrameNavigation) 892 return NO; 893 894 if (!action.processingUserGesture()) 895 return NO; 896 897 return YES; 898 #else 899 return NO; 900 #endif 901 } 902 874 903 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, FramePolicyFunction function) 875 904 { 876 905 WebView *webView = getWebView(m_webFrame.get()); 906 BOOL tryAppLink = shouldTryAppLink(webView, action, nullptr); 907 877 908 [[webView _policyDelegateForwarder] webView:webView 878 909 decidePolicyForNewWindowAction:actionDictionary(action, formState) 879 910 request:request.nsURLRequest(UpdateHTTPBody) 880 911 newFrameName:frameName 881 decisionListener:setUpPolicyListener(WTF::move(function) ).get()];912 decisionListener:setUpPolicyListener(WTF::move(function), tryAppLink ? (NSURL *)request.url() : nil).get()]; 882 913 } 883 914 … … 885 916 { 886 917 WebView *webView = getWebView(m_webFrame.get()); 918 BOOL tryAppLink = shouldTryAppLink(webView, action, core(m_webFrame.get())); 919 887 920 [[webView _policyDelegateForwarder] webView:webView 888 921 decidePolicyForNavigationAction:actionDictionary(action, formState) 889 922 request:request.nsURLRequest(UpdateHTTPBody) 890 923 frame:m_webFrame.get() 891 decisionListener:setUpPolicyListener(WTF::move(function) ).get()];924 decisionListener:setUpPolicyListener(WTF::move(function), tryAppLink ? (NSURL *)request.url() : nil).get()]; 892 925 } 893 926 … … 1473 1506 } 1474 1507 1475 RetainPtr<WebFramePolicyListener> WebFrameLoaderClient::setUpPolicyListener(FramePolicyFunction function )1508 RetainPtr<WebFramePolicyListener> WebFrameLoaderClient::setUpPolicyListener(FramePolicyFunction function, NSURL *appLinkURL) 1476 1509 { 1477 1510 // FIXME: <rdar://5634381> We need to support multiple active policy listeners. 1478 1511 [m_policyListener invalidate]; 1479 1512 1480 m_policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:function]); 1513 #if HAVE(APP_LINKS) 1514 if (appLinkURL) 1515 m_policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:function appLinkURL:appLinkURL]); 1516 else 1517 #endif 1518 m_policyListener = adoptNS([[WebFramePolicyListener alloc] initWithFrame:core(m_webFrame.get()) policyFunction:function]); 1481 1519 1482 1520 return m_policyListener; … … 2272 2310 } 2273 2311 2312 #if HAVE(APP_LINKS) 2313 - (id)initWithFrame:(Frame*)frame policyFunction:(FramePolicyFunction)policyFunction appLinkURL:(NSURL *)appLinkURL 2314 { 2315 self = [self initWithFrame:frame policyFunction:policyFunction]; 2316 if (!self) 2317 return nil; 2318 2319 _appLinkURL = appLinkURL; 2320 2321 return self; 2322 } 2323 #endif 2324 2274 2325 - (void)invalidate 2275 2326 { … … 2310 2361 - (void)use 2311 2362 { 2363 #if HAVE(APP_LINKS) 2364 if (_appLinkURL && _frame) { 2365 [LSAppLink openWithURL:_appLinkURL.get() completionHandler:^(BOOL success, NSError *) { 2366 WebThreadRun(^{ 2367 if (success) 2368 [self receivedPolicyDecision:PolicyIgnore]; 2369 else 2370 [self receivedPolicyDecision:PolicyUse]; 2371 }); 2372 }]; 2373 return; 2374 } 2375 #endif 2376 2312 2377 [self receivedPolicyDecision:PolicyUse]; 2313 2378 } -
trunk/Source/WebKit2/ChangeLog
r182640 r182648 1 2015-04-08 Sam Weinig <sam@webkit.org> 2 3 Allow LaunchServices to handle URLs on link navigations 4 <rdar://problem/19446826> 5 https://bugs.webkit.org/show_bug.cgi?id=143544 6 7 Reviewed by Anders Carlsson. 8 9 * UIProcess/Cocoa/NavigationState.mm: 10 (WebKit::tryAppLink): 11 (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): 12 Only let LaunchServices have a crack at the URL if the navigation is: 13 1) a main frame navigation 14 2) a result of a user gesture 15 1 16 2015-04-10 Tim Horton <timothy_horton@apple.com> 2 17 -
trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm
r179786 r182648 65 65 #import <wtf/NeverDestroyed.h> 66 66 67 #if HAVE(APP_LINKS) 68 #import <WebCore/LaunchServicesSPI.h> 69 #endif 70 67 71 #if USE(QUICK_LOOK) 68 72 #import "QuickLookDocumentData.h" … … 225 229 } 226 230 231 static void tryAppLink(RefPtr<API::NavigationAction> navigationAction, std::function<void (bool)> completionHandler) 232 { 233 #if HAVE(APP_LINKS) 234 bool mainFrameNavigation = !navigationAction->targetFrame() || navigationAction->targetFrame()->isMainFrame(); 235 bool isProcessingUserGesture = navigationAction->isProcessingUserGesture(); 236 if (mainFrameNavigation && isProcessingUserGesture) { 237 auto* localCompletionHandler = new std::function<void (bool)>(WTF::move(completionHandler)); 238 [LSAppLink openWithURL:navigationAction->request().url() completionHandler:[localCompletionHandler](BOOL success, NSError *) { 239 dispatch_async(dispatch_get_main_queue(), [localCompletionHandler, success] { 240 (*localCompletionHandler)(success); 241 delete localCompletionHandler; 242 }); 243 }]; 244 return; 245 } 246 #endif 247 248 completionHandler(false); 249 } 250 227 251 void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageProxy&, API::NavigationAction& navigationAction, Ref<WebFramePolicyListenerProxy>&& listener, API::Object* userData) 228 252 { 229 253 if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler) { 230 RetainPtr<NSURLRequest> nsURLRequest = adoptNS(wrapper(*API::URLRequest::create(navigationAction.request()).leakRef())); 231 232 if (!navigationAction.targetFrame()) { 233 listener->use(); 234 return; 235 } 236 237 if ([NSURLConnection canHandleRequest:nsURLRequest.get()]) { 238 listener->use(); 239 return; 240 } 254 RefPtr<API::NavigationAction> localNavigationAction = &navigationAction; 255 RefPtr<WebFramePolicyListenerProxy> localListener = WTF::move(listener); 256 257 tryAppLink(localNavigationAction, [localListener, localNavigationAction] (bool followedLinkToApp) { 258 if (followedLinkToApp) { 259 localListener->ignore(); 260 return; 261 } 262 263 if (!localNavigationAction->targetFrame()) { 264 localListener->use(); 265 return; 266 } 267 268 RetainPtr<NSURLRequest> nsURLRequest = adoptNS(wrapper(*API::URLRequest::create(localNavigationAction->request()).leakRef())); 269 if ([NSURLConnection canHandleRequest:nsURLRequest.get()]) { 270 localListener->use(); 271 return; 272 } 241 273 242 274 #if PLATFORM(MAC) 243 // A file URL shouldn't fall through to here, but if it did,244 // it would be a security risk to open it.245 if (![[nsURLRequest URL] isFileURL])246 [[NSWorkspace sharedWorkspace] openURL:[nsURLRequest URL]];275 // A file URL shouldn't fall through to here, but if it did, 276 // it would be a security risk to open it. 277 if (![[nsURLRequest URL] isFileURL]) 278 [[NSWorkspace sharedWorkspace] openURL:[nsURLRequest URL]]; 247 279 #endif 248 listener->ignore(); 280 localListener->ignore(); 281 }); 282 249 283 return; 250 284 } … … 254 288 return; 255 289 290 RefPtr<API::NavigationAction> localNavigationAction = &navigationAction; 256 291 RefPtr<WebFramePolicyListenerProxy> localListener = WTF::move(listener); 257 292 RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:decidePolicyForNavigationAction:decisionHandler:)); 258 [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:wrapper(navigationAction) decisionHandler:[localListener, checker](WKNavigationActionPolicy actionPolicy) {293 [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:wrapper(navigationAction) decisionHandler:[localListener, localNavigationAction, checker](WKNavigationActionPolicy actionPolicy) { 259 294 checker->didCallCompletionHandler(); 260 295 261 296 switch (actionPolicy) { 262 297 case WKNavigationActionPolicyAllow: 263 localListener->use(); 298 tryAppLink(localNavigationAction, [localListener](bool followedLinkToApp) { 299 if (followedLinkToApp) { 300 localListener->ignore(); 301 return; 302 } 303 304 localListener->use(); 305 }); 306 264 307 break; 265 308
Note: See TracChangeset
for help on using the changeset viewer.