Title: [186718] trunk/Source
Revision
186718
Author
[email protected]
Date
2015-07-11 15:58:08 -0700 (Sat, 11 Jul 2015)

Log Message

Update default link action sheets for app links
https://bugs.webkit.org/show_bug.cgi?id=146658
<rdar://problem/21221902>

Reviewed by Dan Bernstein.

Source/WebCore:

* English.lproj/Localizable.strings:
* platform/spi/ios/LaunchServicesSPI.h:

Source/WebKit2:

* Shared/mac/SandboxUtilities.h:
* Shared/mac/SandboxUtilities.mm: Renamed from Source/WebKit2/Shared/mac/SandboxUtilities.cpp.
(WebKit::processHasEntitlement):
* UIProcess/ApplicationStateTracker.mm:
(WebKit::applicationType):
(WebKit::hasEntitlement): Deleted.
* WebKit2.xcodeproj/project.pbxproj:
Share a helper for checking if the current process has an entitlement.

* UIProcess/API/Cocoa/_WKElementAction.h:
* UIProcess/API/Cocoa/_WKElementAction.mm:
(+[_WKElementAction _elementActionWithType:title:actionHandler:]):
(+[_WKElementAction _elementActionWithType:customTitle:assistant:]):
* UIProcess/API/Cocoa/_WKElementActionInternal.h:
Add an internal way to make an element action with a standard type and regular handler.
We use this for the new standard types that don't have a default implementation.

* UIProcess/ios/WKActionSheetAssistant.mm:
(applicationHasAppLinkEntitlements):
(appLinkForURL):
Helpers checking access to app links and fetching app links.

(-[WKActionSheetAssistant _appendOpenActionsForURL:actions:]):
(-[WKActionSheetAssistant defaultActionsForLinkSheet]):
(-[WKActionSheetAssistant defaultActionsForImageSheet]):
Create "Open in Safari" and "Open in 'App'" default actions for AppLinks,
otherwise add the normal default "Open" action.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (186717 => 186718)


--- trunk/Source/WebCore/ChangeLog	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebCore/ChangeLog	2015-07-11 22:58:08 UTC (rev 186718)
@@ -1,3 +1,14 @@
+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>
+
+        Reviewed by Dan Bernstein.
+
+        * English.lproj/Localizable.strings:
+        * platform/spi/ios/LaunchServicesSPI.h:
+
 2015-07-11  Benjamin Poulain  <[email protected]>
 
         Fix CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING

Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (186717 => 186718)


--- trunk/Source/WebCore/English.lproj/Localizable.strings	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings	2015-07-11 22:58:08 UTC (rev 186718)
@@ -182,7 +182,7 @@
 "Copy" = "Copy";
 
 /* Title for Copy Link or Image action button */
-"Copy ActionSheet Link" = "Copy";
+"Copy (ActionSheet)" = "Copy";
 
 /* Copy Audio Address Location context menu item */
 "Copy Audio Address" = "Copy Audio Address";
@@ -371,7 +371,7 @@
 "Off" = "Off";
 
 /* Title for Open Link action button */
-"Open ActionSheet Link" = "Open";
+"Open" = "Open";
 
 /* Open Audio in New Window context menu item */
 "Open Audio in New Window" = "Open Audio in New Window";
@@ -391,6 +391,12 @@
 /* Open Video in New Window context menu item */
 "Open Video in New Window" = "Open Video in New Window";
 
+/* Title for Open in Safari Link action button */
+"Open in Safari" = "Open in Safari";
+
+/* Title for Open in External Application Link action button */
+"Open in “%@”" = "Open in “%@”";
+
 /* context menu item for PDF */
 "Open with %@" = "Open with %@";
 

Modified: trunk/Source/WebCore/platform/spi/ios/LaunchServicesSPI.h (186717 => 186718)


--- trunk/Source/WebCore/platform/spi/ios/LaunchServicesSPI.h	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebCore/platform/spi/ios/LaunchServicesSPI.h	2015-07-11 22:58:08 UTC (rev 186718)
@@ -46,6 +46,7 @@
 
 @interface LSAppLink (Details)
 + (void)openWithURL:(NSURL *)aURL completionHandler:(LSAppLinkOpenCompletionHandler)completionHandler;
+- (void)openInWebBrowser:(BOOL)inWebBrowser setAppropriateOpenStrategyAndWebBrowserState:(NSDictionary<NSString *, id> *)state completionHandler:(LSAppLinkOpenCompletionHandler)completionHandler;
 @end
 #endif
 

