Bug 143544 - Allow LaunchServices to handle URLs on link navigations
Summary: Allow LaunchServices to handle URLs on link navigations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-08 17:38 PDT by Sam Weinig
Modified: 2015-04-10 22:08 PDT (History)
3 users (show)

See Also:


Attachments
Patch (23.06 KB, patch)
2015-04-08 17:44 PDT, Sam Weinig
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2015-04-08 17:38:38 PDT
Allow LaunchServices to handle URLs on link navigations.
Comment 1 Sam Weinig 2015-04-08 17:38:57 PDT
<rdar://problem/19446826>
Comment 2 Sam Weinig 2015-04-08 17:44:27 PDT
Created attachment 250398 [details]
Patch
Comment 3 WebKit Commit Bot 2015-04-08 17:47:21 PDT
Attachment 250398 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:231:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:231:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:237:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:291:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm:912:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm:924:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm:2365:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 7 in 11 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Anders Carlsson 2015-04-08 18:14:29 PDT
Comment on attachment 250398 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250398&action=review

> Source/WebCore/platform/spi/ios/LaunchServicesSPI.h:39
> +typedef void (^ LSAppLinkOpenCompletionHandler)(BOOL success, NSError *error);

No space after ^.

> Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:240
> +            dispatch_async(dispatch_get_main_queue(), [completionHandler, success] {
> +                completionHandler(success);
> +            });

This is copying the completion handler on a background queue - that's not thread safe and will break if the completion handler has bound strings for example. I think you're going to have to create an std::function pointer and pass it across the thread boundary and then explicitly delete it on the main thread.

> Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:255
> +        tryAppLink(localNavigationAction, [localListener, localNavigationAction] (bool followedLinkToApp) {

What's ensuring that the web view doesn't go away while waiting for the completion handler to be invoked?
Comment 5 Sam Weinig 2015-04-10 10:53:39 PDT
(In reply to comment #4)
> Comment on attachment 250398 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=250398&action=review
> 
> > Source/WebCore/platform/spi/ios/LaunchServicesSPI.h:39
> > +typedef void (^ LSAppLinkOpenCompletionHandler)(BOOL success, NSError *error);
> 
> No space after ^.

Fixed.

> 
> > Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:240
> > +            dispatch_async(dispatch_get_main_queue(), [completionHandler, success] {
> > +                completionHandler(success);
> > +            });
> 
> This is copying the completion handler on a background queue - that's not
> thread safe and will break if the completion handler has bound strings for
> example. I think you're going to have to create an std::function pointer and
> pass it across the thread boundary and then explicitly delete it on the main
> thread.

Ok. How about if I just use a block?

> 
> > Source/WebKit2/UIProcess/Cocoa/NavigationState.mm:255
> > +        tryAppLink(localNavigationAction, [localListener, localNavigationAction] (bool followedLinkToApp) {
> 
> What's ensuring that the web view doesn't go away while waiting for the
> completion handler to be invoked?

Nothing, though that should be fine.  The listener will be invalidated and thus when it is called with success or failure, it will just do nothing.
Comment 6 Sam Weinig 2015-04-10 18:45:59 PDT
Committed r182648: <http://trac.webkit.org/changeset/182648>
Comment 7 Alexey Proskuryakov 2015-04-10 22:08:35 PDT
Build fix in <http://trac.webkit.org/r182650>.