| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/payments/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "modules/payments/PaymentAddress.h" | 32 #include "modules/payments/PaymentAddress.h" |
| 33 #include "modules/payments/PaymentDetailsInit.h" | 33 #include "modules/payments/PaymentDetailsInit.h" |
| 34 #include "modules/payments/PaymentDetailsUpdate.h" | 34 #include "modules/payments/PaymentDetailsUpdate.h" |
| 35 #include "modules/payments/PaymentItem.h" | 35 #include "modules/payments/PaymentItem.h" |
| 36 #include "modules/payments/PaymentRequestUpdateEvent.h" | 36 #include "modules/payments/PaymentRequestUpdateEvent.h" |
| 37 #include "modules/payments/PaymentResponse.h" | 37 #include "modules/payments/PaymentResponse.h" |
| 38 #include "modules/payments/PaymentShippingOption.h" | 38 #include "modules/payments/PaymentShippingOption.h" |
| 39 #include "modules/payments/PaymentsValidators.h" | 39 #include "modules/payments/PaymentsValidators.h" |
| 40 #include "mojo/public/cpp/bindings/interface_request.h" | 40 #include "mojo/public/cpp/bindings/interface_request.h" |
| 41 #include "platform/RuntimeEnabledFeatures.h" | 41 #include "platform/RuntimeEnabledFeatures.h" |
| 42 #include "platform/UUID.h" |
| 42 #include "platform/mojo/MojoHelper.h" | 43 #include "platform/mojo/MojoHelper.h" |
| 43 #include "public/platform/InterfaceProvider.h" | 44 #include "public/platform/InterfaceProvider.h" |
| 44 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
| 45 #include "public/platform/WebTraceLocation.h" | 46 #include "public/platform/WebTraceLocation.h" |
| 46 #include "wtf/HashSet.h" | 47 #include "wtf/HashSet.h" |
| 47 | 48 |
| 48 using payments::mojom::blink::CanMakePaymentQueryResult; | 49 using payments::mojom::blink::CanMakePaymentQueryResult; |
| 49 using payments::mojom::blink::PaymentAddressPtr; | 50 using payments::mojom::blink::PaymentAddressPtr; |
| 50 using payments::mojom::blink::PaymentCurrencyAmount; | 51 using payments::mojom::blink::PaymentCurrencyAmount; |
| 51 using payments::mojom::blink::PaymentCurrencyAmountPtr; | 52 using payments::mojom::blink::PaymentCurrencyAmountPtr; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 shippingOptionOutput, executionContext, | 515 shippingOptionOutput, executionContext, |
| 515 exceptionState); | 516 exceptionState); |
| 516 if (exceptionState.hadException()) | 517 if (exceptionState.hadException()) |
| 517 return; | 518 return; |
| 518 | 519 |
| 519 if (!input.hasTotal()) { | 520 if (!input.hasTotal()) { |
| 520 exceptionState.throwTypeError("Must specify total"); | 521 exceptionState.throwTypeError("Must specify total"); |
| 521 return; | 522 return; |
| 522 } | 523 } |
| 523 | 524 |
| 525 if (input.id().isEmpty()) |
| 526 output->id = createCanonicalUUIDString(); |
| 527 |
| 524 validateAndConvertTotal(input.total(), output->total, exceptionState); | 528 validateAndConvertTotal(input.total(), output->total, exceptionState); |
| 525 } | 529 } |
| 526 | 530 |
| 527 void validateAndConvertPaymentDetailsUpdate(const PaymentDetailsUpdate& input, | 531 void validateAndConvertPaymentDetailsUpdate(const PaymentDetailsUpdate& input, |
| 528 bool requestShipping, | 532 bool requestShipping, |
| 529 PaymentDetailsPtr& output, | 533 PaymentDetailsPtr& output, |
| 530 String& shippingOptionOutput, | 534 String& shippingOptionOutput, |
| 531 ExecutionContext& executionContext, | 535 ExecutionContext& executionContext, |
| 532 ExceptionState& exceptionState) { | 536 ExceptionState& exceptionState) { |
| 533 validateAndConvertPaymentDetailsBase(input, requestShipping, output, | 537 validateAndConvertPaymentDetailsBase(input, requestShipping, output, |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 } | 880 } |
| 877 | 881 |
| 878 PaymentDetailsPtr validatedDetails = | 882 PaymentDetailsPtr validatedDetails = |
| 879 payments::mojom::blink::PaymentDetails::New(); | 883 payments::mojom::blink::PaymentDetails::New(); |
| 880 validateAndConvertPaymentDetailsInit(details, m_options.requestShipping(), | 884 validateAndConvertPaymentDetailsInit(details, m_options.requestShipping(), |
| 881 validatedDetails, m_shippingOption, | 885 validatedDetails, m_shippingOption, |
| 882 *getExecutionContext(), exceptionState); | 886 *getExecutionContext(), exceptionState); |
| 883 if (exceptionState.hadException()) | 887 if (exceptionState.hadException()) |
| 884 return; | 888 return; |
| 885 | 889 |
| 890 m_id = validatedDetails->id; |
| 891 |
| 886 if (m_options.requestShipping()) | 892 if (m_options.requestShipping()) |
| 887 m_shippingType = getValidShippingType(m_options.shippingType()); | 893 m_shippingType = getValidShippingType(m_options.shippingType()); |
| 888 | 894 |
| 889 frame()->interfaceProvider()->getInterface( | 895 frame()->interfaceProvider()->getInterface( |
| 890 mojo::MakeRequest(&m_paymentProvider)); | 896 mojo::MakeRequest(&m_paymentProvider)); |
| 891 m_paymentProvider.set_connection_error_handler(convertToBaseCallback( | 897 m_paymentProvider.set_connection_error_handler(convertToBaseCallback( |
| 892 WTF::bind(&PaymentRequest::OnError, wrapWeakPersistent(this), | 898 WTF::bind(&PaymentRequest::OnError, wrapWeakPersistent(this), |
| 893 PaymentErrorReason::UNKNOWN))); | 899 PaymentErrorReason::UNKNOWN))); |
| 894 m_paymentProvider->Init( | 900 m_paymentProvider->Init( |
| 895 m_clientBinding.CreateInterfacePtrAndBind(), | 901 m_clientBinding.CreateInterfacePtrAndBind(), |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 m_completeResolver.clear(); | 1078 m_completeResolver.clear(); |
| 1073 m_showResolver.clear(); | 1079 m_showResolver.clear(); |
| 1074 m_abortResolver.clear(); | 1080 m_abortResolver.clear(); |
| 1075 m_canMakePaymentResolver.clear(); | 1081 m_canMakePaymentResolver.clear(); |
| 1076 if (m_clientBinding.is_bound()) | 1082 if (m_clientBinding.is_bound()) |
| 1077 m_clientBinding.Close(); | 1083 m_clientBinding.Close(); |
| 1078 m_paymentProvider.reset(); | 1084 m_paymentProvider.reset(); |
| 1079 } | 1085 } |
| 1080 | 1086 |
| 1081 } // namespace blink | 1087 } // namespace blink |
| OLD | NEW |