Modified: trunk/Source/WebKit2/ChangeLog (186717 => 186718)


--- trunk/Source/WebKit2/ChangeLog	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-11 22:58:08 UTC (rev 186718)
@@ -1,3 +1,39 @@
+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>
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/mac/SandboxUtilities.h:
+        * Shared/mac/SandboxUtilities.mm: Renamed from Source/WebKit2/Shared/mac/SandboxUtilities.cpp.
+        (WebKit::processHasEntitlement):
+        * UIProcess/ApplicationStateTracker.mm:
+        (WebKit::applicationType):
+        (WebKit::hasEntitlement): Deleted.
+        * WebKit2.xcodeproj/project.pbxproj:
+        Share a helper for checking if the current process has an entitlement.
+
+        * UIProcess/API/Cocoa/_WKElementAction.h:
+        * UIProcess/API/Cocoa/_WKElementAction.mm:
+        (+[_WKElementAction _elementActionWithType:title:actionHandler:]):
+        (+[_WKElementAction _elementActionWithType:customTitle:assistant:]):
+        * UIProcess/API/Cocoa/_WKElementActionInternal.h:
+        Add an internal way to make an element action with a standard type and regular handler.
+        We use this for the new standard types that don't have a default implementation.
+
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (applicationHasAppLinkEntitlements):
+        (appLinkForURL):
+        Helpers checking access to app links and fetching app links.
+
+        (-[WKActionSheetAssistant _appendOpenActionsForURL:actions:]):
+        (-[WKActionSheetAssistant defaultActionsForLinkSheet]):
+        (-[WKActionSheetAssistant defaultActionsForImageSheet]):
+        Create "Open in Safari" and "Open in 'App'" default actions for AppLinks,
+        otherwise add the normal default "Open" action.
+
 2015-07-11  Enrica Casucci  <[email protected]>
 
         Remove incorrect overriding of inputAssistantItem in WKContentView.

Deleted: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp (186717 => 186718)


--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp	2015-07-11 22:58:08 UTC (rev 186718)
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SandboxUtilities.h"
-
-#include <array>
-#include <sys/param.h>
-#include <wtf/text/WTFString.h>
-
-#if __has_include(<sandbox/private.h>)
-#import <sandbox/private.h>
-#else
-enum sandbox_filter_type {
-    SANDBOX_FILTER_NONE,
-};
-extern "C" {
-int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
-int sandbox_container_path_for_pid(pid_t, char *buffer, size_t bufsize);
-}
-#endif
-
-namespace WebKit {
-
-bool processIsSandboxed(pid_t pid)
-{
-    return sandbox_check(pid, nullptr, SANDBOX_FILTER_NONE);
-}
-
-static bool processHasContainer(pid_t pid)
-{
-    std::array<char, MAXPATHLEN> path;
-
-    if (sandbox_container_path_for_pid(pid, path.data(), path.size()))
-        return false;
-
-    if (!path[0])
-        return false;
-
-    return true;
-}
-
-bool processHasContainer()
-{
-    static bool hasContainer = processHasContainer(getpid());
-
-    return hasContainer;
-}
-
-String pathForProcessContainer()
-{
-    std::array<char, MAXPATHLEN> path;
-    path[0] = 0;
-    sandbox_container_path_for_pid(getpid(), path.data(), path.size());
-
-    return String::fromUTF8(path.data());
-}
-
-}

Modified: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h (186717 => 186718)


--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h	2015-07-11 22:58:08 UTC (rev 186718)
@@ -26,8 +26,8 @@
 #ifndef SandboxUtilities_h
 #define SandboxUtilities_h
 
-#include <sys/types.h>
-#include <wtf/Forward.h>
+#import <sys/types.h>
+#import <wtf/Forward.h>
 
 namespace WebKit {
 
@@ -37,6 +37,8 @@
 // Returns an empty string if the process is not in a container.
 String pathForProcessContainer();
 
+bool processHasEntitlement(NSString *entitlement);
+
 }
 
 #endif // SandboxUtilities_h

Copied: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.mm (from rev 186717, trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp) (0 => 186718)


