WebPaymentCoordinator.h [plain text]
#pragma once
#if ENABLE(APPLE_PAY)
#include "MessageReceiver.h"
#include "MessageSender.h"
#include <WebCore/PaymentCoordinatorClient.h>
#include <WebCore/PaymentHeaders.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/text/StringHash.h>
namespace IPC {
class DataReference;
}
namespace WebCore {
class PaymentCoordinator;
class PaymentContact;
class PaymentSessionError;
}
namespace WebKit {
class NetworkProcessConnection;
class WebPage;
class WebPaymentCoordinator final : public WebCore::PaymentCoordinatorClient, private IPC::MessageReceiver, private IPC::MessageSender {
WTF_MAKE_FAST_ALLOCATED;
public:
friend class NetworkProcessConnection;
explicit WebPaymentCoordinator(WebPage&);
~WebPaymentCoordinator();
void networkProcessConnectionClosed();
private:
Optional<String> validatedPaymentNetwork(const String&) override;
bool canMakePayments() override;
void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) override;
void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) override;
bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&) override;
void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override;
void completeShippingMethodSelection(Optional<WebCore::ShippingMethodUpdate>&&) override;
void completeShippingContactSelection(Optional<WebCore::ShippingContactUpdate>&&) override;
void completePaymentMethodSelection(Optional<WebCore::PaymentMethodUpdate>&&) override;
void completePaymentSession(Optional<WebCore::PaymentAuthorizationResult>&&) override;
void abortPaymentSession() override;
void cancelPaymentSession() override;
void paymentCoordinatorDestroyed() override;
bool isWebPaymentCoordinator() const override { return true; }
bool isAlwaysOnLoggingAllowed() const override;
bool supportsUnrestrictedApplePay() const override;
String userAgentScriptsBlockedErrorMessage() const final;
void getSetupFeatures(const WebCore::ApplePaySetupConfiguration&, const URL&, CompletionHandler<void(Vector<Ref<WebCore::ApplePaySetupFeature>>&&)>&&) final;
void beginApplePaySetup(const WebCore::ApplePaySetupConfiguration&, const URL&, Vector<RefPtr<WebCore::ApplePaySetupFeature>>&&, CompletionHandler<void(bool)>&&) final;
void endApplePaySetup() final;
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
IPC::Connection* messageSenderConnection() const final;
uint64_t messageSenderDestinationID() const final;
void validateMerchant(const String& validationURLString);
void didAuthorizePayment(const WebCore::Payment&);
void didSelectShippingMethod(const WebCore::ApplePaySessionPaymentRequest::ShippingMethod&);
void didSelectShippingContact(const WebCore::PaymentContact&);
void didSelectPaymentMethod(const WebCore::PaymentMethod&);
void didCancelPaymentSession(WebCore::PaymentSessionError&&);
WebCore::PaymentCoordinator& paymentCoordinator();
#if ENABLE(APPLE_PAY_REMOTE_UI)
bool remoteUIEnabled() const;
#endif
using AvailablePaymentNetworksSet = HashSet<String, ASCIICaseInsensitiveHash>;
static AvailablePaymentNetworksSet platformAvailablePaymentNetworks();
WebPage& m_webPage;
Optional<AvailablePaymentNetworksSet> m_availablePaymentNetworks;
};
}
SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::WebPaymentCoordinator)
static bool isType(const WebCore::PaymentCoordinatorClient& paymentCoordinatorClient) { return paymentCoordinatorClient.isWebPaymentCoordinator(); }
SPECIALIZE_TYPE_TRAITS_END()
#endif