WebKit Bugzilla
Attachment 361998 Details for
Bug 194645
: Clean up WKActionSheetAssistant's use of LaunchServices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194645-20190213233332.patch (text/plain), 8.72 KB, created by
Tim Horton
on 2019-02-13 23:33:32 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2019-02-13 23:33:32 PST
Size:
8.72 KB
patch
obsolete
>Subversion Revision: 241453 >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index af09be12e9470e39f966b11a509b9bb8463aa10b..f5db2d8ef0fd684fb8b63ffe7504ea9bcbf6c3b7 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,13 @@ >+2019-02-13 Tim Horton <timothy_horton@apple.com> >+ >+ Clean up WKActionSheetAssistant's use of LaunchServices >+ https://bugs.webkit.org/show_bug.cgi?id=194645 >+ <rdar://problem/47707952> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * pal/spi/cocoa/LaunchServicesSPI.h: >+ > 2019-02-12 Chris Fleizach <cfleizach@apple.com> > > AX: IsolatedTree: Implement more attributes >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 4b97c0ff8b8730e9f207b7f7eaf1cfb25d422a51..4051b87c81b94d964935b35a6cc91b267a05d3ba 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,20 @@ >+2019-02-13 Tim Horton <timothy_horton@apple.com> >+ >+ Clean up WKActionSheetAssistant's use of LaunchServices >+ https://bugs.webkit.org/show_bug.cgi?id=194645 >+ <rdar://problem/47707952> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/ios/WKActionSheetAssistant.mm: >+ (applicationHasAppLinkEntitlements): >+ (-[WKActionSheetAssistant _appendAppLinkOpenActionsForURL:actions:elementInfo:]): >+ (-[WKActionSheetAssistant _appendOpenActionsForURL:actions:elementInfo:]): >+ (appLinkForURL): Deleted. >+ Make this function much more early-returny and flat. >+ Adopt LS sync SPI instead of using a semaphore ourselves. >+ Adopt modern open SPI. >+ > 2019-02-13 Michael Catanzaro <mcatanzaro@igalia.com> > > Fix -Wformat warning from r241401 >diff --git a/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h b/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h >index 69ff8526c1bf66f1af2629159008bf07551a868b..1063950d6caa16fdf4691a5ea9443a93e34b6805 100644 >--- a/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h >+++ b/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h >@@ -60,9 +60,9 @@ typedef void (^LSAppLinkOpenCompletionHandler)(BOOL success, NSError *error); > @end > > @interface LSAppLink () >-+ (void)getAppLinkWithURL:(NSURL *)aURL completionHandler:(LSAppLinkCompletionHandler)completionHandler; >++ (NSArray<LSAppLink *> *)appLinksWithURL:(NSURL *)aURL limit:(NSUInteger)limit error:(NSError **)outError; > + (void)openWithURL:(NSURL *)aURL completionHandler:(LSAppLinkOpenCompletionHandler)completionHandler; >-- (void)openInWebBrowser:(BOOL)inWebBrowser setAppropriateOpenStrategyAndWebBrowserState:(NSDictionary<NSString *, id> *)state completionHandler:(LSAppLinkOpenCompletionHandler)completionHandler; >+- (void)openWithCompletionHandler:(LSAppLinkOpenCompletionHandler)completionHandler; > @property (readonly, strong) LSApplicationProxy *targetApplicationProxy; > @end > #endif >diff --git a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >index 5f2dd2e5cbff274ba7c9a9ed2716211007ef0684..0bc19e57810a779d034da1b8b43bab5cda718bc8 100644 >--- a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >+++ b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >@@ -46,7 +46,6 @@ > #import <wtf/cocoa/Entitlements.h> > #import <wtf/cocoa/NSURLExtras.h> > #import <wtf/text/WTFString.h> >-#import <wtf/threads/BinarySemaphore.h> > > #if HAVE(APP_LINKS) > #import <pal/spi/cocoa/LaunchServicesSPI.h> >@@ -68,21 +67,6 @@ static bool applicationHasAppLinkEntitlements() > static bool hasEntitlement = WTF::processHasEntitlement("com.apple.private.canGetAppLinkInfo") && WTF::processHasEntitlement("com.apple.private.canModifyAppLinkPermissions"); > return hasEntitlement; > } >- >-static LSAppLink *appLinkForURL(NSURL *url) >-{ >- BinarySemaphore semaphore; >- __block LSAppLink *syncAppLink = nil; >- __block BinarySemaphore* semaphorePtr = &semaphore; >- >- [LSAppLink getAppLinkWithURL:url completionHandler:^(LSAppLink *appLink, NSError *error) { >- syncAppLink = [appLink retain]; >- semaphorePtr->signal(); >- }]; >- semaphore.wait(); >- >- return [syncAppLink autorelease]; >-} > #endif > > @implementation WKActionSheetAssistant { >@@ -429,40 +413,49 @@ - (WKActionSheetPresentationStyle)_presentationStyleForPositionInfo:(const WebKi > return WKActionSheetPresentAtElementRect; > } > >+#if HAVE(APP_LINKS) >+- (BOOL)_appendAppLinkOpenActionsForURL:(NSURL *)url actions:(NSMutableArray *)defaultActions elementInfo:(_WKActivatedElementInfo *)elementInfo >+{ >+ ASSERT(_delegate); >+ >+ if (!applicationHasAppLinkEntitlements() || ![_delegate.get() actionSheetAssistant:self shouldIncludeAppLinkActionsForElement:elementInfo]) >+ return NO; >+ >+ NSArray<LSAppLink *> *appLinks = [LSAppLink appLinksWithURL:url limit:1 error:nil]; >+ LSAppLink *appLink = appLinks.firstObject; >+ if (!appLink) >+ return NO; >+ >+ NSString *openInDefaultBrowserTitle = WEB_UI_STRING("Open in Safari", "Title for Open in Safari Link action button"); >+ _WKElementAction *openInDefaultBrowserAction = [_WKElementAction _elementActionWithType:_WKElementActionTypeOpenInDefaultBrowser title:openInDefaultBrowserTitle actionHandler:^(_WKActivatedElementInfo *) { >+ appLink.enabled = NO; >+ [appLink openWithCompletionHandler:nil]; >+ }]; >+ [defaultActions addObject:openInDefaultBrowserAction]; >+ >+ NSString *externalApplicationName = [appLink.targetApplicationProxy localizedNameForContext:nil]; >+ if (!externalApplicationName) >+ return YES; >+ >+ NSString *openInExternalApplicationTitle = [NSString stringWithFormat:WEB_UI_STRING("Open in â%@â", "Title for Open in External Application Link action button"), externalApplicationName]; >+ _WKElementAction *openInExternalApplicationAction = [_WKElementAction _elementActionWithType:_WKElementActionTypeOpenInExternalApplication title:openInExternalApplicationTitle actionHandler:^(_WKActivatedElementInfo *) { >+ appLink.enabled = YES; >+ [appLink openWithCompletionHandler:nil]; >+ }]; >+ [defaultActions addObject:openInExternalApplicationAction]; >+ >+ return YES; >+} >+#endif >+ > - (void)_appendOpenActionsForURL:(NSURL *)url actions:(NSMutableArray *)defaultActions elementInfo:(_WKActivatedElementInfo *)elementInfo > { > #if HAVE(APP_LINKS) >- ASSERT(_delegate); >- if (applicationHasAppLinkEntitlements() && [_delegate.get() actionSheetAssistant:self shouldIncludeAppLinkActionsForElement:elementInfo]) { >- LSAppLink *appLink = appLinkForURL(url); >- if (appLink) { >- NSString *title = WEB_UI_STRING("Open in Safari", "Title for Open in Safari Link action button"); >- _WKElementAction *openInDefaultBrowserAction = [_WKElementAction _elementActionWithType:_WKElementActionTypeOpenInDefaultBrowser title:title actionHandler:^(_WKActivatedElementInfo *) { >-#pragma clang diagnostic push >-#pragma clang diagnostic ignored "-Wdeprecated-declarations" >- [appLink openInWebBrowser:YES setAppropriateOpenStrategyAndWebBrowserState:nil completionHandler:^(BOOL success, NSError *error) { }]; >-#pragma clang diagnostic pop >- }]; >- [defaultActions addObject:openInDefaultBrowserAction]; >- >- NSString *externalApplicationName = [appLink.targetApplicationProxy localizedNameForContext:nil]; >- if (externalApplicationName) { >- NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Open in â%@â", "Title for Open in External Application Link action button"), externalApplicationName]; >- _WKElementAction *openInExternalApplicationAction = [_WKElementAction _elementActionWithType:_WKElementActionTypeOpenInExternalApplication title:title actionHandler:^(_WKActivatedElementInfo *) { >-#pragma clang diagnostic push >-#pragma clang diagnostic ignored "-Wdeprecated-declarations" >- [appLink openInWebBrowser:NO setAppropriateOpenStrategyAndWebBrowserState:nil completionHandler:^(BOOL success, NSError *error) { }]; >-#pragma clang diagnostic pop >- }]; >- [defaultActions addObject:openInExternalApplicationAction]; >- } >- } else >- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]]; >- } else >- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]]; >-#else >- [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]]; >+ if ([self _appendAppLinkOpenActionsForURL:url actions:defaultActions elementInfo:elementInfo]) >+ return; > #endif >+ >+ [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]]; > } > > - (RetainPtr<NSArray>)defaultActionsForLinkSheet:(_WKActivatedElementInfo *)elementInfo
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194645
:
361998
|
368101