--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.mm	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.mm	2015-07-11 22:58:08 UTC (rev 186718)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "SandboxUtilities.h"
+
+#import <WebCore/SecuritySPI.h>
+#import <array>
+#import <sys/param.h>
+#import <wtf/text/WTFString.h>
+
+#if __has_include(<sandbox/private.h>)
+#import <sandbox/private.h>
+#else
+enum sandbox_filter_type {
+    SANDBOX_FILTER_NONE,
+};
+extern "C" {
+int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
+int sandbox_container_path_for_pid(pid_t, char *buffer, size_t bufsize);
+}
+#endif
+
+namespace WebKit {
+
+bool processIsSandboxed(pid_t pid)
+{
+    return sandbox_check(pid, nullptr, SANDBOX_FILTER_NONE);
+}
+
+static bool processHasContainer(pid_t pid)
+{
+    std::array<char, MAXPATHLEN> path;
+
+    if (sandbox_container_path_for_pid(pid, path.data(), path.size()))
+        return false;
+
+    if (!path[0])
+        return false;
+
+    return true;
+}
+
+bool processHasContainer()
+{
+    static bool hasContainer = processHasContainer(getpid());
+
+    return hasContainer;
+}
+
+String pathForProcessContainer()
+{
+    std::array<char, MAXPATHLEN> path;
+    path[0] = 0;
+    sandbox_container_path_for_pid(getpid(), path.data(), path.size());
+
+    return String::fromUTF8(path.data());
+}
+
+bool processHasEntitlement(NSString *entitlement)
+{
+    auto task = adoptCF(SecTaskCreateFromSelf(CFAllocatorGetDefault()));
+    if (!task)
+        return false;
+
+    auto value = adoptCF(SecTaskCopyValueForEntitlement(task.get(), (__bridge CFStringRef)entitlement, nullptr));
+    if (!value)
+        return false;
+
+    if (CFGetTypeID(value.get()) != CFBooleanGetTypeID())
+        return false;
+
+    return CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()));
+}
+
+}

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h (186717 => 186718)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h	2015-07-11 22:58:08 UTC (rev 186718)
@@ -41,6 +41,8 @@
     _WKElementActionTypeSaveImage,
 #if !defined(TARGET_OS_IOS) || TARGET_OS_IOS
     _WKElementActionTypeAddToReadingList,
+    _WKElementActionTypeOpenInDefaultBrowser WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA),
+    _WKElementActionTypeOpenInExternalApplication WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA),
 #endif
 } WK_ENUM_AVAILABLE(10_10, 8_0);
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm (186717 => 186718)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm	2015-07-11 22:58:08 UTC (rev 186718)
@@ -90,25 +90,31 @@
 }
 #endif
 
++ (instancetype)_elementActionWithType:(_WKElementActionType)type title:(NSString *)title actionHandler:(WKElementActionHandler)actionHandler
+{
+    WKElementActionHandlerInternal handler = ^(WKActionSheetAssistant *, _WKActivatedElementInfo *actionInfo) { actionHandler(actionInfo); };
+    return [[[self alloc] _initWithTitle:title actionHandler:handler type:type assistant:nil] autorelease];
+}
+
 + (instancetype)_elementActionWithType:(_WKElementActionType)type customTitle:(NSString *)customTitle assistant:(WKActionSheetAssistant *)assistant
 {
     NSString *title;
     WKElementActionHandlerInternal handler;
     switch (type) {
     case _WKElementActionTypeCopy:
-        title = WEB_UI_STRING_KEY("Copy", "Copy ActionSheet Link", "Title for Copy Link or Image action button");
+        title = WEB_UI_STRING_KEY("Copy", "Copy (ActionSheet)", "Title for Copy Link or Image action button");
         handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
             [assistant.delegate actionSheetAssistant:assistant performAction:WebKit::SheetAction::Copy];
         };
         break;
     case _WKElementActionTypeOpen:
-        title = WEB_UI_STRING_KEY("Open", "Open ActionSheet Link", "Title for Open Link action button");
+        title = WEB_UI_STRING("Open", "Title for Open Link action button");
         handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
             [assistant.delegate actionSheetAssistant:assistant openElementAtLocation:actionInfo._interactionLocation];
         };
         break;
     case _WKElementActionTypeSaveImage:
-        title = WEB_UI_STRING_KEY("Save Image", "Save Image", "Title for Save Image action button");
+        title = WEB_UI_STRING("Save Image", "Title for Save Image action button");
         handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
             [assistant.delegate actionSheetAssistant:assistant performAction:WebKit::SheetAction::SaveImage];
         };

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h (186717 => 186718)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h	2015-07-11 22:58:08 UTC (rev 186718)
@@ -35,6 +35,7 @@
 @interface _WKElementAction ()
 
 + (instancetype)_elementActionWithType:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant;
