Implement the Web Share API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 00:20:26 +0000 (00:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 00:20:26 +0000 (00:20 +0000)
commita3e7cbf5314579ec265d3ff3e62a200bbe423efa
tree05c4243ed0e5843e139309ad9791f311af468f9a
parent61eff9b7fa2b0f74ab0abee865f52b569a840f53
Implement the Web Share API
https://bugs.webkit.org/show_bug.cgi?id=171100
<rdar://problem/31751734>

Patch by Olivia Barnett <obarnett@apple.com> on 2018-08-29
Reviewed by Tim Horton.

LayoutTests/imported/w3c:

* web-platform-tests/web-share/idlharness.https-expected.txt:
* web-platform-tests/web-share/share-empty.https-expected.txt:
* web-platform-tests/web-share/share-securecontext.http-expected.txt:
* web-platform-tests/web-share/share-url-invalid.https-expected.txt:
* web-platform-tests/web-share/share-without-user-gesture.https-expected.txt:
Updated expected results.

Source/WebCore:

Added one test in fast/events/ios called share.html; adjusted expectations for existing tests.

* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* features.json:
* loader/EmptyClients.cpp:
(WebCore::EmptyChromeClient::showShareSheet):
* loader/EmptyClients.h:
Added empty showShareSheet function.

* page/Chrome.cpp:
(WebCore::Chrome::showShareSheet):
* page/Chrome.h:
Added call to showShareSheet on client.

* page/ChromeClient.h:
Virtual showShareSheet function.

* page/Navigator.cpp:
(WebCore::Navigator::share):
* page/Navigator.h:
Share function that returns a promise and invokes the share sheet.

* page/Navigator.idl:
Implements NavigatorShare

* page/NavigatorShare.idl: Added.
Added definition of share function returning a promise.

* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setWebShareEnabled):
(WebCore::RuntimeEnabledFeatures::webShareEnabled const):
Added RuntimeEnabledFeature switch.

* page/ShareData.h: Added.
* page/ShareData.idl: Added.
Definition of ShareData struct.

Source/WebKit:

* Platform/spi/ios/UIKitSPI.h:
Added NSURL _title property as in the WebCore UIKitSPI.

* Scripts/webkit/messages.py:
ShareDataWithParsedURL special case for header for type.

* Shared/ShareSheetCallbackID.h:
Added a typedef for a share sheet callback id.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ShareData>::encode):
(IPC::ArgumentCoder<ShareData>::decode):
(IPC::ArgumentCoder<ShareDataWithParsedURL>::encode):
(IPC::ArgumentCoder<ShareDataWithParsedURL>::decode):
* Shared/WebCoreArgumentCoders.h:
Added encoding and decoding functionality for new structs.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetWebShareEnabled):
(WKPreferencesGetWebShareEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
Added switch for RuntimeEnabledFeature.

* UIProcess/API/Cocoa/WKWebView.mm:
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
Added hook for share sheet testing.

* UIProcess/PageClient.h:
(WebKit::PageClient::showShareSheet):
Page client call to invoke share sheet.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::showShareSheet):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
Web page proxy handling of call to invoke share sheet.
Creates completion handler to send to WKShareSheet.mm
Completion handler sends message to WebPage with message id.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::showShareSheet):
Page client implementation call to invoke share sheet.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanupInteraction]):
(-[WKContentView _showShareSheet:completionHandler:]):
(-[WKContentView shareSheetDidDismiss:]):
(-[WKContentView invokeShareSheetWithResolution:resolved):
Call to WKShareSheet to invoke the share sheet and callback.
Hook for share sheet resolution testing.

* UIProcess/ios/forms/WKShareSheet.h: Added.
* UIProcess/ios/forms/WKShareSheet.mm: Added.
(-[WKShareSheet initWithView:]):
(-[WKShareSheet presentWithParameters:completionHandler:]):
(-[WKShareSheet _dispatchDidDismiss]):
(-[WKShareSheet _cancel]):
(-[WKShareSheet dismiss]):
(-[WKShareSheet _dismissDisplayAnimated:]):
(-[WKShareSheet _presentFullscreenViewController:animated:]):
(-[WKShareSheet invokeShareSheetWithResolution:resolved:]):
Completion handler call and creation of share sheet with parameters.
Hook that force resolves the share sheet completion handler for testing.

* WebKit.xcodeproj/project.pbxproj:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::showShareSheet):
Call to page to invoke share sheet.

* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::nextShareSheetContextId):
(WebKit::WebPage::showShareSheet):
(WebKit::WebPage::showShareSheetResponse):
WebPage calls proxy and saves context id for promise.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
Callback for completed response.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.h:
* WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::showShareSheet):
Empty declaration of showShareSheet.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::showShareSheet):
Empty declaration of showShareSheet.

LayoutTests:

* fast/dom/navigator-detached-no-crash-expected.txt:
Updated expected results.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235489 268f45cc-cd09-0410-ab3c-d52691b4dbfc
68 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/fast/events/ios/share-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/share.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/web-share/idlharness.https-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/web-share/share-empty.https-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/web-share/share-securecontext.http-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/web-share/share-url-invalid.https-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/web-share/share-without-user-gesture.https-expected.txt [new file with mode: 0644]
LayoutTests/resources/ui-helper.js
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/features.json
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/Chrome.cpp
Source/WebCore/page/Chrome.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/Navigator.cpp
Source/WebCore/page/Navigator.h
Source/WebCore/page/Navigator.idl
Source/WebCore/page/NavigatorShare.idl [new file with mode: 0644]
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebCore/page/ShareData.h [new file with mode: 0644]
Source/WebCore/page/ShareData.idl [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/ShareSheetCallbackID.h [new file with mode: 0644]
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/Shared/WebPreferencesDefaultValues.h
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/ios/PageClientImplIOS.h
Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKShareSheet.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/forms/WKShareSheet.mm [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.h
Source/WebKitLegacy/ios/WebCoreSupport/WebChromeClientIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm
Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm