haikuwebkit/Source/WebCore/Modules/applepay/ApplePayCancelEvent.h

59 lines
2.0 KiB
C
Raw Permalink Normal View History

[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. Canonical link: https://commits.webkit.org/215573@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-18 19:13:33 +00:00
/*
* Copyright (C) 2019 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)
#include "Event.h"
#include "PaymentSessionError.h"
namespace WebCore {
class PaymentSessionError;
class ApplePayCancelEvent : public Event {
WTF_MAKE_ISO_ALLOCATED(ApplePayCancelEvent);
[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. Canonical link: https://commits.webkit.org/215573@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-18 19:13:33 +00:00
public:
static Ref<ApplePayCancelEvent> create(const AtomString& type, PaymentSessionError&& sessionError)
{
return adoptRef(*new ApplePayCancelEvent(type, WTFMove(sessionError)));
}
ApplePaySessionError sessionError() const;
private:
explicit ApplePayCancelEvent(const AtomString&, PaymentSessionError&&);
// Event.
EventInterface eventInterface() const final;
PaymentSessionError m_sessionError;
};
} // namespace WebCore
#endif // ENABLE(APPLE_PAY)