++ (instancetype)_elementActionWithType:(_WKElementActionType)type title:(NSString *)title actionHandler:(WKElementActionHandler)actionHandler;
 - (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info forActionSheetAssistant:(WKActionSheetAssistant *)assistant;
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.mm (186717 => 186718)


--- trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.mm	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/UIProcess/ApplicationStateTracker.mm	2015-07-11 22:58:08 UTC (rev 186718)
@@ -29,6 +29,7 @@
 #if PLATFORM(IOS)
 
 #import "AssertionServicesSPI.h"
+#import "SandboxUtilities.h"
 #import "UIKitSPI.h"
 #import "WKContentView.h"
 #import <WebCore/SecuritySPI.h>
@@ -41,22 +42,7 @@
 
 namespace WebKit {
 
-static bool hasEntitlement(NSString *entitlement)
-{
-    auto task = adoptCF(SecTaskCreateFromSelf(CFAllocatorGetDefault()));
-    if (!task)
-        return false;
 
-    auto value = adoptCF(SecTaskCopyValueForEntitlement(task.get(), (__bridge CFStringRef)entitlement, nullptr));
-    if (!value)
-        return false;
-
-    if (CFGetTypeID(value.get()) != CFBooleanGetTypeID())
-        return false;
-
-    return CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()));
-}
-
 enum class ApplicationType {
     Application,
     ViewService,
@@ -70,7 +56,7 @@
     if (_UIApplicationIsExtension())
         return ApplicationType::Extension;
 
-    if (hasEntitlement(@"com.apple.UIKit.vends-view-services") && window._isHostedInAnotherProcess)
+    if (processHasEntitlement(@"com.apple.UIKit.vends-view-services") && window._isHostedInAnotherProcess)
         return ApplicationType::ViewService;
 
     return ApplicationType::Application;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (186717 => 186718)


--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2015-07-11 22:58:08 UTC (rev 186718)
@@ -29,13 +29,14 @@
 #if PLATFORM(IOS)
 
 #import "APIUIClient.h"
+#import "SandboxUtilities.h"
 #import "TCCSPI.h"
 #import "UIKitSPI.h"
 #import "WKActionSheet.h"
 #import "WKContentViewInteraction.h"
+#import "WKNSURLExtras.h"
 #import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
-#import "WKNSURLExtras.h"
 #import "_WKActivatedElementInfoInternal.h"
 #import "_WKElementActionInternal.h"
 #import <UIKit/UIView.h>
@@ -44,6 +45,10 @@
 #import <WebCore/WebCoreNSURLExtras.h>
 #import <wtf/text/WTFString.h>
 
+#if HAVE(APP_LINKS)
+#import <WebCore/LaunchServicesSPI.h>
+#endif
+
 #if HAVE(SAFARI_SERVICES_FRAMEWORK)
 #import <SafariServices/SSReadingList.h>
 SOFT_LINK_FRAMEWORK(SafariServices)
@@ -56,6 +61,28 @@
 
 using namespace WebKit;
 
+#if HAVE(APP_LINKS)
+static bool applicationHasAppLinkEntitlements()
+{
+    static bool hasEntitlement = processHasEntitlement(@"com.apple.private.canGetAppLinkInfo") && processHasEntitlement(@"com.apple.private.canModifyAppLinkPermissions");
+    return hasEntitlement;
+}
+
+static LSAppLink *appLinkForURL(NSURL *url)
+{
+    __block LSAppLink *syncAppLink = nil;
+
+    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
+    [LSAppLink getAppLinkWithURL:url completionHandler:^(LSAppLink *appLink, NSError *error) {
+        syncAppLink = [appLink retain];
+        dispatch_semaphore_signal(semaphore);
+    }];
+    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
+
+    return [syncAppLink autorelease];
+}
+#endif
+
 @implementation WKActionSheetAssistant {
     WeakObjCPtr<id <WKActionSheetAssistantDelegate>> _delegate;
     RetainPtr<WKActionSheet> _interactionSheet;
@@ -264,6 +291,35 @@
         [self cleanupSheet];
 }
 
+- (void)_appendOpenActionsForURL:(NSURL *)url actions:(NSMutableArray *)defaultActions
+{
+#if HAVE(APP_LINKS)
+    if (applicationHasAppLinkEntitlements()) {
+        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 *) {
+                [appLink openInWebBrowser:YES setAppropriateOpenStrategyAndWebBrowserState:nil completionHandler:^(BOOL success, NSError *error) { }];
+            }];
+            [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 *) {
+                    [appLink openInWebBrowser:NO setAppropriateOpenStrategyAndWebBrowserState:nil completionHandler:^(BOOL success, NSError *error) { }];
+                }];
+                [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]];
+#endif
+}
+
 - (RetainPtr<NSArray>)defaultActionsForLinkSheet
 {
     auto delegate = _delegate.get();
@@ -277,7 +333,8 @@
         return nil;
 
     auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
-    [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]];
+    [self _appendOpenActionsForURL:targetURL actions:defaultActions.get()];
+
 #if HAVE(SAFARI_SERVICES_FRAMEWORK)
     if ([getSSReadingListClass() supportsURL:targetURL])
         [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList assistant:self]];
