Diff
Modified: trunk/LayoutTests/ChangeLog (285443 => 285444)
--- trunk/LayoutTests/ChangeLog 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/LayoutTests/ChangeLog 2021-11-09 00:34:24 UTC (rev 285444)
@@ -1,3 +1,16 @@
+2021-11-08 Devin Rousso <[email protected]>
+
+ [Payment Request] Add a new payment method for showing AMS UI
+ https://bugs.webkit.org/show_bug.cgi?id=232634
+ <rdar://problem/79024227>
+
+ Reviewed by Tim Horton.
+
+ * http/tests/ssl/applepay-ams-ui/PaymentRequest.https.html: Added.
+ * http/tests/ssl/applepay-ams-ui/PaymentRequest.https-expected.txt: Added.
+
+ * TestExpectations:
+
2021-11-08 Alex Christensen <[email protected]>
Remove unused file
Modified: trunk/LayoutTests/TestExpectations (285443 => 285444)
--- trunk/LayoutTests/TestExpectations 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/LayoutTests/TestExpectations 2021-11-09 00:34:24 UTC (rev 285444)
@@ -263,6 +263,7 @@
fast/css/webkit-named-image/apple-pay-logo-black [ Skip ]
fast/css/webkit-named-image/apple-pay-logo-white [ Skip ]
http/tests/ssl/applepay/ [ Skip ]
+http/tests/ssl/applepay-ams-ui/ [ Skip ]
# Only WK2 allows unconstrained scrolling
fast/visual-viewport/rubberbanding-viewport-rects.html [ Skip ]
Added: trunk/LayoutTests/http/tests/ssl/applepay-ams-ui/PaymentRequest.https-expected.txt (0 => 285444)
--- trunk/LayoutTests/http/tests/ssl/applepay-ams-ui/PaymentRequest.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay-ams-ui/PaymentRequest.https-expected.txt 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,41 @@
+Test basic creation of a PaymentRequest object with an Apple Pay AMS UI payment method.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing PaymentRequest
+
+PASS new PaymentRequest(null, null) threw exception TypeError: Value is not a sequence.
+PASS new PaymentRequest([validPaymentMethod()], validPaymentDetails()) did not throw exception.
+
+Testing ApplePayAMSUIRequest.engagementRequest
+
+SETUP: paymentMethod = validPaymentMethod(); delete paymentMethod.data.engagementRequest
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = ''
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = 'invalid'
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = null
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = 7
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = [ ]
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = false
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) threw exception TypeError: Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = { }
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()) did not throw exception.
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/ssl/applepay-ams-ui/PaymentRequest.https.html (0 => 285444)
--- trunk/LayoutTests/http/tests/ssl/applepay-ams-ui/PaymentRequest.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay-ams-ui/PaymentRequest.https.html 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test basic creation of a PaymentRequest object with an Apple Pay AMS UI payment method.");
+
+window.jsTestIsAsync = true;
+
+function validPaymentMethod() {
+ return {
+ supportedMethods: 'https://apple.com/ams-ui',
+ data: {
+ engagementRequest: { value: 42 },
+ },
+ }
+}
+
+function validPaymentDetails() {
+ return {
+ total: { label: 'Your label', amount: { currency: 'USD', value: '10.00' } },
+ }
+}
+
+function logAndShouldThrow(setup, test) {
+ return activateThen(() => {
+ debug("SETUP: " + setup);
+ eval(setup);
+ shouldThrow(test);
+ debug("");
+ });
+}
+
+function logAndShouldNotThrow(setup, test) {
+ return activateThen(() => {
+ debug("SETUP: " + setup);
+ eval(setup);
+ shouldNotThrow(test);
+ debug("");
+ });
+}
+
+async function go() {
+ debug("Testing PaymentRequest")
+ debug("")
+ shouldThrow("new PaymentRequest(null, null)")
+ shouldNotThrow("new PaymentRequest([validPaymentMethod()], validPaymentDetails())")
+ debug("")
+
+ debug("Testing ApplePayAMSUIRequest.engagementRequest")
+ debug("")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); delete paymentMethod.data.engagementRequest", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = ''", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = 'invalid'", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = null", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = 7", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = [ ]", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = false", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ await logAndShouldNotThrow("paymentMethod = validPaymentMethod(); paymentMethod.data.engagementRequest = { }", "new PaymentRequest([paymentMethod], validPaymentDetails())")
+ debug("")
+
+ document.querySelector("button").remove();
+
+ finishJSTest();
+}
+
+function clickElement(element) {
+ let x = element.offsetLeft + 2;
+ let y = element.offsetTop + 2;
+
+ var supportsTouchEvents = "TouchEvent" in window;
+ if (supportsTouchEvents && window.testRunner && testRunner.runUIScript) {
+ testRunner.runUIScript(`(function() { uiController.singleTapAtPoint(${x}, ${y}, function() { }); })();`, function () { });
+ } else if (window.eventSender) {
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+
+window._onload_ = function() {
+ clickElement(document.querySelector("button"));
+}
+
+</script>
+<button _onclick_='go()'>Go</button>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (285443 => 285444)
--- trunk/Source/WebCore/ChangeLog 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/ChangeLog 2021-11-09 00:34:24 UTC (rev 285444)
@@ -1,3 +1,96 @@
+2021-11-08 Devin Rousso <[email protected]>
+
+ [Payment Request] Add a new payment method for showing AMS UI
+ https://bugs.webkit.org/show_bug.cgi?id=232634
+ <rdar://problem/79024227>
+
+ Reviewed by Tim Horton.
+
+ Leverage the W3C Payment Request API as a way for Apple domains to show alternate native
+ payment UIs without having to add new proprietary APIs (e.g. Apple Pay JS). This new payment
+ method is quite bare-bones in that it just takes some JSON and passes it to AMS, which then
+ decides what UI to show based on that. No data is exposed back to the page other than either
+ an error or a yes/no as to whether the payment was successful.
+
+ Test: http/tests/ssl/applepay-ams-ui/PaymentRequest.https.html
+
+ * Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm:
+ (WebCore::PaymentAPIVersion::current):
+ Bump the current Apple Pay version.
+
+ * Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.h: Added.
+ * Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp: Added.
+ (WebCore::convertAndValidateApplePayAMSUIRequest):
+ (WebCore::ApplePayAMSUIPaymentHandler::validateData):
+ (WebCore::ApplePayAMSUIPaymentHandler::handlesIdentifier):
+ (WebCore::ApplePayAMSUIPaymentHandler::hasActiveSession):
+ (WebCore::ApplePayAMSUIPaymentHandler::finishSession):
+ (WebCore::ApplePayAMSUIPaymentHandler::ApplePayAMSUIPaymentHandler):
+ (WebCore::ApplePayAMSUIPaymentHandler::document const):
+ (WebCore::ApplePayAMSUIPaymentHandler::page const):
+ (WebCore::ApplePayAMSUIPaymentHandler::convertData):
+ (WebCore::ApplePayAMSUIPaymentHandler::show):
+ (WebCore::ApplePayAMSUIPaymentHandler::hide):
+ (WebCore::ApplePayAMSUIPaymentHandler::canMakePayment):
+ (WebCore::ApplePayAMSUIPaymentHandler::detailsUpdated):
+ (WebCore::ApplePayAMSUIPaymentHandler::merchantValidationCompleted):
+ (WebCore::ApplePayAMSUIPaymentHandler::complete):
+ (WebCore::ApplePayAMSUIPaymentHandler::retry):
+ Add a new payment method that uses AMS to present UI.
+
+ * Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl: Added.
+ * Modules/applepay-ams-ui/ApplePayAMSUIRequest.h: Added.
+ (WebCore::ApplePayAMSUIRequest::encode const):
+ (WebCore::ApplePayAMSUIRequest::decode):
+ IDL `dictionary` that takes the place of the `object data` in `PaymentMethodData` when the
+ Apple Pay AMS UI payment method is used.
+
+ * Modules/paymentrequest/PaymentHandler.h:
+ * Modules/paymentrequest/PaymentHandler.cpp:
+ (WebCore::PaymentHandler::create):
+ (WebCore::PaymentHandler::validateData):
+ (WebCore::PaymentHandler::hasActiveSession):
+ Minor refactoring to allow for there to be more than one payment method implemeted at once.
+
+ * Modules/paymentrequest/PaymentRequest.h:
+ * Modules/paymentrequest/PaymentRequest.cpp:
+ (WebCore::PaymentRequest::abort):
+ (WebCore::PaymentRequest::accept):
+ (WebCore::PaymentRequest::reject):
+ The W3C Payment Request API doesn't require that payment methods be abortable. As such, add
+ some logic that checks with the active `PaymentHandler` to see if it can be aborted before
+ actually doing so. Also create some public helper methods that allow the payment request to
+ be accepted without providing shipping information and be directly rejected with an error.
+
+ * page/Page.h:
+ (WebCore::Page::hasActiveApplePayAMSUISession const): Added.
+ * page/Page.cpp:
+ (WebCore::Page::startApplePayAMSUISession): Added.
+ (WebCore::Page::abortApplePayAMSUISession): Added.
+ * page/ChromeClient.h:
+ (WebCore::ChromeClient::startApplePayAMSUISession): Added.
+ (WebCore::ChromeClient::abortApplePayAMSUISession): Added.
+ Add plumbing between WebCore/WebProcess and UIProcess. Also maintain state about if there's
+ already an active Apple Pay AMS UI payment session (needed by the W3C Payment Request API).
+
+ * platform/cocoa/PlatformViewController.h: Added.
+ Create a helper `PlatformViewController` that will do the right thing on both macOS and iOS.
+
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+ (WebCore::convertAndValidateApplePayRequest): Added.
+ (WebCore::ApplePayPaymentHandler::validateData):
+ (WebCore::ApplePayPaymentHandler::convertData):
+ Drive-by: Rename the `convertAndValidate` that takes `JSC::JSValue` to `convertAndValidateApplePayRequest`
+ so that there isn't a naming conflict in other files that may want to do a similar thing.
+
+ * DerivedSources-input.xcfilelist:
+ * DerivedSources-output.xcfilelist:
+ * DerivedSources.make:
+ * PlatformMac.cmake:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
2021-11-08 Alex Christensen <[email protected]>
Parse redirect and modify-headers actions for WKContentRuleList
Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (285443 => 285444)
--- trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-11-09 00:34:24 UTC (rev 285444)
@@ -205,6 +205,7 @@
$(PROJECT_DIR)/Modules/applepay/ApplePayValidateMerchantEvent.idl
$(PROJECT_DIR)/Modules/applepay/paymentrequest/ApplePayModifier.idl
$(PROJECT_DIR)/Modules/applepay/paymentrequest/ApplePayRequest.idl
+$(PROJECT_DIR)/Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl
$(PROJECT_DIR)/Modules/async-clipboard/Clipboard.idl
$(PROJECT_DIR)/Modules/async-clipboard/ClipboardItem.idl
$(PROJECT_DIR)/Modules/async-clipboard/Navigator+Clipboard.idl
Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (285443 => 285444)
--- trunk/Source/WebCore/DerivedSources-output.xcfilelist 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist 2021-11-09 00:34:24 UTC (rev 285444)
@@ -76,6 +76,8 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnimationPlaybackEventInit.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnimationTimeline.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnimationTimeline.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePayAMSUIRequest.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePayAMSUIRequest.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePayCancelEvent.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePayCancelEvent.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSApplePayContactField.cpp
Modified: trunk/Source/WebCore/DerivedSources.make (285443 => 285444)
--- trunk/Source/WebCore/DerivedSources.make 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/DerivedSources.make 2021-11-09 00:34:24 UTC (rev 285444)
@@ -236,6 +236,7 @@
$(WebCore)/Modules/applepay/ApplePayValidateMerchantEvent.idl \
$(WebCore)/Modules/applepay/paymentrequest/ApplePayModifier.idl \
$(WebCore)/Modules/applepay/paymentrequest/ApplePayRequest.idl \
+ $(WebCore)/Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl \
$(WebCore)/Modules/async-clipboard/Clipboard.idl \
$(WebCore)/Modules/async-clipboard/ClipboardItem.idl \
$(WebCore)/Modules/async-clipboard/Navigator+Clipboard.idl \
Modified: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm (285443 => 285444)
--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm 2021-11-09 00:34:24 UTC (rev 285444)
@@ -35,7 +35,9 @@
unsigned PaymentAPIVersion::current()
{
static unsigned current = [] {
-#if ENABLE(APPLE_PAY_COUPON_CODE) || ENABLE(APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE) || ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM) || ENABLE(APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
+#if ENABLE(APPLE_PAY_PAYMENT_DETAILS_DATA) || ENABLE(APPLE_PAY_AMS_UI)
+ return 13;
+#elif ENABLE(APPLE_PAY_COUPON_CODE) || ENABLE(APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE) || ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM) || ENABLE(APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
return 12;
#elif ENABLE(APPLE_PAY_SESSION_V11)
return 11;
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (285443 => 285444)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2021-11-09 00:34:24 UTC (rev 285444)
@@ -78,7 +78,7 @@
namespace WebCore {
-static ExceptionOr<ApplePayRequest> convertAndValidate(ScriptExecutionContext& context, JSC::JSValue data)
+static ExceptionOr<ApplePayRequest> convertAndValidateApplePayRequest(ScriptExecutionContext& context, JSC::JSValue data)
{
if (data.isEmpty())
return Exception { TypeError, "Missing payment method data." };
@@ -93,7 +93,7 @@
ExceptionOr<void> ApplePayPaymentHandler::validateData(Document& document, JSC::JSValue data)
{
- auto requestOrException = convertAndValidate(document, data);
+ auto requestOrException = convertAndValidateApplePayRequest(document, data);
if (requestOrException.hasException())
return requestOrException.releaseException();
@@ -202,7 +202,7 @@
ExceptionOr<void> ApplePayPaymentHandler::convertData(JSC::JSValue data)
{
- auto requestOrException = convertAndValidate(*scriptExecutionContext(), data);
+ auto requestOrException = convertAndValidateApplePayRequest(*scriptExecutionContext(), data);
if (requestOrException.hasException())
return requestOrException.releaseException();
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (285443 => 285444)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -73,6 +73,7 @@
// PaymentHandler
ExceptionOr<void> convertData(JSC::JSValue) final;
ExceptionOr<void> show(Document&) final;
+ bool canAbortSession() final { return true; }
void hide() final;
void canMakePayment(Document&, Function<void(bool)>&& completionHandler) final;
ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) final;
Added: trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp (0 => 285444)
--- trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2021 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 "ApplePayAMSUIPaymentHandler.h"
+
+#if ENABLE(APPLE_PAY_AMS_UI) && ENABLE(PAYMENT_REQUEST)
+
+#include "ApplePayAMSUIRequest.h"
+#include "Document.h"
+#include "JSApplePayAMSUIRequest.h"
+#include "JSDOMConvert.h"
+#include "Page.h"
+
+namespace WebCore {
+
+static ExceptionOr<ApplePayAMSUIRequest> convertAndValidateApplePayAMSUIRequest(ScriptExecutionContext& context, JSC::JSValue data)
+{
+ if (data.isEmpty())
+ return Exception { TypeError, "Missing payment method data." };
+
+ auto throwScope = DECLARE_THROW_SCOPE(context.vm());
+ auto applePayAMSUIRequest = convertDictionary<ApplePayAMSUIRequest>(*context.globalObject(), data);
+ if (throwScope.exception())
+ return Exception { ExistingExceptionError };
+
+ if (!applePayAMSUIRequest.engagementRequest.startsWith('{'))
+ return Exception { TypeError, "Member ApplePayAMSUIRequest.engagementRequest is required and must be a JSON-serializable object"_s };
+
+ return WTFMove(applePayAMSUIRequest);
+}
+
+ExceptionOr<void> ApplePayAMSUIPaymentHandler::validateData(Document& document, JSC::JSValue data)
+{
+ auto requestOrException = convertAndValidateApplePayAMSUIRequest(document, data);
+ if (requestOrException.hasException())
+ return requestOrException.releaseException();
+
+ return { };
+}
+
+bool ApplePayAMSUIPaymentHandler::handlesIdentifier(const PaymentRequest::MethodIdentifier& identifier)
+{
+ if (!std::holds_alternative<URL>(identifier))
+ return false;
+
+ auto& url = ""
+ return url.host() == "apple.com" && url.path() == "/ams-ui";
+}
+
+bool ApplePayAMSUIPaymentHandler::hasActiveSession(Document& document)
+{
+ auto* page = document.page();
+ return page && page->hasActiveApplePayAMSUISession();
+}
+
+void ApplePayAMSUIPaymentHandler::finishSession(std::optional<bool>&& result)
+{
+ if (!result) {
+ m_paymentRequest->reject(Exception { AbortError });
+ return;
+ }
+
+ m_paymentRequest->accept(std::get<URL>(m_identifier).string(), [success = *result] (JSC::JSGlobalObject& lexicalGlobalObject) -> JSC::Strong<JSC::JSObject> {
+ JSC::JSLockHolder lock { &lexicalGlobalObject };
+
+ JSC::VM& vm = lexicalGlobalObject.vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+ auto* object = constructEmptyObject(&lexicalGlobalObject);
+ object->putDirect(vm, JSC::Identifier::fromString(vm, "success"), JSC::jsBoolean(success));
+
+ RETURN_IF_EXCEPTION(throwScope, { });
+
+ return { vm, object };
+ });
+}
+
+ApplePayAMSUIPaymentHandler::ApplePayAMSUIPaymentHandler(Document& document, const PaymentRequest::MethodIdentifier& identifier, PaymentRequest& paymentRequest)
+ : ContextDestructionObserver { &document }
+ , m_identifier { identifier }
+ , m_paymentRequest { paymentRequest }
+{
+ ASSERT(handlesIdentifier(m_identifier));
+}
+
+Document& ApplePayAMSUIPaymentHandler::document() const
+{
+ ASSERT(is<Document>(scriptExecutionContext()));
+ return downcast<Document>(*scriptExecutionContext());
+}
+
+Page& ApplePayAMSUIPaymentHandler::page() const
+{
+ ASSERT(document().page());
+ return *document().page();
+}
+
+ExceptionOr<void> ApplePayAMSUIPaymentHandler::convertData(JSC::JSValue data)
+{
+ auto requestOrException = convertAndValidateApplePayAMSUIRequest(*scriptExecutionContext(), data);
+ if (requestOrException.hasException())
+ return requestOrException.releaseException();
+
+ m_applePayAMSUIRequest = requestOrException.releaseReturnValue();
+ return { };
+}
+
+ExceptionOr<void> ApplePayAMSUIPaymentHandler::show(Document& document)
+{
+ ASSERT(m_applePayAMSUIRequest);
+
+ if (!page().startApplePayAMSUISession(document, *this, *m_applePayAMSUIRequest))
+ return Exception { AbortError };
+
+ return { };
+}
+
+void ApplePayAMSUIPaymentHandler::hide()
+{
+ page().abortApplePayAMSUISession(*this);
+}
+
+void ApplePayAMSUIPaymentHandler::canMakePayment(Document& document, Function<void(bool)>&& completionHandler)
+{
+ auto* page = document.page();
+ completionHandler(page && !page->hasActiveApplePayAMSUISession());
+}
+
+ExceptionOr<void> ApplePayAMSUIPaymentHandler::detailsUpdated(PaymentRequest::UpdateReason, String&& /* error */, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* /* paymentMethodErrors */)
+{
+ ASSERT_NOT_REACHED_WITH_MESSAGE("ApplePayAMSUIPaymentHandler does not need shipping/payment info");
+ return { };
+}
+
+ExceptionOr<void> ApplePayAMSUIPaymentHandler::merchantValidationCompleted(JSC::JSValue&& /* merchantSessionValue */)
+{
+ ASSERT_NOT_REACHED_WITH_MESSAGE("ApplePayAMSUIPaymentHandler does not need merchant validation");
+ return { };
+}
+
+void ApplePayAMSUIPaymentHandler::complete(std::optional<PaymentComplete>&&)
+{
+ hide();
+}
+
+ExceptionOr<void> ApplePayAMSUIPaymentHandler::retry(PaymentValidationErrors&&)
+{
+ return show(document());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
Added: trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.h (0 => 285444)
--- trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.h (rev 0)
+++ trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_AMS_UI) && ENABLE(PAYMENT_REQUEST)
+
+#include "ApplePayAMSUIRequest.h"
+#include "ContextDestructionObserver.h"
+#include "ExceptionOr.h"
+#include "PaymentHandler.h"
+#include "PaymentRequest.h"
+#include <wtf/Function.h>
+#include <wtf/Ref.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace JSC {
+class JSObject;
+class JSValue;
+}
+
+namespace WebCore {
+
+class Document;
+class Page;
+
+struct AddressErrors;
+struct PayerErrorFields;
+
+enum class PaymentComplete;
+
+class ApplePayAMSUIPaymentHandler final : public PaymentHandler, private ContextDestructionObserver {
+public:
+ static ExceptionOr<void> validateData(Document&, JSC::JSValue);
+ static bool handlesIdentifier(const PaymentRequest::MethodIdentifier&);
+ static bool hasActiveSession(Document&);
+
+ void finishSession(std::optional<bool>&&);
+
+private:
+ friend class PaymentHandler;
+ explicit ApplePayAMSUIPaymentHandler(Document&, const PaymentRequest::MethodIdentifier&, PaymentRequest&);
+
+ Document& document() const;
+ Page& page() const;
+
+ // PaymentHandler
+ ExceptionOr<void> convertData(JSC::JSValue) final;
+ ExceptionOr<void> show(Document&) final;
+ bool canAbortSession() final { return false; }
+ void hide() final;
+ void canMakePayment(Document&, Function<void(bool)>&& completionHandler) final;
+ ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) final;
+ ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) final;
+ void complete(std::optional<PaymentComplete>&&) final;
+ ExceptionOr<void> retry(PaymentValidationErrors&&) final;
+
+ PaymentRequest::MethodIdentifier m_identifier;
+ Ref<PaymentRequest> m_paymentRequest;
+ std::optional<ApplePayAMSUIRequest> m_applePayAMSUIRequest;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
Copied: trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIRequest.h (from rev 285443, trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm) (0 => 285444)
--- trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIRequest.h (rev 0)
+++ trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIRequest.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_AMS_UI) && ENABLE(PAYMENT_REQUEST)
+
+#include <optional>
+#include <wtf/URL.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct ApplePayAMSUIRequest {
+ String engagementRequest; // required JSON
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<ApplePayAMSUIRequest> decode(Decoder&);
+};
+
+template<class Encoder>
+void ApplePayAMSUIRequest::encode(Encoder& encoder) const
+{
+ encoder << engagementRequest;
+}
+
+template<class Decoder>
+std::optional<ApplePayAMSUIRequest> ApplePayAMSUIRequest::decode(Decoder& decoder)
+{
+ std::optional<String> engagementRequest;
+ decoder >> engagementRequest;
+ if (!engagementRequest)
+ return std::nullopt;
+
+ return { { WTFMove(*engagementRequest) } };
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY_AMS_UI) && ENABLE(PAYMENT_REQUEST)
Copied: trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl (from rev 285443, trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm) (0 => 285444)
--- trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl (rev 0)
+++ trunk/Source/WebCore/Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+[
+ Conditional=APPLE_PAY_AMS_UI&PAYMENT_REQUEST,
+] dictionary ApplePayAMSUIRequest {
+ required JSON engagementRequest;
+};
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp (285443 => 285444)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp 2021-11-09 00:34:24 UTC (rev 285444)
@@ -28,6 +28,10 @@
#if ENABLE(PAYMENT_REQUEST)
+#if ENABLE(APPLE_PAY_AMS_UI)
+#include "ApplePayAMSUIPaymentHandler.h"
+#endif
+
#if ENABLE(APPLE_PAY)
#include "ApplePayPaymentHandler.h"
#endif
@@ -39,12 +43,16 @@
#if ENABLE(APPLE_PAY)
if (ApplePayPaymentHandler::handlesIdentifier(identifier))
return adoptRef(new ApplePayPaymentHandler(document, identifier, paymentRequest));
-#else
+#endif
+
+#if ENABLE(APPLE_PAY_AMS_UI)
+ if (ApplePayAMSUIPaymentHandler::handlesIdentifier(identifier))
+ return adoptRef(new ApplePayAMSUIPaymentHandler(document, identifier, paymentRequest));
+#endif
+
UNUSED_PARAM(document);
UNUSED_PARAM(paymentRequest);
UNUSED_PARAM(identifier);
-#endif
-
return nullptr;
}
@@ -66,12 +74,16 @@
#if ENABLE(APPLE_PAY)
if (ApplePayPaymentHandler::handlesIdentifier(identifier))
return ApplePayPaymentHandler::validateData(document, data);
-#else
+#endif
+
+#if ENABLE(APPLE_PAY_AMS_UI)
+ if (ApplePayAMSUIPaymentHandler::handlesIdentifier(identifier))
+ return ApplePayAMSUIPaymentHandler::validateData(document, data);
+#endif
+
UNUSED_PARAM(document);
UNUSED_PARAM(data);
UNUSED_PARAM(identifier);
-#endif
-
return { };
}
@@ -88,11 +100,17 @@
bool PaymentHandler::hasActiveSession(Document& document)
{
#if ENABLE(APPLE_PAY)
- return ApplePayPaymentHandler::hasActiveSession(document);
-#else
+ if (ApplePayPaymentHandler::hasActiveSession(document))
+ return true;
+#endif
+
+#if ENABLE(APPLE_PAY_AMS_UI)
+ if (ApplePayAMSUIPaymentHandler::hasActiveSession(document))
+ return true;
+#endif
+
UNUSED_PARAM(document);
return false;
-#endif
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h (285443 => 285444)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -52,6 +52,7 @@
virtual ExceptionOr<void> convertData(JSC::JSValue) = 0;
virtual ExceptionOr<void> show(Document&) = 0;
+ virtual bool canAbortSession() = 0;
virtual void hide() = 0;
virtual void canMakePayment(Document&, Function<void(bool)>&& completionHandler) = 0;
virtual ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) = 0;
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (285443 => 285444)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2021-11-09 00:34:24 UTC (rev 285444)
@@ -494,6 +494,11 @@
return;
}
+ if (m_activePaymentHandler && !activePaymentHandler()->canAbortSession()) {
+ promise.reject(Exception { InvalidStateError });
+ return;
+ }
+
abortWithException(Exception { AbortError });
promise.resolve();
}
@@ -697,6 +702,35 @@
});
}
+void PaymentRequest::accept(const String& methodName, PaymentResponse::DetailsFunction&& detailsFunction)
+{
+ ASSERT(!m_isUpdating);
+ ASSERT(m_state == State::Interactive);
+
+ bool isRetry = m_response;
+ if (!isRetry) {
+ m_response = PaymentResponse::create(scriptExecutionContext(), *this);
+ m_response->setRequestId(m_details.id);
+ }
+
+ m_response->setMethodName(methodName);
+ m_response->setDetailsFunction(WTFMove(detailsFunction));
+ m_response->setShippingAddress(nullptr);
+ m_response->setShippingOption(nullString());
+ m_response->setPayerName(nullString());
+ m_response->setPayerEmail(nullString());
+ m_response->setPayerPhone(nullString());
+
+ if (!isRetry)
+ settleShowPromise(*m_response);
+ else {
+ ASSERT(m_response->hasRetryPromise());
+ m_response->settleRetryPromise();
+ }
+
+ m_state = State::Closed;
+}
+
void PaymentRequest::accept(const String& methodName, PaymentResponse::DetailsFunction&& detailsFunction, Ref<PaymentAddress>&& shippingAddress, const String& payerName, const String& payerEmail, const String& payerPhone)
{
ASSERT(!m_isUpdating);
@@ -726,6 +760,11 @@
m_state = State::Closed;
}
+void PaymentRequest::reject(Exception&& exception)
+{
+ abortWithException(WTFMove(exception));
+}
+
ExceptionOr<void> PaymentRequest::complete(std::optional<PaymentComplete>&& result)
{
ASSERT(m_state == State::Closed);
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (285443 => 285444)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -96,7 +96,9 @@
void paymentMethodChanged(const String& methodName, PaymentMethodChangeEvent::MethodDetailsFunction&&);
ExceptionOr<void> updateWith(UpdateReason, Ref<DOMPromise>&&);
ExceptionOr<void> completeMerchantValidation(Event&, Ref<DOMPromise>&&);
+ void accept(const String& methodName, PaymentResponse::DetailsFunction&&);
void accept(const String& methodName, PaymentResponse::DetailsFunction&&, Ref<PaymentAddress>&& shippingAddress, const String& payerName, const String& payerEmail, const String& payerPhone);
+ void reject(Exception&&);
ExceptionOr<void> complete(std::optional<PaymentComplete>&&);
ExceptionOr<void> retry(PaymentValidationErrors&&);
void cancel();
Modified: trunk/Source/WebCore/PlatformMac.cmake (285443 => 285444)
--- trunk/Source/WebCore/PlatformMac.cmake 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/PlatformMac.cmake 2021-11-09 00:34:24 UTC (rev 285444)
@@ -589,6 +589,7 @@
platform/cocoa/LocalCurrentGraphicsContext.h
platform/cocoa/NetworkExtensionContentFilter.h
platform/cocoa/PlatformView.h
+ platform/cocoa/PlatformViewController.h
platform/cocoa/PlaybackSessionModel.h
platform/cocoa/PlaybackSessionModelMediaElement.h
platform/cocoa/PowerSourceNotifier.h
@@ -794,6 +795,8 @@
Modules/applepay/paymentrequest/ApplePayModifier.idl
Modules/applepay/paymentrequest/ApplePayRequest.idl
+ Modules/applepay-ams-ui/ApplePayAMSUIRequest.idl
+
Modules/plugins/QuickTimePluginReplacement.idl
)
Modified: trunk/Source/WebCore/SourcesCocoa.txt (285443 => 285444)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-11-09 00:34:24 UTC (rev 285444)
@@ -21,6 +21,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
+JSApplePayAMSUIRequest.cpp
JSApplePayCancelEvent.cpp
JSApplePayContactField.cpp
JSApplePayCouponCodeChangedEvent.cpp
@@ -96,6 +97,7 @@
Modules/applepay/cocoa/PaymentSessionErrorCocoa.mm
Modules/applepay/cocoa/PaymentSummaryItemsCocoa.mm
Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
+Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp
Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm
Modules/async-clipboard/mac/ClipboardImageReaderMac.mm
Modules/mediastream/RTCRtpSFrameTransformerCocoa.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285443 => 285444)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-11-09 00:34:24 UTC (rev 285444)
@@ -3054,6 +3054,7 @@
9596B93825DEEF0300ED2CFA /* JSApplePayCouponCodeChangedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 9596B93625DEEF0200ED2CFA /* JSApplePayCouponCodeChangedEvent.h */; };
95A1E2E925CC75A900268C8E /* MediaControlsContextMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 95A1E2E725CC75A800268C8E /* MediaControlsContextMenuItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
95AA571025EEED32004E9283 /* InspectorCanvasCallTracer.h in Headers */ = {isa = PBXBuildFile; fileRef = 95AA570E25EEED31004E9283 /* InspectorCanvasCallTracer.h */; };
+ 95BA4FAD26D981AA002A0E62 /* PlatformViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 95BA4FAB26D981AA002A0E62 /* PlatformViewController.h */; settings = {ATTRIBUTES = (Private, ); }; };
95DF9D25252BEDB2000D7F46 /* PointerCharacteristics.h in Headers */ = {isa = PBXBuildFile; fileRef = 95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */; settings = {ATTRIBUTES = (Private, ); }; };
95EAD563266EF2DB004B9CF1 /* ApplePayCouponCodeChangedEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 95EAD55F266EF2DA004B9CF1 /* ApplePayCouponCodeChangedEvent.h */; };
95EAD56A266EF2FA004B9CF1 /* ApplePayDateComponentsRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 95EAD566266EF2F8004B9CF1 /* ApplePayDateComponentsRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3070,6 +3071,8 @@
95EAD594266EF5D4004B9CF1 /* JSApplePayPaymentRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C6579EC1E00856600E3A27A /* JSApplePayPaymentRequest.h */; };
95EAD597266EF60B004B9CF1 /* JSApplePayShippingContactEditingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 95EAD595266EF609004B9CF1 /* JSApplePayShippingContactEditingMode.h */; };
95F45D27264DFBF100D0B8B8 /* PageColorSampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 95F45D26264DFBEB00D0B8B8 /* PageColorSampler.h */; };
+ 95FB662526D7033C0068AC67 /* ApplePayAMSUIPaymentHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 95FB662126D7033B0068AC67 /* ApplePayAMSUIPaymentHandler.h */; };
+ 95FB662626D7033C0068AC67 /* ApplePayAMSUIRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 95FB662226D7033B0068AC67 /* ApplePayAMSUIRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B7289144FFAC600F00A37 /* EventInterfaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B72A5145008EB00F00A37 /* EventHeaders.h */; };
@@ -12519,6 +12522,7 @@
95A1E2E725CC75A800268C8E /* MediaControlsContextMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlsContextMenuItem.h; sourceTree = "<group>"; };
95AA570D25EEED30004E9283 /* InspectorCanvasCallTracer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasCallTracer.cpp; sourceTree = "<group>"; };
95AA570E25EEED31004E9283 /* InspectorCanvasCallTracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasCallTracer.h; sourceTree = "<group>"; };
+ 95BA4FAB26D981AA002A0E62 /* PlatformViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformViewController.h; sourceTree = "<group>"; };
95DF9D23252BED99000D7F46 /* PointerCharacteristics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PointerCharacteristics.h; sourceTree = "<group>"; };
95EAD55F266EF2DA004B9CF1 /* ApplePayCouponCodeChangedEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayCouponCodeChangedEvent.h; sourceTree = "<group>"; };
95EAD561266EF2DA004B9CF1 /* ApplePayCouponCodeChangedEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ApplePayCouponCodeChangedEvent.idl; sourceTree = "<group>"; };
@@ -12549,6 +12553,10 @@
95EAD596266EF60A004B9CF1 /* JSApplePayShippingContactEditingMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayShippingContactEditingMode.cpp; sourceTree = "<group>"; };
95F45D24264DFBEB00D0B8B8 /* PageColorSampler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PageColorSampler.cpp; sourceTree = "<group>"; };
95F45D26264DFBEB00D0B8B8 /* PageColorSampler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PageColorSampler.h; sourceTree = "<group>"; };
+ 95FB662026D7033B0068AC67 /* ApplePayAMSUIRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ApplePayAMSUIRequest.idl; sourceTree = "<group>"; };
+ 95FB662126D7033B0068AC67 /* ApplePayAMSUIPaymentHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayAMSUIPaymentHandler.h; sourceTree = "<group>"; };
+ 95FB662226D7033B0068AC67 /* ApplePayAMSUIRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayAMSUIRequest.h; sourceTree = "<group>"; };
+ 95FB662326D7033B0068AC67 /* ApplePayAMSUIPaymentHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplePayAMSUIPaymentHandler.cpp; sourceTree = "<group>"; };
97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; };
97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; };
970B7289144FFAC600F00A37 /* EventInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EventInterfaces.h; path = DerivedSources/WebCore/EventInterfaces.h; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -18899,11 +18907,11 @@
1A569CC40D7E2B60007C3983 /* bridge */ = {
isa = PBXGroup;
children = (
+ 59B5977111086556007159E8 /* jsc */,
1A569CE20D7E2B82007C3983 /* objc */,
599E758F11055A1F00D904FA /* Bridge.h */,
1A71D5790F33819000F9CE4E /* IdentifierRep.cpp */,
1A71D57A0F33819000F9CE4E /* IdentifierRep.h */,
- 59B5977111086556007159E8 /* jsc */,
1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */,
1A569CF00D7E2B82007C3983 /* runtime_array.h */,
1A569CF10D7E2B82007C3983 /* runtime_method.cpp */,
@@ -24980,11 +24988,23 @@
name = parser;
sourceTree = "<group>";
};
+ 95FB661F26D7033B0068AC67 /* applepay-ams-ui */ = {
+ isa = PBXGroup;
+ children = (
+ 95FB662326D7033B0068AC67 /* ApplePayAMSUIPaymentHandler.cpp */,
+ 95FB662126D7033B0068AC67 /* ApplePayAMSUIPaymentHandler.h */,
+ 95FB662226D7033B0068AC67 /* ApplePayAMSUIRequest.h */,
+ 95FB662026D7033B0068AC67 /* ApplePayAMSUIRequest.idl */,
+ );
+ path = "applepay-ams-ui";
+ sourceTree = "<group>";
+ };
971145FE14EF006E00674FD9 /* Modules */ = {
isa = PBXGroup;
children = (
CE26169D187E6554007955F3 /* airplay */,
1A58E8611D19D37300C0EA73 /* applepay */,
+ 95FB661F26D7033B0068AC67 /* applepay-ams-ui */,
63BD4A5C1F778E8400438722 /* applicationmanifest */,
F440E76A233D93C80063F9AB /* async-clipboard */,
832150791F27E96B0095B136 /* beacon */,
@@ -25769,6 +25789,7 @@
F4FB35002350C96200F0094A /* PasteboardCustomDataCocoa.mm */,
F4628A9E234D3BBF00BC884C /* PlatformPasteboardCocoa.mm */,
52B0D4BD1C57FD1E0077CE53 /* PlatformView.h */,
+ 95BA4FAB26D981AA002A0E62 /* PlatformViewController.h */,
CDA29A0A1CBD9A7400901CCF /* PlaybackSessionModel.h */,
CDA29A0D1CBD9CFE00901CCF /* PlaybackSessionModelMediaElement.h */,
CDA29A0C1CBD9CFE00901CCF /* PlaybackSessionModelMediaElement.mm */,
@@ -32244,6 +32265,8 @@
445210DF25D61F00003A2ED8 /* AppHighlight.h in Headers */,
44AE045C2579CFFB00C42E65 /* AppHighlightRangeData.h in Headers */,
4425070925829A2700C09368 /* AppHighlightStorage.h in Headers */,
+ 95FB662526D7033C0068AC67 /* ApplePayAMSUIPaymentHandler.h in Headers */,
+ 95FB662626D7033C0068AC67 /* ApplePayAMSUIRequest.h in Headers */,
A113E02E2331A134009C33A0 /* ApplePayCancelEvent.h in Headers */,
A1DF5A941F7EC4320058A477 /* ApplePayContactField.h in Headers */,
95EAD563266EF2DB004B9CF1 /* ApplePayCouponCodeChangedEvent.h in Headers */,
@@ -35374,6 +35397,7 @@
0F7D07331884C56C00B4AF86 /* PlatformTextTrack.h in Headers */,
074E82BB18A69F0E007EF54C /* PlatformTimeRanges.h in Headers */,
52B0D4BE1C57FD1E0077CE53 /* PlatformView.h in Headers */,
+ 95BA4FAD26D981AA002A0E62 /* PlatformViewController.h in Headers */,
935C476B09AC4D4F00A6AAB4 /* PlatformWheelEvent.h in Headers */,
E1EE8B722412B2A800E794D6 /* PlatformXR.h in Headers */,
5273CC77256103CF00850007 /* PlatformXRCocoa.h in Headers */,
Modified: trunk/Source/WebCore/page/ChromeClient.h (285443 => 285444)
--- trunk/Source/WebCore/page/ChromeClient.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/page/ChromeClient.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -124,6 +124,7 @@
#endif
struct AppHighlight;
+struct ApplePayAMSUIRequest;
struct ContactsRequestData;
struct ContentRuleListResults;
struct DataDetectorElementInfo;
@@ -611,6 +612,11 @@
virtual void modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&) const { };
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+ virtual void startApplePayAMSUISession(const URL&, const ApplePayAMSUIRequest&, CompletionHandler<void(std::optional<bool>&&)>&& completionHandler) { completionHandler(std::nullopt); }
+ virtual void abortApplePayAMSUISession() { }
+#endif
+
protected:
virtual ~ChromeClient() = default;
};
Modified: trunk/Source/WebCore/page/Page.cpp (285443 => 285444)
--- trunk/Source/WebCore/page/Page.cpp 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/page/Page.cpp 2021-11-09 00:34:24 UTC (rev 285444)
@@ -168,6 +168,10 @@
#include <wtf/text/StringHash.h>
#include <wtf/text/TextStream.h>
+#if ENABLE(APPLE_PAY_AMS_UI)
+#include "ApplePayAMSUIPaymentHandler.h"
+#endif
+
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
#include "HTMLVideoElement.h"
#include "MediaPlaybackTarget.h"
@@ -3482,6 +3486,42 @@
}
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+
+bool Page::startApplePayAMSUISession(Document& document, ApplePayAMSUIPaymentHandler& paymentHandler, const ApplePayAMSUIRequest& request)
+{
+ if (hasActiveApplePayAMSUISession())
+ return false;
+
+ m_activeApplePayAMSUIPaymentHandler = &paymentHandler;
+
+ chrome().client().startApplePayAMSUISession(document.url(), request, [weakThis = WeakPtr { *this }, paymentHandlerPtr = &paymentHandler] (std::optional<bool>&& result) {
+ auto strongThis = weakThis.get();
+ if (!strongThis)
+ return;
+
+ if (paymentHandlerPtr != strongThis->m_activeApplePayAMSUIPaymentHandler)
+ return;
+
+ if (auto activePaymentHandler = std::exchange(strongThis->m_activeApplePayAMSUIPaymentHandler, nullptr))
+ activePaymentHandler->finishSession(WTFMove(result));
+ });
+ return true;
+}
+
+void Page::abortApplePayAMSUISession(ApplePayAMSUIPaymentHandler& paymentHandler)
+{
+ if (&paymentHandler != m_activeApplePayAMSUIPaymentHandler)
+ return;
+
+ chrome().client().abortApplePayAMSUISession();
+
+ if (auto activePaymentHandler = std::exchange(m_activeApplePayAMSUIPaymentHandler, nullptr))
+ activePaymentHandler->finishSession(std::nullopt);
+}
+
+#endif // ENABLE(APPLE_PAY_AMS_UI)
+
#if ENABLE(MEDIA_SESSION_COORDINATOR)
void Page::setMediaSessionCoordinator(Ref<MediaSessionCoordinatorPrivate>&& mediaSessionCoordinator)
{
Modified: trunk/Source/WebCore/page/Page.h (285443 => 285444)
--- trunk/Source/WebCore/page/Page.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebCore/page/Page.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -91,6 +91,7 @@
class IDBConnectionToServer;
}
+class ApplePayAMSUIPaymentHandler;
class ActivityStateChangeObserver;
class AlternativeTextClient;
class ApplicationCacheStorage;
@@ -167,6 +168,7 @@
class WheelEventDeltaFilter;
class WheelEventTestMonitor;
+struct ApplePayAMSUIRequest;
struct SimpleRange;
struct TextRecognitionResult;
@@ -541,6 +543,12 @@
WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&);
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+ bool hasActiveApplePayAMSUISession() const { return m_activeApplePayAMSUIPaymentHandler; }
+ bool startApplePayAMSUISession(Document&, ApplePayAMSUIPaymentHandler&, const ApplePayAMSUIRequest&);
+ void abortApplePayAMSUISession(ApplePayAMSUIPaymentHandler&);
+#endif
+
#if ENABLE(WEB_AUTHN)
AuthenticatorCoordinator& authenticatorCoordinator() { return m_authenticatorCoordinator.get(); }
#endif
@@ -1188,6 +1196,10 @@
std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+ RefPtr<ApplePayAMSUIPaymentHandler> m_activeApplePayAMSUIPaymentHandler;
+#endif
+
#if ENABLE(WEB_AUTHN)
UniqueRef<AuthenticatorCoordinator> m_authenticatorCoordinator;
#endif
Added: trunk/Source/WebCore/platform/cocoa/PlatformViewController.h (0 => 285444)
--- trunk/Source/WebCore/platform/cocoa/PlatformViewController.h (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/PlatformViewController.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 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. ``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
+ * 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.
+ */
+
+#ifndef PlatformViewController_h
+#define PlatformViewController_h
+
+#if PLATFORM(COCOA)
+
+#if PLATFORM(IOS_FAMILY)
+OBJC_CLASS UIViewController;
+typedef UIViewController PlatformViewController;
+#else
+OBJC_CLASS NSViewController;
+typedef NSViewController PlatformViewController;
+#endif
+
+#endif // PLATFORM(COCOA)
+
+#endif /* PlatformViewController_h */
Modified: trunk/Source/WebKit/ChangeLog (285443 => 285444)
--- trunk/Source/WebKit/ChangeLog 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/ChangeLog 2021-11-09 00:34:24 UTC (rev 285444)
@@ -1,3 +1,43 @@
+2021-11-08 Devin Rousso <[email protected]>
+
+ [Payment Request] Add a new payment method for showing AMS UI
+ https://bugs.webkit.org/show_bug.cgi?id=232634
+ <rdar://problem/79024227>
+
+ Reviewed by Tim Horton.
+
+ Leverage the W3C Payment Request API as a way for Apple domains to show alternate native
+ payment UIs without having to add new proprietary APIs (e.g. Apple Pay JS). This new payment
+ method is quite bare-bones in that it just takes some JSON and passes it to AMS, which then
+ decides what UI to show based on that. No data is exposed back to the page other than either
+ an error or a yes/no as to whether the payment was successful.
+
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::startApplePayAMSUISession): Added.
+ (WebKit::WebChromeClient::abortApplePayAMSUISession): Added.
+ Add plumbing between WebCore/WebProcess and UIProcess.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::startApplePayAMSUISession): Added.
+ (WebKit::WebPageProxy::abortApplePayAMSUISession): Added.
+ Use AMS to present UI for the given engagement request data and originating URL.
+
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::presentingViewController):
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::presentingViewController):
+ Add support for `-[WKUIDelegatePrivate _presentingViewControllerForWebView:]` on macOS too.
+
+ * Platform/spi/Cocoa/AppleMediaServicesSPI.h: Added.
+ * Platform/spi/Cocoa/AppleMediaServicesUISPI.h: Added.
+ * WebKit.xcodeproj/project.pbxproj:
+
2021-11-08 Alex Christensen <[email protected]>
Parse redirect and modify-headers actions for WKContentRuleList
Copied: trunk/Source/WebKit/Platform/spi/Cocoa/AppleMediaServicesSPI.h (from rev 285443, trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm) (0 => 285444)
--- trunk/Source/WebKit/Platform/spi/Cocoa/AppleMediaServicesSPI.h (rev 0)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/AppleMediaServicesSPI.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_AMS_UI)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppleMediaServices/AMSBag.h>
+#import <AppleMediaServices/AMSBagConsumer.h>
+#import <AppleMediaServices/AMSBagProtocol.h>
+#import <AppleMediaServices/AMSEngagementRequest.h>
+#import <AppleMediaServices/AMSEngagementResult.h>
+#import <AppleMediaServices/AMSPromise.h>
+#import <AppleMediaServices/AMSTask.h>
+
+#else // if !USE(APPLE_INTERNAL_SDK)
+
+@interface AMSPromise<ResultType> : NSObject
+- (void)addFinishBlock:(void(^)(ResultType _Nullable result, NSError * _Nullable error))finishBlock;
+@end
+
+@protocol AMSBagProtocol <NSObject>
+@end
+
+@interface AMSBag : NSObject <AMSBagProtocol>
+@end
+
+@protocol AMSBagConsumer <NSObject>
+@optional
++ (AMSBag *)createBagForSubProfile;
+@end
+
+@interface AMSEngagementRequest : NSObject <NSSecureCoding>
+- (instancetype)initWithRequestDictionary:(NSDictionary *)dictionary
+@property (NS_NONATOMIC_IOSONLY, strong, nullable) NSURL *originatingURL;
+@end
+
+@interface AMSEngagementResult : NSObject <NSSecureCoding>
+@end
+
+@interface AMSTask : NSObject
+- (BOOL)cancel;
+@end
+
+#endif // !USE(APPLE_INTERNAL_SDK)
+
+#endif // ENABLE(APPLE_PAY_AMS_UI)
Copied: trunk/Source/WebKit/Platform/spi/Cocoa/AppleMediaServicesUISPI.h (from rev 285443, trunk/Source/WebCore/Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm) (0 => 285444)
--- trunk/Source/WebKit/Platform/spi/Cocoa/AppleMediaServicesUISPI.h (rev 0)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/AppleMediaServicesUISPI.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY_AMS_UI)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppleMediaServicesUI/AMSUIEngagementTask.h>
+
+#else // if !USE(APPLE_INTERNAL_SDK)
+
+#include "AppleMediaServicesSPI.h"
+
+#if PLATFORM(IOS_FAMILY)
+OBJC_CLASS UIViewController;
+typedef UIViewController AMSUIViewController;
+#else
+OBJC_CLASS NSViewController;
+typedef NSViewController AMSUIViewController;
+#endif
+
+@interface AMSUIEngagementTask : AMSTask <AMSBagConsumer>
+- (instancetype)initWithRequest:(AMSEngagementRequest *)request bag:(id<AMSBagProtocol>)bag presentingViewController:(AMSUIViewController *)viewController;
+@property (NS_NONATOMIC_IOSONLY, assign) BOOL remotePresentation;
+- (AMSPromise<AMSEngagementResult *> *)presentEngagement;
+@end
+
+#endif // !USE(APPLE_INTERNAL_SDK)
+
+#endif // ENABLE(APPLE_PAY_AMS_UI)
Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -33,6 +33,10 @@
#include <WebCore/FloatRect.h>
#include <wtf/CompletionHandler.h>
+#if PLATFORM(COCOA)
+#include <WebCore/PlatformViewController.h>
+#endif
+
#if PLATFORM(IOS_FAMILY)
OBJC_CLASS NSArray;
OBJC_CLASS _WKActivatedElementInfo;
@@ -161,9 +165,9 @@
#endif
virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) { return defaultActions; }
virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) { }
- virtual UIViewController *presentingViewController() { return nullptr; }
#endif
#if PLATFORM(COCOA)
+ virtual PlatformViewController *presentingViewController() { return nullptr; }
virtual NSDictionary *dataDetectionContext() { return nullptr; }
#endif
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -226,6 +226,8 @@
#else // !TARGET_OS_IPHONE
+- (NSViewController *)_presentingViewControllerForWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(WK_MAC_TBA));
+
- (void)_prepareForImmediateActionAnimationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(10.13.4));
- (void)_cancelImmediateActionAnimationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(10.13.4));
- (void)_completeImmediateActionAnimationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(10.13.4));
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -29,6 +29,7 @@
#import "APIContextMenuClient.h"
#import "APIUIClient.h"
+#import <WebCore/PlatformViewController.h>
#import <wtf/RetainPtr.h>
#import <wtf/WeakObjCPtr.h>
#import <wtf/WeakPtr.h>
@@ -148,8 +149,8 @@
#endif
RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) final;
void didNotHandleTapAsClick(const WebCore::IntPoint&) final;
- UIViewController *presentingViewController() final;
#endif // PLATFORM(IOS_FAMILY)
+ PlatformViewController *presentingViewController() final;
NSDictionary *dataDetectionContext() final;
@@ -241,8 +242,8 @@
#endif
bool webViewActionsForElementDefaultActions : 1;
bool webViewDidNotHandleTapAsClickAtPoint : 1;
+#endif
bool presentingViewControllerForWebView : 1;
-#endif
bool dataDetectionContextForWebView : 1;
bool webViewImageOrMediaDocumentSizeChanged : 1;
#if ENABLE(POINTER_LOCK)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2021-11-09 00:34:24 UTC (rev 285444)
@@ -162,8 +162,8 @@
#endif
m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
+#endif
m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];
-#endif
m_delegateMethods.webViewIsMediaCaptureAuthorizedForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)] || [delegate respondsToSelector:@selector(_webView:includeSensitiveMediaDeviceDetails:)];
m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)];
@@ -1392,7 +1392,9 @@
[static_cast<id <WKUIDelegatePrivate>>(delegate) _webView:m_uiDelegate->m_webView.get().get() didNotHandleTapAsClickAtPoint:point];
}
-UIViewController *UIDelegate::UIClient::presentingViewController()
+#endif // PLATFORM(IOS_FAMILY)
+
+PlatformViewController *UIDelegate::UIClient::presentingViewController()
{
if (!m_uiDelegate)
return nullptr;
@@ -1407,8 +1409,6 @@
return [static_cast<id <WKUIDelegatePrivate>>(delegate) _presentingViewControllerForWebView:m_uiDelegate->m_webView.get().get()];
}
-#endif
-
NSDictionary *UIDelegate::UIClient::dataDetectionContext()
{
if (!m_uiDelegate)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2021-11-09 00:34:24 UTC (rev 285444)
@@ -29,6 +29,7 @@
#import "APIAttachment.h"
#import "APIPageConfiguration.h"
#import "APIUIClient.h"
+#import "AppleMediaServicesUISPI.h"
#import "CocoaImage.h"
#import "Connection.h"
#import "DataDetectionResult.h"
@@ -51,6 +52,7 @@
#import "WebsiteDataStore.h"
#import "WKErrorInternal.h"
#import <Foundation/NSURLRequest.h>
+#import <WebCore/ApplePayAMSUIRequest.h>
#import <WebCore/DragItem.h>
#import <WebCore/GeometryUtilities.h>
#import <WebCore/HighlightVisibility.h>
@@ -88,6 +90,14 @@
SOFT_LINK_CLASS(WebContentAnalysis, WebFilterEvaluator);
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(AppleMediaServices)
+SOFT_LINK_CLASS_OPTIONAL(AppleMediaServices, AMSEngagementRequest)
+
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(AppleMediaServicesUI)
+SOFT_LINK_CLASS_OPTIONAL(AppleMediaServicesUI, AMSUIEngagementTask)
+#endif
+
#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process().connection())
#define MESSAGE_CHECK_COMPLETION(assertion, completion) MESSAGE_CHECK_COMPLETION_BASE(assertion, process().connection(), completion)
@@ -628,6 +638,47 @@
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+
+void WebPageProxy::startApplePayAMSUISession(URL&& originatingURL, ApplePayAMSUIRequest&& request, CompletionHandler<void(std::optional<bool>&&)>&& completionHandler)
+{
+ if (!AppleMediaServicesUILibrary()) {
+ completionHandler(std::nullopt);
+ return;
+ }
+
+ PlatformViewController *presentingViewController = uiClient().presentingViewController();
+ if (!presentingViewController) {
+ completionHandler(std::nullopt);
+ return;
+ }
+
+ auto amsRequest = adoptNS([allocAMSEngagementRequestInstance() initWithRequestDictionary:dynamic_objc_cast<NSDictionary>([NSJSONSerialization JSONObjectWithData:[WTFMove(request.engagementRequest) dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil])]);
+ [amsRequest setOriginatingURL:WTFMove(originatingURL)];
+
+ auto amsBag = retainPtr([getAMSUIEngagementTaskClass() createBagForSubProfile]);
+
+ m_applePayAMSUISession = adoptNS([allocAMSUIEngagementTaskInstance() initWithRequest:amsRequest.get() bag:amsBag.get() presentingViewController:presentingViewController]);
+ [m_applePayAMSUISession setRemotePresentation:YES];
+
+ auto amsResult = retainPtr([m_applePayAMSUISession presentEngagement]);
+ [amsResult addFinishBlock:makeBlockPtr([completionHandler = WTFMove(completionHandler)] (AMSEngagementResult *result, NSError *error) mutable {
+ if (error) {
+ completionHandler(std::nullopt);
+ return;
+ }
+
+ completionHandler(result);
+ }).get()];
+}
+
+void WebPageProxy::abortApplePayAMSUISession()
+{
+ [std::exchange(m_applePayAMSUISession, nullptr) cancel];
+}
+
+#endif // ENABLE(APPLE_PAY_AMS_UI)
+
Vector<SandboxExtension::Handle> WebPageProxy::createNetworkExtensionsSandboxExtensions(WebProcessProxy& process)
{
#if ENABLE(CONTENT_FILTERING)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -230,6 +230,7 @@
}
#if PLATFORM(COCOA)
+OBJC_CLASS AMSUIEngagementTask;
OBJC_CLASS NSFileWrapper;
OBJC_CLASS NSMenu;
OBJC_CLASS NSTextAlternatives;
@@ -593,6 +594,11 @@
void modelElementPreviewDidObtainContextId(const WebCore::ElementContext&, const String&, uint32_t);
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+ void startApplePayAMSUISession(URL&&, WebCore::ApplePayAMSUIRequest&&, CompletionHandler<void(std::optional<bool>&&)>&&);
+ void abortApplePayAMSUISession();
+#endif
+
#if ENABLE(CONTEXT_MENUS)
API::ContextMenuClient& contextMenuClient() { return *m_contextMenuClient; }
void setContextMenuClient(std::unique_ptr<API::ContextMenuClient>&&);
@@ -2657,6 +2663,10 @@
std::unique_ptr<ModelElementController> m_modelElementController;
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+ RetainPtr<AMSUIEngagementTask> m_applePayAMSUISession;
+#endif
+
#if ENABLE(WEB_AUTHN)
std::unique_ptr<WebAuthenticatorCoordinatorProxy> m_credentialsMessenger;
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (285443 => 285444)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-11-09 00:34:24 UTC (rev 285444)
@@ -591,4 +591,9 @@
#endif
requestPermission(struct WebCore::ClientOrigin origin, struct WebCore::PermissionDescriptor descriptor) -> (enum:uint8_t WebCore::PermissionState state) Async
+
+#if ENABLE(APPLE_PAY_AMS_UI)
+ StartApplePayAMSUISession(URL originatingURL, struct WebCore::ApplePayAMSUIRequest request) -> (std::optional<bool> result) Async
+ AbortApplePayAMSUISession()
+#endif
}
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (285443 => 285444)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-11-09 00:34:24 UTC (rev 285444)
@@ -1466,6 +1466,8 @@
93E6A4EE1BC5DD3900F8A0E7 /* _WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E6A4ED1BC5DD3900F8A0E7 /* _WKHitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F549B41E3174B7000E7239 /* WKSnapshotConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F549B31E3174B7000E7239 /* WKSnapshotConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
950F2880252414EA00B74F1C /* WKMouseDeviceObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */; };
+ 9565083926D87A2B00E15CB7 /* AppleMediaServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9565083726D87A2B00E15CB7 /* AppleMediaServicesSPI.h */; };
+ 9565083A26D87A2B00E15CB7 /* AppleMediaServicesUISPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9565083826D87A2B00E15CB7 /* AppleMediaServicesUISPI.h */; };
9593675F252E5E3100D3F0A0 /* WKStylusDeviceObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 9593675D252E5E3000D3F0A0 /* WKStylusDeviceObserver.h */; };
95C943912523C0D00054F3D5 /* BaseBoardSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 95C943902523C0D00054F3D5 /* BaseBoardSPI.h */; };
99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */; };
@@ -4877,6 +4879,8 @@
93F549B51E3174DA000E7239 /* WKSnapshotConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSnapshotConfiguration.mm; sourceTree = "<group>"; };
950F287E252414E900B74F1C /* WKMouseDeviceObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKMouseDeviceObserver.h; path = ios/WKMouseDeviceObserver.h; sourceTree = "<group>"; };
950F287F252414EA00B74F1C /* WKMouseDeviceObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKMouseDeviceObserver.mm; path = ios/WKMouseDeviceObserver.mm; sourceTree = "<group>"; };
+ 9565083726D87A2B00E15CB7 /* AppleMediaServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleMediaServicesSPI.h; sourceTree = "<group>"; };
+ 9565083826D87A2B00E15CB7 /* AppleMediaServicesUISPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleMediaServicesUISPI.h; sourceTree = "<group>"; };
9593675D252E5E3000D3F0A0 /* WKStylusDeviceObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKStylusDeviceObserver.h; path = ios/WKStylusDeviceObserver.h; sourceTree = "<group>"; };
9593675E252E5E3100D3F0A0 /* WKStylusDeviceObserver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKStylusDeviceObserver.mm; path = ios/WKStylusDeviceObserver.mm; sourceTree = "<group>"; };
95C943902523C0D00054F3D5 /* BaseBoardSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseBoardSPI.h; sourceTree = "<group>"; };
@@ -7787,6 +7791,8 @@
children = (
E3CAAA432413278A00CED2E2 /* AccessibilitySupportSPI.h */,
572EBBDC25392181000552B3 /* AppAttestSPI.h */,
+ 9565083726D87A2B00E15CB7 /* AppleMediaServicesSPI.h */,
+ 9565083826D87A2B00E15CB7 /* AppleMediaServicesUISPI.h */,
57FABB0E25817CF00059DC95 /* AuthenticationServicesCoreSPI.h */,
1A5705101BE410E500874AF1 /* BlockSPI.h */,
E50620912542102000C43091 /* ContactsUISPI.h */,
@@ -11864,6 +11870,8 @@
572EBBDD25392181000552B3 /* AppAttestSPI.h in Headers */,
074879B92373A90900F5678E /* AppKitSoftLink.h in Headers */,
F48D2A8521583A7E00C6752B /* AppKitSPI.h in Headers */,
+ 9565083926D87A2B00E15CB7 /* AppleMediaServicesSPI.h in Headers */,
+ 9565083A26D87A2B00E15CB7 /* AppleMediaServicesUISPI.h in Headers */,
F4EC94E32356CC57000BB614 /* ApplicationServicesSPI.h in Headers */,
1AD4C1931B39F33200ABC28E /* ApplicationStateTracker.h in Headers */,
493102BD2683F3D0002BB885 /* AppPrivacyReport.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (285443 => 285444)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-11-09 00:34:24 UTC (rev 285444)
@@ -91,6 +91,10 @@
#include <WebCore/Settings.h>
#include <WebCore/TextIndicator.h>
+#if ENABLE(APPLE_PAY_AMS_UI)
+#include <WebCore/ApplePayAMSUIRequest.h>
+#endif
+
#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
#include "PlaybackSessionManager.h"
#endif
@@ -1534,4 +1538,18 @@
}
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+
+void WebChromeClient::startApplePayAMSUISession(const URL& originatingURL, const ApplePayAMSUIRequest& request, CompletionHandler<void(std::optional<bool>&&)>&& completionHandler)
+{
+ m_page.sendWithAsyncReply(Messages::WebPageProxy::StartApplePayAMSUISession(originatingURL, request), WTFMove(completionHandler));
+}
+
+void WebChromeClient::abortApplePayAMSUISession()
+{
+ m_page.send(Messages::WebPageProxy::AbortApplePayAMSUISession());
+}
+
+#endif // ENABLE(APPLE_PAY_AMS_UI)
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (285443 => 285444)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2021-11-09 00:17:54 UTC (rev 285443)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2021-11-09 00:34:24 UTC (rev 285444)
@@ -462,6 +462,11 @@
void modelElementDidCreatePreview(WebCore::HTMLModelElement&, const URL&, const String&, const WebCore::FloatSize&) const final;
#endif
+#if ENABLE(APPLE_PAY_AMS_UI)
+ void startApplePayAMSUISession(const URL&, const WebCore::ApplePayAMSUIRequest&, CompletionHandler<void(std::optional<bool>&&)>&&) final;
+ void abortApplePayAMSUISession() final;
+#endif
+
mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
mutable bool m_cachedMainFrameHasVerticalScrollbar { false };