PaymentHandler.cpp [plain text]
#include "config.h"
#include "PaymentHandler.h"
#if ENABLE(PAYMENT_REQUEST)
#if ENABLE(APPLE_PAY)
#include "ApplePayPaymentHandler.h"
#endif
namespace WebCore {
RefPtr<PaymentHandler> PaymentHandler::create(Document& document, PaymentRequest& paymentRequest, const PaymentRequest::MethodIdentifier& identifier)
{
#if ENABLE(APPLE_PAY)
if (ApplePayPaymentHandler::handlesIdentifier(identifier))
return adoptRef(new ApplePayPaymentHandler(document, identifier, paymentRequest));
#else
UNUSED_PARAM(document);
UNUSED_PARAM(paymentRequest);
UNUSED_PARAM(identifier);
#endif
return nullptr;
}
ExceptionOr<void> PaymentHandler::canCreateSession(Document& document)
{
#if ENABLE(APPLE_PAY)
auto result = PaymentSession::canCreateSession(document);
if (result.hasException())
return Exception { SecurityError, result.releaseException().releaseMessage() };
#else
UNUSED_PARAM(document);
#endif
return { };
}
ExceptionOr<void> PaymentHandler::validateData(Document& document, JSC::JSValue data, const PaymentRequest::MethodIdentifier& identifier)
{
#if ENABLE(APPLE_PAY)
if (ApplePayPaymentHandler::handlesIdentifier(identifier))
return ApplePayPaymentHandler::validateData(document, data);
#else
UNUSED_PARAM(document);
UNUSED_PARAM(data);
UNUSED_PARAM(identifier);
#endif
return { };
}
bool PaymentHandler::enabledForContext(ScriptExecutionContext& context)
{
#if ENABLE(APPLE_PAY)
return PaymentSession::enabledForContext(context);
#else
UNUSED_PARAM(context);
return false;
#endif
}
bool PaymentHandler::hasActiveSession(Document& document)
{
#if ENABLE(APPLE_PAY)
return ApplePayPaymentHandler::hasActiveSession(document);
#else
UNUSED_PARAM(document);
return false;
#endif
}
}
#endif // ENABLE(PAYMENT_REQUEST)