@@ -299,7 +356,8 @@
 
     auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
     if (!positionInformation.url.isEmpty())
-        [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]];
+        [self _appendOpenActionsForURL:targetURL actions:defaultActions.get()];
+
 #if HAVE(SAFARI_SERVICES_FRAMEWORK)
     if ([getSSReadingListClass() supportsURL:targetURL])
         [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList assistant:self]];

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (186717 => 186718)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-07-11 22:29:55 UTC (rev 186717)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-07-11 22:58:08 UTC (rev 186718)
@@ -1730,7 +1730,7 @@
 		E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19582D4153CC05300B60875 /* PDFKitImports.mm */; };
 		E19BDA86193665E300B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */; };
 		E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E19BDA88193686A400B97F57 /* SandboxUtilities.h */; };
-		E19BDA8B19368D4600B97F57 /* SandboxUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */; };
+		E19BDA8B19368D4600B97F57 /* SandboxUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19BDA87193686A400B97F57 /* SandboxUtilities.mm */; };
 		E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; };
 		E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1A31734134CEA80007C9A4F /* AttributedString.mm */; };
 		E1A9A852169E2025002D7176 /* WebKit.icns in Resources */ = {isa = PBXBuildFile; fileRef = E133FD891423DD7F00FC7BFB /* WebKit.icns */; };
@@ -3966,7 +3966,7 @@
 		E19582D4153CC05300B60875 /* PDFKitImports.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFKitImports.mm; sourceTree = "<group>"; };
 		E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.WebProcess.sb; sourceTree = "<group>"; };
 		E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.appstore.CodeRedeemerNetscapePlugin.sb; sourceTree = "<group>"; };
-		E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SandboxUtilities.cpp; sourceTree = "<group>"; };
+		E19BDA87193686A400B97F57 /* SandboxUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SandboxUtilities.mm; sourceTree = "<group>"; };
 		E19BDA88193686A400B97F57 /* SandboxUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxUtilities.h; sourceTree = "<group>"; };
 		E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = "<group>"; };
 		E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = "<group>"; };
@@ -6481,8 +6481,8 @@
 				1AF1AC691651759E00C17D7F /* RemoteLayerTreeTransaction.mm */,
 				1AAB4AA91296F1540023952F /* SandboxExtensionMac.mm */,
 				E1E552C216AE065E004ED653 /* SandboxInitialiationParametersMac.mm */,
-				E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */,
 				E19BDA88193686A400B97F57 /* SandboxUtilities.h */,
+				E19BDA87193686A400B97F57 /* SandboxUtilities.mm */,
 				51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */,
 				51D130501382EAC000351EDD /* SecItemRequestData.h */,
 				51D130511382EAC000351EDD /* SecItemResponseData.cpp */,
@@ -9624,7 +9624,7 @@
 				BC111B09112F5E3C00337BAB /* ResponsivenessTimer.cpp in Sources */,
 				1AAB4AAA1296F1540023952F /* SandboxExtensionMac.mm in Sources */,
 				E1E552C416AE065F004ED653 /* SandboxInitialiationParametersMac.mm in Sources */,
-				E19BDA8B19368D4600B97F57 /* SandboxUtilities.cpp in Sources */,
+				E19BDA8B19368D4600B97F57 /* SandboxUtilities.mm in Sources */,
 				0F931C1D18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.mm in Sources */,
 				51D130531382EAC000351EDD /* SecItemRequestData.cpp in Sources */,
 				51D130551382EAC000351EDD /* SecItemResponseData.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to