| Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
|
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
|
| index 63e221476b9c5d4619f63e40ddda08f1023310d6..3fffe48cfff3743d5bc689904177867ee4c7864d 100644
|
| --- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
|
| +++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
|
| @@ -12,7 +12,7 @@
|
| #include "bindings/core/v8/V8StringResource.h"
|
| #include "bindings/modules/v8/V8AndroidPayMethodData.h"
|
| #include "bindings/modules/v8/V8BasicCardRequest.h"
|
| -#include "bindings/modules/v8/V8PaymentDetailsUpdate.h"
|
| +#include "bindings/modules/v8/V8PaymentDetails.h"
|
| #include "core/EventTypeNames.h"
|
| #include "core/dom/DOMException.h"
|
| #include "core/dom/Document.h"
|
| @@ -30,8 +30,6 @@
|
| #include "modules/payments/BasicCardRequest.h"
|
| #include "modules/payments/HTMLIFrameElementPayments.h"
|
| #include "modules/payments/PaymentAddress.h"
|
| -#include "modules/payments/PaymentDetailsInit.h"
|
| -#include "modules/payments/PaymentDetailsUpdate.h"
|
| #include "modules/payments/PaymentItem.h"
|
| #include "modules/payments/PaymentRequestUpdateEvent.h"
|
| #include "modules/payments/PaymentResponse.h"
|
| @@ -474,12 +472,21 @@
|
| return result;
|
| }
|
|
|
| -void validateAndConvertPaymentDetailsBase(const PaymentDetailsBase& input,
|
| - bool requestShipping,
|
| - PaymentDetailsPtr& output,
|
| - String& shippingOptionOutput,
|
| - ExecutionContext& executionContext,
|
| - ExceptionState& exceptionState) {
|
| +void validateAndConvertPaymentDetails(const PaymentDetails& input,
|
| + bool requestShipping,
|
| + PaymentDetailsPtr& output,
|
| + String& shippingOptionOutput,
|
| + ExecutionContext& executionContext,
|
| + ExceptionState& exceptionState) {
|
| + if (!input.hasTotal()) {
|
| + exceptionState.throwTypeError("Must specify total");
|
| + return;
|
| + }
|
| +
|
| + validateAndConvertTotal(input.total(), output->total, exceptionState);
|
| + if (exceptionState.hadException())
|
| + return;
|
| +
|
| if (input.hasDisplayItems()) {
|
| validateAndConvertDisplayItems(input.displayItems(), output->display_items,
|
| exceptionState);
|
| @@ -499,45 +506,6 @@
|
| if (input.hasModifiers()) {
|
| validateAndConvertPaymentDetailsModifiers(
|
| input.modifiers(), output->modifiers, executionContext, exceptionState);
|
| - if (exceptionState.hadException())
|
| - return;
|
| - }
|
| -}
|
| -
|
| -void validateAndConvertPaymentDetailsInit(const PaymentDetailsInit& input,
|
| - bool requestShipping,
|
| - PaymentDetailsPtr& output,
|
| - String& shippingOptionOutput,
|
| - ExecutionContext& executionContext,
|
| - ExceptionState& exceptionState) {
|
| - validateAndConvertPaymentDetailsBase(input, requestShipping, output,
|
| - shippingOptionOutput, executionContext,
|
| - exceptionState);
|
| - if (exceptionState.hadException())
|
| - return;
|
| -
|
| - if (!input.hasTotal()) {
|
| - exceptionState.throwTypeError("Must specify total");
|
| - return;
|
| - }
|
| -
|
| - validateAndConvertTotal(input.total(), output->total, exceptionState);
|
| -}
|
| -
|
| -void validateAndConvertPaymentDetailsUpdate(const PaymentDetailsUpdate& input,
|
| - bool requestShipping,
|
| - PaymentDetailsPtr& output,
|
| - String& shippingOptionOutput,
|
| - ExecutionContext& executionContext,
|
| - ExceptionState& exceptionState) {
|
| - validateAndConvertPaymentDetailsBase(input, requestShipping, output,
|
| - shippingOptionOutput, executionContext,
|
| - exceptionState);
|
| - if (exceptionState.hadException())
|
| - return;
|
| -
|
| - if (input.hasTotal()) {
|
| - validateAndConvertTotal(input.total(), output->total, exceptionState);
|
| if (exceptionState.hadException())
|
| return;
|
| }
|
| @@ -660,7 +628,7 @@
|
| PaymentRequest* PaymentRequest::create(
|
| ExecutionContext* executionContext,
|
| const HeapVector<PaymentMethodData>& methodData,
|
| - const PaymentDetailsInit& details,
|
| + const PaymentDetails& details,
|
| ExceptionState& exceptionState) {
|
| return new PaymentRequest(executionContext, methodData, details,
|
| PaymentOptions(), exceptionState);
|
| @@ -669,7 +637,7 @@
|
| PaymentRequest* PaymentRequest::create(
|
| ExecutionContext* executionContext,
|
| const HeapVector<PaymentMethodData>& methodData,
|
| - const PaymentDetailsInit& details,
|
| + const PaymentDetails& details,
|
| const PaymentOptions& options,
|
| ExceptionState& exceptionState) {
|
| return new PaymentRequest(executionContext, methodData, details, options,
|
| @@ -793,13 +761,13 @@
|
| if (!m_showResolver || !m_paymentProvider)
|
| return;
|
|
|
| - PaymentDetailsUpdate details;
|
| + PaymentDetails details;
|
| ExceptionState exceptionState(v8::Isolate::GetCurrent(),
|
| ExceptionState::ConstructionContext,
|
| - "PaymentDetailsUpdate");
|
| - V8PaymentDetailsUpdate::toImpl(detailsScriptValue.isolate(),
|
| - detailsScriptValue.v8Value(), details,
|
| - exceptionState);
|
| + "PaymentDetails");
|
| + V8PaymentDetails::toImpl(detailsScriptValue.isolate(),
|
| + detailsScriptValue.v8Value(), details,
|
| + exceptionState);
|
| if (exceptionState.hadException()) {
|
| m_showResolver->reject(
|
| DOMException::create(SyntaxError, exceptionState.message()));
|
| @@ -809,9 +777,9 @@
|
|
|
| PaymentDetailsPtr validatedDetails =
|
| payments::mojom::blink::PaymentDetails::New();
|
| - validateAndConvertPaymentDetailsUpdate(
|
| - details, m_options.requestShipping(), validatedDetails, m_shippingOption,
|
| - *getExecutionContext(), exceptionState);
|
| + validateAndConvertPaymentDetails(details, m_options.requestShipping(),
|
| + validatedDetails, m_shippingOption,
|
| + *getExecutionContext(), exceptionState);
|
| if (exceptionState.hadException()) {
|
| m_showResolver->reject(
|
| DOMException::create(SyntaxError, exceptionState.message()));
|
| @@ -848,7 +816,7 @@
|
|
|
| PaymentRequest::PaymentRequest(ExecutionContext* executionContext,
|
| const HeapVector<PaymentMethodData>& methodData,
|
| - const PaymentDetailsInit& details,
|
| + const PaymentDetails& details,
|
| const PaymentOptions& options,
|
| ExceptionState& exceptionState)
|
| : ContextLifecycleObserver(executionContext),
|
| @@ -877,11 +845,16 @@
|
|
|
| PaymentDetailsPtr validatedDetails =
|
| payments::mojom::blink::PaymentDetails::New();
|
| - validateAndConvertPaymentDetailsInit(details, m_options.requestShipping(),
|
| - validatedDetails, m_shippingOption,
|
| - *getExecutionContext(), exceptionState);
|
| + validateAndConvertPaymentDetails(details, m_options.requestShipping(),
|
| + validatedDetails, m_shippingOption,
|
| + *getExecutionContext(), exceptionState);
|
| if (exceptionState.hadException())
|
| return;
|
| +
|
| + if (details.hasError()) {
|
| + exceptionState.throwTypeError("Error message not allowed in constructor");
|
| + return;
|
| + }
|
|
|
| if (m_options.requestShipping())
|
| m_shippingType = getValidShippingType(m_options.shippingType());
|
|
|