Diff
Modified: trunk/LayoutTests/ChangeLog (235924 => 235925)
--- trunk/LayoutTests/ChangeLog 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/LayoutTests/ChangeLog 2018-09-12 00:57:58 UTC (rev 235925)
@@ -1,3 +1,18 @@
+2018-09-11 Olivia Barnett <[email protected]>
+
+ Implement the Web Share API for mac
+ https://bugs.webkit.org/show_bug.cgi?id=189443
+
+ Reviewed by Tim Horton.
+
+ * platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt: Added.
+ * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt: Added.
+ * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-empty.https-expected.txt: Added.
+ * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-securecontext.http-expected.txt: Added.
+ * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-url-invalid.https-expected.txt: Added.
+ * platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https-expected.txt: Added.
+ Updated test expectations.
+
2018-09-11 Myles C. Maxfield <[email protected]>
Unreviewed test fix after r235910
Modified: trunk/LayoutTests/platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt (235924 => 235925)
--- trunk/LayoutTests/platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/LayoutTests/platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Type error
This tests that the navigator object of a deleted frame is disconnected properly. Accessing fields or methods shouldn't crash the browser.
Check Navigator
navigator.appCodeName is OK
@@ -18,6 +19,7 @@
navigator.productSub is OK
navigator.sendBeacon() threw err TypeError: Not enough arguments
navigator.serviceWorker is OK
+navigator.share() is OK
navigator.userAgent is OK
navigator.vendor is OK
navigator.vendorSub is OK
@@ -40,6 +42,7 @@
navigator.productSub is OK
navigator.sendBeacon() threw err TypeError: Not enough arguments
navigator.serviceWorker is OK
+navigator.share() is OK
navigator.userAgent is OK
navigator.vendor is OK
navigator.vendorSub is OK
Copied: trunk/LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt (from rev 235924, trunk/LayoutTests/platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt) (0 => 235925)
--- trunk/LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,53 @@
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Not enough arguments
+CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Type error
+This tests that the navigator object of a deleted frame is disconnected properly. Accessing fields or methods shouldn't crash the browser.
+ Check Navigator
+navigator.appCodeName is OK
+navigator.appName is OK
+navigator.appVersion is OK
+navigator.cookieEnabled is OK
+navigator.credentials is OK
+navigator.getStorageUpdates() is OK
+navigator.javaEnabled() is OK
+navigator.language is OK
+navigator.languages is OK
+navigator.mediaCapabilities is OK
+navigator.mimeTypes is OK
+navigator.onLine is OK
+navigator.platform is OK
+navigator.plugins is OK
+navigator.product is OK
+navigator.productSub is OK
+navigator.requestMediaKeySystemAccess() is OK
+navigator.sendBeacon() threw err TypeError: Not enough arguments
+navigator.serviceWorker is OK
+navigator.share() is OK
+navigator.userAgent is OK
+navigator.vendor is OK
+navigator.vendorSub is OK
+navigator.webdriver is OK
+navigator.appCodeName is OK
+navigator.appName is OK
+navigator.appVersion is OK
+navigator.cookieEnabled is OK
+navigator.credentials is OK
+navigator.getStorageUpdates() is OK
+navigator.javaEnabled() is OK
+navigator.language is OK
+navigator.languages is OK
+navigator.mediaCapabilities is OK
+navigator.mimeTypes is OK
+navigator.onLine is OK
+navigator.platform is OK
+navigator.plugins is OK
+navigator.product is OK
+navigator.productSub is OK
+navigator.requestMediaKeySystemAccess() is OK
+navigator.sendBeacon() threw err TypeError: Not enough arguments
+navigator.serviceWorker is OK
+navigator.share() is OK
+navigator.userAgent is OK
+navigator.vendor is OK
+navigator.vendorSub is OK
+navigator.webdriver is OK
+
Added: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt (0 => 235925)
--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,7 @@
+
+PASS Test driver
+PASS Navigator interface: operation share(ShareData)
+PASS Unscopable handled correctly for share(ShareData) on Navigator
+PASS Navigator interface: navigator must inherit property "share(ShareData)" with the proper type
+PASS Navigator interface: calling share(ShareData) on navigator with too few arguments must throw TypeError
+
Added: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-empty.https-expected.txt (0 => 235925)
--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-empty.https-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-empty.https-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,7 @@
+
+PASS share with no arguments (same as empty dictionary)
+PASS share with an empty dictionary
+PASS share with a undefined argument (same as empty dictionary)
+PASS share with a null argument (same as empty dictionary)
+PASS share with a dictionary containing only surplus fields
+
Added: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-securecontext.http-expected.txt (0 => 235925)
--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-securecontext.http-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-securecontext.http-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,3 @@
+
+FAIL navigator.share must be undefined in non-secure context assert_false: navigator has attribute 'share'. expected false got true
+
Added: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-url-invalid.https-expected.txt (0 => 235925)
--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-url-invalid.https-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-url-invalid.https-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,3 @@
+
+PASS share with an invalid URL
+
Added: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https-expected.txt (0 => 235925)
--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https-expected.txt 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,3 @@
+
+PASS share without a user gesture
+
Modified: trunk/Source/WebKit/ChangeLog (235924 => 235925)
--- trunk/Source/WebKit/ChangeLog 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/ChangeLog 2018-09-12 00:57:58 UTC (rev 235925)
@@ -1,3 +1,39 @@
+2018-09-11 Olivia Barnett <[email protected]>
+
+ Implement the Web Share API for mac
+ https://bugs.webkit.org/show_bug.cgi?id=189443
+
+ Reviewed by Tim Horton.
+
+ * Shared/WebPreferencesDefaultValues.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView shareSheetDidDismiss:]):
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView shareSheetDidDismiss:]):
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::showShareSheet):
+ (WebKit::WebViewImpl::shareSheetDidDismiss):
+ Implemented function for WKShareSheetDelegate.
+
+ * UIProcess/Cocoa/WKShareSheet.h:
+ * UIProcess/Cocoa/WKShareSheet.mm:
+ (-[WKShareSheet initWithView:initWithView:]):
+ (-[WKShareSheet presentWithParameters:completionHandler:]):
+ (-[WKShareSheet sharingServicePicker:didChooseSharingService:]):
+ (-[WKShareSheet _cancel]):
+ (-[WKShareSheet dismiss]):
+ (-[WKShareSheet _dismissDisplayAnimated:]):
+ (-[WKShareSheet invokeShareSheetWithResolution:]):
+ (-[WKShareSheet initWithView:]): Deleted.
+ Added mac platform checks and share sheet functionality.
+
+ * UIProcess/mac/PageClientImplMac.h:
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::showShareSheet):
+ Allows macos to invoke the system share sheet.
+
2018-09-07 Dean Jackson <[email protected]>
Add and expose Internal features from WebKit
Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h (235924 => 235925)
--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2018-09-12 00:57:58 UTC (rev 235925)
@@ -84,7 +84,6 @@
#define DEFAULT_TEXT_AREAS_ARE_RESIZABLE true
#define DEFAULT_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY true
#define DEFAULT_SHOULD_RESPECT_IMAGE_ORIENTATION false
-#define DEFAULT_WEB_SHARE_ENABLED false
#define DEFAULT_PASSWORD_ECHO_ENABLED false
#define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK true
#define DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK_AFTER_FULLSCREEN false
@@ -173,7 +172,7 @@
#endif
-#if PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
#define DEFAULT_WEB_SHARE_ENABLED true
#else
#define DEFAULT_WEB_SHARE_ENABLED false
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-09-12 00:57:58 UTC (rev 235925)
@@ -5680,6 +5680,11 @@
_impl->setWindowOcclusionDetectionEnabled(enabled);
}
+- (void)shareSheetDidDismiss:(WKShareSheet *)shareSheet
+{
+ _impl->shareSheetDidDismiss(shareSheet);
+}
+
- (void)_setOverrideDeviceScaleFactor:(CGFloat)deviceScaleFactor
{
_impl->setOverrideDeviceScaleFactor(deviceScaleFactor);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2018-09-12 00:57:58 UTC (rev 235925)
@@ -28,6 +28,7 @@
#if WK_API_ENABLED
#import "SameDocumentNavigationType.h"
+#import "WKShareSheet.h"
#import "WKWebViewConfiguration.h"
#import "_WKAttachmentInternal.h"
#import "_WKWebViewPrintFormatterInternal.h"
@@ -47,6 +48,10 @@
#define WK_WEB_VIEW_PROTOCOLS <UIScrollViewDelegate>
#endif
+#if PLATFORM(MAC)
+#define WK_WEB_VIEW_PROTOCOLS <WKShareSheetDelegate>
+#endif
+
#if !defined(WK_WEB_VIEW_PROTOCOLS)
#define WK_WEB_VIEW_PROTOCOLS
#endif
Copied: trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h (from rev 235924, trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.h) (0 => 235925)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.h 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2018 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 "WKAPICast.h"
+
+#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && WK_API_ENABLED
+
+#import <WebCore/ShareData.h>
+#import <wtf/BlockPtr.h>
+#import <wtf/Forward.h>
+#import <wtf/Vector.h>
+#import <wtf/WeakObjCPtr.h>
+#import <wtf/text/WTFString.h>
+
+#if PLATFORM(IOS)
+#import <UIKit/UIKit.h>
+#else
+#import "WKWebView.h"
+#endif
+
+@class WKContentView;
+@protocol WKShareSheetDelegate;
+
+#if PLATFORM(MAC)
+@interface WKShareSheet : NSObject <NSSharingServicePickerDelegate>
+- (instancetype)initWithView:(WKWebView *)view;
+#else
+@interface WKShareSheet : NSObject
+- (instancetype)initWithView:(WKContentView *)view;
+#endif
+
+- (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL&)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler;
+- (void)dismiss;
+- (void)invokeShareSheetWithResolution:(BOOL)resolved;
+
+@property (nonatomic, weak) id <WKShareSheetDelegate> delegate;
+@end
+
+@protocol WKShareSheetDelegate <NSObject>
+@optional
+- (void)shareSheetDidDismiss:(WKShareSheet *)shareSheet;
+@end
+
+#endif // !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
Copied: trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm (from rev 235924, trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm) (0 => 235925)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKShareSheet.mm 2018-09-12 00:57:58 UTC (rev 235925)
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2018 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 "WKShareSheet.h"
+
+#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && WK_API_ENABLED
+
+#import "WKContentViewInteraction.h"
+#import "WebPageProxy.h"
+#import <WebCore/ShareData.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
+
+#if PLATFORM(IOS)
+#import "UIKitSPI.h"
+#else
+#import "WKWebView.h"
+#endif
+
+using namespace WebKit;
+
+@implementation WKShareSheet {
+#if PLATFORM(MAC)
+ WeakObjCPtr<WKWebView> _view;
+
+ BOOL _isShowingSharingServicePicker;
+ RetainPtr<NSSharingServicePicker> _sharingServicePickerForMenu;
+ WTF::CompletionHandler<void(bool)> _completionHandler;
+#else
+ WeakObjCPtr<WKContentView> _view;
+
+ RetainPtr<UIActivityViewController> _shareSheetViewController;
+ RetainPtr<UIViewController> _presentationViewController;
+ BOOL _shouldDismissWithAnimation;
+#endif
+}
+
+#if PLATFORM(MAC)
+- (instancetype)initWithView:(WKWebView *)view
+#else
+- (instancetype)initWithView:(WKContentView *)view
+#endif
+{
+ if (!(self = [super init]))
+ return nil;
+ _view = view;
+#if PLATFORM(IOS)
+ _shouldDismissWithAnimation = YES;
+#endif
+ return self;
+}
+
+- (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL &)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler
+{
+ auto shareDataArray = adoptNS([[NSMutableArray alloc] init]);
+
+ if (!data.shareData.text.isEmpty())
+ [shareDataArray addObject:(NSString *)data.shareData.text];
+
+ if (!data.url.isNull()) {
+ NSURL *url = "" *)data.url;
+#if PLATFORM(IOS)
+ if (!data.shareData.title.isEmpty())
+ url._title = data.shareData.title;
+#endif
+ [shareDataArray addObject:url];
+ }
+
+ if (!data.shareData.title.isEmpty() && ![shareDataArray count])
+ [shareDataArray addObject:(NSString *)data.shareData.title];
+
+#if PLATFORM(MAC)
+ _sharingServicePickerForMenu = adoptNS([[NSSharingServicePicker alloc] initWithItems:shareDataArray.get()]);
+ _sharingServicePickerForMenu.get().delegate = self;
+ _completionHandler = WTFMove(completionHandler);
+
+ NSPoint location = [NSEvent mouseLocation];
+ NSRect mouseLocationRect = NSMakeRect(location.x, location.y, 1.0, 1.0);
+ NSRect mouseLocationInWindow = [[_view window] convertRectFromScreen:mouseLocationRect];
+ NSRect mouseLocationInView = [_view convertRect:mouseLocationInWindow fromView:nil];
+ [_sharingServicePickerForMenu showRelativeToRect:mouseLocationInView ofView:_view.getAutoreleased() preferredEdge:NSMinYEdge];
+#else
+ auto shareSheetController = adoptNS([[UIActivityViewController alloc] initWithActivityItems:shareDataArray.get() applicationActivities:nil]);
+
+ auto completionHandlerBlock = BlockPtr<void((NSString *, BOOL completed, NSArray *, NSError *))>::fromCallable([completionHandler = WTFMove(completionHandler), shareSheet = self](NSString *, BOOL completed, NSArray *, NSError *) mutable {
+ completionHandler(completed);
+ [shareSheet dismiss];
+ });
+
+ shareSheetController.get().completionWithItemsHandler = completionHandlerBlock.get();
+ _shareSheetViewController = WTFMove(shareSheetController);
+ [self _presentFullscreenViewController:_shareSheetViewController.get() animated:YES];
+#endif
+}
+
+#if PLATFORM(MAC)
+- (void)sharingServicePicker:(NSSharingServicePicker *)sharingServicePicker didChooseSharingService:(nullable NSSharingService *)service
+{
+ self->_completionHandler(!service);
+ [self _dispatchDidDismiss];
+}
+
+#endif
+- (void)_dispatchDidDismiss
+{
+ if ([_delegate respondsToSelector:@selector(shareSheetDidDismiss:)])
+ [_delegate shareSheetDidDismiss:self];
+}
+
+- (void)_cancel
+{
+#if PLATFORM(IOS)
+ [self _dispatchDidDismiss];
+#endif
+}
+
+- (void)dismiss
+{
+#if PLATFORM(IOS)
+ [[UIViewController _viewControllerForFullScreenPresentationFromView:_view.getAutoreleased()] dismissViewControllerAnimated:_shouldDismissWithAnimation completion:nil];
+ _presentationViewController = nil;
+
+ [self _cancel];
+#endif
+}
+
+#if PLATFORM(IOS)
+
+- (void)_dismissDisplayAnimated:(BOOL)animated
+{
+ if (_presentationViewController) {
+ UIViewController *currentPresentedViewController = [_presentationViewController presentedViewController];
+ if (currentPresentedViewController == _shareSheetViewController) {
+ [currentPresentedViewController dismissViewControllerAnimated:animated completion:^{
+ _presentationViewController = nil;
+ }];
+ }
+ }
+}
+
+- (void)_presentFullscreenViewController:(UIViewController *)viewController animated:(BOOL)animated
+{
+ _presentationViewController = [UIViewController _viewControllerForFullScreenPresentationFromView:_view.getAutoreleased()];
+ [_presentationViewController presentViewController:viewController animated:animated completion:nil];
+}
+#endif
+
+- (void)invokeShareSheetWithResolution:(BOOL)resolved
+{
+#if PLATFORM(IOS)
+ _shouldDismissWithAnimation = NO;
+ _shareSheetViewController.get().completionWithItemsHandler(nil, resolved, nil, nil);
+#else
+ _completionHandler(resolved);
+#endif
+}
+
+@end
+#endif // !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2018-09-12 00:57:58 UTC (rev 235925)
@@ -59,6 +59,10 @@
OBJC_CLASS _WKRemoteObjectRegistry;
OBJC_CLASS _WKThumbnailView;
+#if WK_API_ENABLED
+OBJC_CLASS WKShareSheet;
+#endif
+
#if HAVE(TOUCH_BAR)
OBJC_CLASS NSCandidateListTouchBarItem;
OBJC_CLASS NSCustomTouchBarItem;
@@ -75,6 +79,10 @@
class PageConfiguration;
}
+namespace WebCore {
+struct ShareDataWithParsedURL;
+}
+
@protocol WebViewImplDelegate
- (NSTextInputContext *)_web_superInputContext;
@@ -313,6 +321,7 @@
id validRequestorForSendAndReturnTypes(NSString *sendType, NSString *returnType);
void centerSelectionInVisibleArea();
void selectionDidChange();
+
void didBecomeEditable();
void updateFontPanelIfNeeded();
void changeFontFromFontManager();
@@ -412,6 +421,9 @@
void setInspectorAttachmentView(NSView *);
NSView *inspectorAttachmentView();
+
+ void showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&, WKWebView *);
+ void shareSheetDidDismiss(WKShareSheet *);
_WKRemoteObjectRegistry *remoteObjectRegistry();
@@ -687,6 +699,10 @@
#if ENABLE(FULLSCREEN_API)
RetainPtr<WKFullScreenWindowController> m_fullScreenWindowController;
#endif
+
+#if WK_API_ENABLED
+ RetainPtr<WKShareSheet> _shareSheet;
+#endif
RetainPtr<WKWindowVisibilityObserver> m_windowVisibilityObserver;
RetainPtr<WKAccessibilitySettingsObserver> m_accessibilitySettingsObserver;
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2018-09-12 00:57:58 UTC (rev 235925)
@@ -2726,6 +2726,29 @@
[m_view _web_editorStateDidChange];
}
+#if WK_API_ENABLED
+void WebViewImpl::showShareSheet(const WebCore::ShareDataWithParsedURL& data, WTF::CompletionHandler<void(bool)>&& completionHandler, WKWebView *view)
+{
+ ASSERT(!_shareSheet);
+ if (_shareSheet)
+ return;
+
+ ASSERT([view respondsToSelector:@selector(shareSheetDidDismiss:)]);
+ _shareSheet = adoptNS([[WKShareSheet alloc] initWithView:view]);
+ [_shareSheet setDelegate:view];
+
+ [_shareSheet presentWithParameters:data completionHandler:WTFMove(completionHandler)];
+}
+
+void WebViewImpl::shareSheetDidDismiss(WKShareSheet *shareSheet)
+{
+ ASSERT(_shareSheet == shareSheet);
+
+ [_shareSheet setDelegate:nil];
+ _shareSheet = nil;
+}
+#endif
+
void WebViewImpl::didBecomeEditable()
{
[m_windowVisibilityObserver startObservingFontPanel];
Deleted: trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.h (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.h 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.h 2018-09-12 00:57:58 UTC (rev 235925)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#if PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
-
-#import <UIKit/UIKit.h>
-#import <WebCore/ShareData.h>
-#import <wtf/BlockPtr.h>
-#import <wtf/Forward.h>
-#import <wtf/Vector.h>
-#import <wtf/WeakObjCPtr.h>
-#import <wtf/text/WTFString.h>
-
-@class WKContentView;
-@protocol WKShareSheetDelegate;
-
-@interface WKShareSheet : UIViewController
-- (instancetype)initWithView:(WKContentView *)view;
-
-- (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL&)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler;
-- (void)dismiss;
-- (void)invokeShareSheetWithResolution:(BOOL)resolved;
-
-@property (nonatomic, weak) id <WKShareSheetDelegate> delegate;
-@end
-
-@protocol WKShareSheetDelegate <NSObject>
-@optional
-- (void)shareSheetDidDismiss:(WKShareSheet *)shareSheet;
-@end
-
-#endif // PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
Deleted: trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm 2018-09-12 00:57:58 UTC (rev 235925)
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2018 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 "WKShareSheet.h"
-
-#if PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
-#import "UIKitSPI.h"
-#import "WKContentViewInteraction.h"
-#import "WebPageProxy.h"
-#import <WebCore/ShareData.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/WeakObjCPtr.h>
-
-using namespace WebKit;
-
-@implementation WKShareSheet {
- WeakObjCPtr<WKContentView> _view;
-
- RetainPtr<UIActivityViewController> _shareSheetViewController;
- RetainPtr<UIViewController> _presentationViewController;
- BOOL _shouldDismissWithAnimation;
-}
-
-- (instancetype)initWithView:(WKContentView *)view
-{
- if (!(self = [super init]))
- return nil;
- _view = view;
- _shouldDismissWithAnimation = YES;
- return self;
-}
-
-- (void)presentWithParameters:(const WebCore::ShareDataWithParsedURL &)data completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler
-{
- auto shareDataArray = adoptNS([[NSMutableArray alloc] init]);
-
- if (!data.shareData.text.isEmpty())
- [shareDataArray addObject:(NSString *)data.shareData.text];
-
- if (!data.url.isNull()) {
- NSURL *url = "" *)data.url;
- if (!data.shareData.title.isEmpty())
- url._title = data.shareData.title;
- [shareDataArray addObject:url];
- }
-
- if (!data.shareData.title.isEmpty() && ![shareDataArray count])
- [shareDataArray addObject:(NSString *)data.shareData.title];
-
- auto shareSheetController = adoptNS([[UIActivityViewController alloc] initWithActivityItems:shareDataArray.get() applicationActivities:nil]);
-
- auto completionHandlerBlock = BlockPtr<void((NSString *, BOOL completed, NSArray *, NSError *))>::fromCallable([completionHandler = WTFMove(completionHandler), shareSheet = self](NSString *, BOOL completed, NSArray *, NSError *) mutable {
- completionHandler(completed);
- [shareSheet dismiss];
- });
-
- shareSheetController.get().completionWithItemsHandler = completionHandlerBlock.get();
- _shareSheetViewController = WTFMove(shareSheetController);
- [self _presentFullscreenViewController:_shareSheetViewController.get() animated:YES];
-}
-
-- (void)_dispatchDidDismiss
-{
- if ([_delegate respondsToSelector:@selector(shareSheetDidDismiss:)])
- [_delegate shareSheetDidDismiss:self];
-}
-
-- (void)_cancel
-{
- [self _dispatchDidDismiss];
-}
-
-- (void)dismiss
-{
- [[UIViewController _viewControllerForFullScreenPresentationFromView:_view.getAutoreleased()] dismissViewControllerAnimated:_shouldDismissWithAnimation completion:nil];
- _presentationViewController = nil;
-
- [self _cancel];
-}
-
-- (void)_dismissDisplayAnimated:(BOOL)animated
-{
- if (_presentationViewController) {
- UIViewController *currentPresentedViewController = [_presentationViewController presentedViewController];
- if (currentPresentedViewController == self) {
- [currentPresentedViewController dismissViewControllerAnimated:animated completion:^{
- _presentationViewController = nil;
- }];
- }
- }
-}
-
-- (void)_presentFullscreenViewController:(UIViewController *)viewController animated:(BOOL)animated
-{
- _presentationViewController = [UIViewController _viewControllerForFullScreenPresentationFromView:_view.getAutoreleased()];
- [_presentationViewController presentViewController:viewController animated:animated completion:nil];
-}
-
-- (void)invokeShareSheetWithResolution:(BOOL)resolved
-{
- _shouldDismissWithAnimation = NO;
- _shareSheetViewController.get().completionWithItemsHandler(nil, resolved, nil, nil);
-}
-
-@end
-#endif // PLATFORM(IOS) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2018-09-12 00:57:58 UTC (rev 235925)
@@ -103,7 +103,11 @@
void resetSecureInputState() override;
void notifyInputContextAboutDiscardedComposition() override;
void selectionDidChange() override;
-
+
+#if WK_API_ENABLED
+ bool showShareSheet(const WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) override;
+#endif
+
WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (235924 => 235925)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2018-09-12 00:57:58 UTC (rev 235925)
@@ -540,6 +540,13 @@
{
m_impl->selectionDidChange();
}
+#if WK_API_ENABLED
+bool PageClientImpl::showShareSheet(const ShareDataWithParsedURL& shareData, WTF::CompletionHandler<void(bool)>&& completionHandler)
+{
+ m_impl->showShareSheet(shareData, WTFMove(completionHandler), m_webView);
+ return true;
+}
+#endif
void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
{
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (235924 => 235925)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2018-09-12 00:51:23 UTC (rev 235924)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2018-09-12 00:57:58 UTC (rev 235925)
@@ -2420,8 +2420,8 @@
1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorUIMessages.h; sourceTree = "<group>"; };
1CC417C912C00CCA002BE67B /* TextCheckerCompletion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCheckerCompletion.h; sourceTree = "<group>"; };
1D67B338212E1F6100FAA786 /* ShareSheetCallbackID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareSheetCallbackID.h; sourceTree = "<group>"; };
- 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKShareSheet.mm; path = ios/forms/WKShareSheet.mm; sourceTree = "<group>"; };
- 1DE0D095211CC21300439B5F /* WKShareSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKShareSheet.h; path = ios/forms/WKShareSheet.h; sourceTree = "<group>"; };
+ 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKShareSheet.mm; sourceTree = "<group>"; };
+ 1DE0D095211CC21300439B5F /* WKShareSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKShareSheet.h; sourceTree = "<group>"; };
1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFrame.h; sourceTree = "<group>"; };
1F01816A1858DC1500F92884 /* WKWebProcessPlugInFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInFrame.mm; sourceTree = "<group>"; };
1F01816B1858DC1500F92884 /* WKWebProcessPlugInFrameInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFrameInternal.h; sourceTree = "<group>"; };
@@ -5294,6 +5294,8 @@
2DFC7DBA1BCCC19500C1548C /* WebViewImpl.mm */,
1AD01BCB1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.h */,
1AD01BCA1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.mm */,
+ 1DE0D095211CC21300439B5F /* WKShareSheet.h */,
+ 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */,
2D7AAFD218C8640600A7ACD4 /* WKWebViewContentProvider.h */,
2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */,
2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */,
@@ -8507,8 +8509,6 @@
F4D5F51C206087A10038BBA8 /* WKQuickboardListViewController.mm */,
F4F59AD42065A5CA006CAA46 /* WKSelectMenuListViewController.h */,
F4F59AD32065A5C9006CAA46 /* WKSelectMenuListViewController.mm */,
- 1DE0D095211CC21300439B5F /* WKShareSheet.h */,
- 1DBBB061211CC3CB00502ECC /* WKShareSheet.mm */,
F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */,
F4D5F51A206087A10038BBA8 /* WKTextInputListViewController.mm */,
2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */,