Diff
Modified: trunk/Source/WebKit2/ChangeLog (186718 => 186719)
--- trunk/Source/WebKit2/ChangeLog 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/ChangeLog 2015-07-11 22:58:13 UTC (rev 186719)
@@ -1,5 +1,43 @@
2015-07-11 Joseph Pecoraro <[email protected]>
+ Allow clients to opt-out of default app link link actions
+ https://bugs.webkit.org/show_bug.cgi?id=146883
+ <rdar://problem/21221902>
+
+ Reviewed by Dan Bernstein.
+
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::shouldIncludeAppLinkActionsForElement):
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::shouldIncludeAppLinkActionsForElement):
+ Plumbing for a new delegate message to ask the client if they
+ would like app link actions or not. Default is yes.
+
+ * UIProcess/ios/WKActionSheetAssistant.h:
+ * UIProcess/ios/WKActionSheetAssistant.mm:
+ (-[WKActionSheetAssistant showImageSheet]):
+ (-[WKActionSheetAssistant showLinkSheet]):
+ (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
+ (-[WKActionSheetAssistant defaultActionsForImageSheet:]):
+ Pass elementInfo into methods generating default actions.
+
+ (-[WKActionSheetAssistant _appendOpenActionsForURL:actions:elementInfo:]):
+ When generating open actions, if the process has AppLink capabilities
+ ask the client if they want to include AppLink actions or fall back
+ to the basic Open action.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView actionSheetAssistant:shouldIncludeAppLinkActionsForElement:]):
+ (-[WKContentView previewViewControllerForPosition:inSourceView:]):
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView actionSheetAssistant:shouldIncludeAppLinkActionsForElement:]):
+ Assistant delegate implementations forward to the UIDelegate.
+
+2015-07-11 Joseph Pecoraro <[email protected]>
+
Update default link action sheets for app links
https://bugs.webkit.org/show_bug.cgi?id=146658
<rdar://problem/21221902>
Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2015-07-11 22:58:13 UTC (rev 186719)
@@ -159,6 +159,9 @@
#endif
#if PLATFORM(IOS)
+#if HAVE(APP_LINKS)
+ virtual bool shouldIncludeAppLinkActionsForElement(_WKActivatedElementInfo *) { return true; }
+#endif
virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) { return WTF::move(defaultActions); }
virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) { }
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2015-07-11 22:58:13 UTC (rev 186719)
@@ -55,6 +55,7 @@
- (void)_webViewDidExitFullscreen:(WKWebView *)webView WK_AVAILABLE(WK_MAC_TBA, 8_3);
#if TARGET_OS_IPHONE
+- (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_AVAILABLE(NA, WK_IOS_TBA);
- (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray *)defaultActions;
- (void)_webView:(WKWebView *)webView didNotHandleTapAsClickAtPoint:(CGPoint)point;
- (BOOL)_webView:(WKWebView *)webView shouldRequestGeolocationAuthorizationForURL:(NSURL *)url isMainFrame:(BOOL)isMainFrame mainFrameURL:(NSURL *)mainFrameURL;
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h 2015-07-11 22:58:13 UTC (rev 186719)
@@ -69,10 +69,13 @@
virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)>) override;
virtual void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler) override;
virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
- #if PLATFORM(IOS)
+#if PLATFORM(IOS)
+#if HAVE(APP_LINKS)
+ virtual bool shouldIncludeAppLinkActionsForElement(_WKActivatedElementInfo *) override;
+#endif
virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) override;
virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) override;
- #endif
+#endif
UIDelegate& m_uiDelegate;
};
@@ -94,6 +97,9 @@
bool webViewDidEnterFullscreen : 1;
bool webViewDidExitFullscreen : 1;
#if PLATFORM(IOS)
+#if HAVE(APP_LINKS)
+ bool webViewShouldIncludeAppLinkActionsForElement : 1;
+#endif
bool webViewActionsForElementDefaultActions : 1;
bool webViewDidNotHandleTapAsClickAtPoint : 1;
#endif
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm 2015-07-11 22:58:13 UTC (rev 186719)
@@ -78,6 +78,9 @@
m_delegateMethods.webViewDidEnterFullscreen = [delegate respondsToSelector:@selector(_webViewDidEnterFullscreen:)];
m_delegateMethods.webViewDidExitFullscreen = [delegate respondsToSelector:@selector(_webViewDidExitFullscreen:)];
#if PLATFORM(IOS)
+#if HAVE(APP_LINKS)
+ m_delegateMethods.webViewShouldIncludeAppLinkActionsForElement = [delegate respondsToSelector:@selector(_webView:shouldIncludeAppLinkActionsForElement:)];
+#endif
m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
#endif
@@ -293,6 +296,20 @@
}
#if PLATFORM(IOS)
+#if HAVE(APP_LINKS)
+bool UIDelegate::UIClient::shouldIncludeAppLinkActionsForElement(_WKActivatedElementInfo *elementInfo)
+{
+ if (!m_uiDelegate.m_delegateMethods.webViewShouldIncludeAppLinkActionsForElement)
+ return true;
+
+ auto delegate = m_uiDelegate.m_delegate.get();
+ if (!delegate)
+ return true;
+
+ return [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView shouldIncludeAppLinkActionsForElement:elementInfo];
+}
+#endif
+
RetainPtr<NSArray> UIDelegate::UIClient::actionsForElement(_WKActivatedElementInfo *elementInfo, RetainPtr<NSArray> defaultActions)
{
if (!m_uiDelegate.m_delegateMethods.webViewActionsForElementDefaultActions)
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h 2015-07-11 22:58:13 UTC (rev 186719)
@@ -45,6 +45,9 @@
- (const WebKit::InteractionInformationAtPosition&)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action;
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location;
+#if HAVE(APP_LINKS)
+- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element;
+#endif
- (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions;
@optional
@@ -62,8 +65,8 @@
- (void)showDataDetectorsSheet;
- (void)cleanupSheet;
- (void)updateSheetPosition;
-- (RetainPtr<NSArray>)defaultActionsForLinkSheet;
-- (RetainPtr<NSArray>)defaultActionsForImageSheet;
+- (RetainPtr<NSArray>)defaultActionsForLinkSheet:(_WKActivatedElementInfo *)elementInfo;
+- (RetainPtr<NSArray>)defaultActionsForImageSheet:(_WKActivatedElementInfo *)elementInfo;
@end
#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm 2015-07-11 22:58:13 UTC (rev 186719)
@@ -273,8 +273,8 @@
const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
NSURL *targetURL = [NSURL _web_URLWithWTFString:positionInformation.url];
- auto defaultActions = [self defaultActionsForImageSheet];
auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
+ auto defaultActions = [self defaultActionsForImageSheet:elementInfo.get()];
RetainPtr<NSArray> actions = [delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
@@ -291,10 +291,11 @@
[self cleanupSheet];
}
-- (void)_appendOpenActionsForURL:(NSURL *)url actions:(NSMutableArray *)defaultActions
+- (void)_appendOpenActionsForURL:(NSURL *)url actions:(NSMutableArray *)defaultActions elementInfo:(_WKActivatedElementInfo *)elementInfo
{
#if HAVE(APP_LINKS)
- if (applicationHasAppLinkEntitlements()) {
+ 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");
@@ -320,7 +321,7 @@
#endif
}
-- (RetainPtr<NSArray>)defaultActionsForLinkSheet
+- (RetainPtr<NSArray>)defaultActionsForLinkSheet:(_WKActivatedElementInfo *)elementInfo
{
auto delegate = _delegate.get();
if (!delegate)
@@ -333,7 +334,7 @@
return nil;
auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
- [self _appendOpenActionsForURL:targetURL actions:defaultActions.get()];
+ [self _appendOpenActionsForURL:targetURL actions:defaultActions.get() elementInfo:elementInfo];
#if HAVE(SAFARI_SERVICES_FRAMEWORK)
if ([getSSReadingListClass() supportsURL:targetURL])
@@ -345,7 +346,7 @@
return defaultActions;
}
-- (RetainPtr<NSArray>)defaultActionsForImageSheet
+- (RetainPtr<NSArray>)defaultActionsForImageSheet:(_WKActivatedElementInfo *)elementInfo
{
auto delegate = _delegate.get();
if (!delegate)
@@ -356,7 +357,7 @@
auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
if (!positionInformation.url.isEmpty())
- [self _appendOpenActionsForURL:targetURL actions:defaultActions.get()];
+ [self _appendOpenActionsForURL:targetURL actions:defaultActions.get() elementInfo:elementInfo];
#if HAVE(SAFARI_SERVICES_FRAMEWORK)
if ([getSSReadingListClass() supportsURL:targetURL])
@@ -385,9 +386,8 @@
if (!targetURL)
return;
- auto defaultActions = [self defaultActionsForLinkSheet];
- RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink
- URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
+ auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
+ auto defaultActions = [self defaultActionsForLinkSheet:elementInfo.get()];
RetainPtr<NSArray> actions = [delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2015-07-11 22:58:13 UTC (rev 186719)
@@ -3152,6 +3152,13 @@
[self _attemptClickAtLocation:location];
}
+#if HAVE(APP_LINKS)
+- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element
+{
+ return _page->uiClient().shouldIncludeAppLinkActionsForElement(element);
+}
+#endif
+
- (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions
{
return _page->uiClient().actionsForElement(element, WTF::move(defaultActions));
@@ -3215,7 +3222,7 @@
_highlightLongPressCanClick = NO;
RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:_positionInformation.image.get()]);
_page->startInteractionWithElementAtPosition(_positionInformation.point);
- return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL defaultActions:[_actionSheetAssistant defaultActionsForLinkSheet].get() elementInfo:elementInfo.get()];
+ return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL defaultActions:[_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()].get() elementInfo:elementInfo.get()];
}
if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:)]) {
@@ -3245,7 +3252,7 @@
[uiDelegate _webView:_webView willPreviewImageWithURL:targetURL];
RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:_positionInformation.image.get()]);
_page->startInteractionWithElementAtPosition(_positionInformation.point);
- return [[[WKImagePreviewViewController alloc] initWithCGImage:_positionInformation.image->makeCGImageCopy() defaultActions:[_actionSheetAssistant defaultActionsForImageSheet] elementInfo:elementInfo] autorelease];
+ return [[[WKImagePreviewViewController alloc] initWithCGImage:_positionInformation.image->makeCGImageCopy() defaultActions:[_actionSheetAssistant defaultActionsForImageSheet:elementInfo.get()] elementInfo:elementInfo] autorelease];
}
return nil;
Modified: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm (186718 => 186719)
--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2015-07-11 22:58:08 UTC (rev 186718)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2015-07-11 22:58:13 UTC (rev 186719)
@@ -718,6 +718,13 @@
_webView->_page->navigateToPDFLinkWithSimulatedClick(_positionInformation.url, roundedIntPoint(location), roundedIntPoint(screenPoint));
}
+#if HAVE(APP_LINKS)
+- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element
+{
+ return _webView->_page->uiClient().shouldIncludeAppLinkActionsForElement(element);
+}
+#endif
+
- (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions
{
return _webView->_page->uiClient().actionsForElement(element, WTF::move(defaultActions));