[Apple Pay] Tell websites why a session was cancelled
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Sep 2019 19:13:33 +0000 (19:13 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Sep 2019 19:13:33 +0000 (19:13 +0000)
commit45952a84e72139480f57de9b54f43f7b9e8ee1b8
tree9b70127e2d9ef9e95b89ad9054d33a21ec8d22cf
parent2a1ea59af9b820b07d92c247669e9f81017d430a
[Apple Pay] Tell websites why a session was cancelled
https://bugs.webkit.org/show_bug.cgi?id=201912
Source/WebCore:

Reviewed by Brady Eidson.

Added ApplePayCancelEvent as the interface for ApplePaySession's cancel event. This event
object includes a `sessionError` attribute that exposes a Web-safe version of the PassKit
domain error we received from PKPaymentAuthorization(View)Controller. Currently, we report
all errors with code "unknown", but more codes will be added in future patches.

Test: http/tests/ssl/applepay/ApplePayCancelEvent.https.html

* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/applepay/ApplePayCancelEvent.cpp: Copied from Source/WebCore/Modules/applepay/PaymentHeaders.h.
(WebCore::ApplePayCancelEvent::ApplePayCancelEvent):
(WebCore::ApplePayCancelEvent::sessionError const):
(WebCore::ApplePayCancelEvent::eventInterface const):
* Modules/applepay/ApplePayCancelEvent.h: Copied from Source/WebCore/Modules/applepay/PaymentHeaders.h.
(WebCore::ApplePayCancelEvent::create):
* Modules/applepay/ApplePayCancelEvent.idl: Copied from Source/WebCore/Modules/applepay/PaymentHeaders.h.
* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::didCancelPaymentSession):
* Modules/applepay/ApplePaySession.h:
* Modules/applepay/ApplePaySessionError.h: Copied from Source/WebCore/Modules/applepay/PaymentHeaders.h.
* Modules/applepay/ApplePaySessionError.idl: Copied from Source/WebCore/Modules/applepay/PaymentHeaders.h.
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::didCancelPaymentSession):
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentHeaders.h:
* Modules/applepay/PaymentSession.cpp:
* Modules/applepay/PaymentSession.h:
* Modules/applepay/PaymentSessionError.h: Copied from Source/WebCore/Modules/applepay/PaymentHeaders.h.
* Modules/applepay/cocoa/PaymentSessionErrorCocoa.mm: Copied from Source/WebCore/Modules/applepay/PaymentSession.h.
(WebCore::additionalError):
(WebCore::PaymentSessionError::PaymentSessionError):
(WebCore::PaymentSessionError::sessionError const):
(WebCore::PaymentSessionError::platformError const):
(WebCore::PaymentSessionError::unknownError const):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::didCancelPaymentSession):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp:
* Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/EventNames.in:
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::cancelPayment):

Source/WebCore/PAL:

<rdar://problem/55469706>

Reviewed by Brady Eidson.

Soft-linked PKPassKitErrorDomain and included PassKit headers more judiciously.

* pal/cocoa/PassKitSoftLink.h:
* pal/cocoa/PassKitSoftLink.mm:
* pal/spi/cocoa/PassKitSPI.h:

Source/WebKit:

<rdar://problem/55469706>

Reviewed by Brady Eidson.

Remembered the error passed to -[WKPaymentAuthorizationDelegate _willFinishWithError:] and
sent it to the WebContent process in Messages::WebPaymentCoordinator::DidCancelPaymentSession.

* Platform/cocoa/PaymentAuthorizationPresenter.h:
* Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
(-[WKPaymentAuthorizationDelegate _didFinish]):
(-[WKPaymentAuthorizationDelegate _willFinishWithError:]):
* Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::didCancelPaymentSession):
(WebKit::WebPaymentCoordinatorProxy::presenterDidFinish):
* Shared/ApplePay/WebPaymentCoordinatorProxy.h:
(WebKit::WebPaymentCoordinatorProxy::didCancelPaymentSession):
* Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::PaymentSessionError>::encode):
(IPC::ArgumentCoder<WebCore::PaymentSessionError>::decode):
* Shared/WebCoreArgumentCoders.h:
* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::networkProcessConnectionClosed):
(WebKit::WebPaymentCoordinator::didCancelPaymentSession):
* WebProcess/ApplePay/WebPaymentCoordinator.h:
* WebProcess/ApplePay/WebPaymentCoordinator.messages.in:

LayoutTests:

Reviewed by Brady Eidson.

* http/tests/ssl/applepay/ApplePayCancelEvent.https-expected.txt: Added.
* http/tests/ssl/applepay/ApplePayCancelEvent.https.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePayCancelEvent.https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/ssl/applepay/ApplePayCancelEvent.https.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/applepay/ApplePayCancelEvent.cpp [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePayCancelEvent.h [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePayCancelEvent.idl [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/applepay/ApplePaySession.h
Source/WebCore/Modules/applepay/ApplePaySessionError.h [new file with mode: 0644]
Source/WebCore/Modules/applepay/ApplePaySessionError.idl [new file with mode: 0644]
Source/WebCore/Modules/applepay/PaymentCoordinator.cpp
Source/WebCore/Modules/applepay/PaymentCoordinator.h
Source/WebCore/Modules/applepay/PaymentHeaders.h
Source/WebCore/Modules/applepay/PaymentSession.cpp
Source/WebCore/Modules/applepay/PaymentSession.h
Source/WebCore/Modules/applepay/PaymentSessionError.h [new file with mode: 0644]
Source/WebCore/Modules/applepay/cocoa/PaymentSessionErrorCocoa.mm [new file with mode: 0644]
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h
Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp
Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h
Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm
Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/EventNames.in
Source/WebCore/testing/MockPaymentCoordinator.cpp
Source/WebKit/ChangeLog
Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.h
Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm
Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp
Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h
Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm
Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.messages.in