| 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 "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8StringResource.h" | 10 #include "bindings/core/v8/V8StringResource.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 351 |
| 352 String errorMessage; | 352 String errorMessage; |
| 353 if (!PaymentsValidators::isValidErrorMsgFormat(details.error(), | 353 if (!PaymentsValidators::isValidErrorMsgFormat(details.error(), |
| 354 &errorMessage)) { | 354 &errorMessage)) { |
| 355 exceptionState.throwTypeError(errorMessage); | 355 exceptionState.throwTypeError(errorMessage); |
| 356 } | 356 } |
| 357 | 357 |
| 358 return keepShippingOptions; | 358 return keepShippingOptions; |
| 359 } | 359 } |
| 360 | 360 |
| 361 void maybeSetAndroidPayMethodata( | 361 void maybeSetAndroidPayMethodData( |
| 362 const ScriptValue& input, | 362 const ScriptValue& input, |
| 363 payments::mojom::blink::PaymentMethodDataPtr& output) { | 363 payments::mojom::blink::PaymentMethodDataPtr& output, |
| 364 ExceptionState& exceptionState) { |
| 364 AndroidPayMethodData androidPay; | 365 AndroidPayMethodData androidPay; |
| 365 TrackExceptionState exceptionState; | 366 TrackExceptionState trackExceptionState; |
| 366 V8AndroidPayMethodData::toImpl(input.isolate(), input.v8Value(), androidPay, | 367 V8AndroidPayMethodData::toImpl(input.isolate(), input.v8Value(), androidPay, |
| 367 exceptionState); | 368 trackExceptionState); |
| 368 if (exceptionState.hadException()) | 369 if (trackExceptionState.hadException()) |
| 369 return; | 370 return; |
| 370 | 371 |
| 371 if (androidPay.hasEnvironment() && androidPay.environment() == "TEST") | 372 if (androidPay.hasEnvironment() && androidPay.environment() == "TEST") |
| 372 output->environment = payments::mojom::blink::AndroidPayEnvironment::TEST; | 373 output->environment = payments::mojom::blink::AndroidPayEnvironment::TEST; |
| 373 | 374 |
| 374 output->merchant_name = androidPay.merchantName(); | 375 output->merchant_name = androidPay.merchantName(); |
| 375 output->merchant_id = androidPay.merchantId(); | 376 output->merchant_id = androidPay.merchantId(); |
| 376 | 377 |
| 377 if (androidPay.hasAllowedCardNetworks()) { | 378 if (androidPay.hasAllowedCardNetworks()) { |
| 378 output->allowed_card_networks.resize( | 379 output->allowed_card_networks.resize( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 399 for (size_t j = 0; j < arraysize(kAndroidPayTokenization); ++j) { | 400 for (size_t j = 0; j < arraysize(kAndroidPayTokenization); ++j) { |
| 400 if (tokenization.tokenizationType() == | 401 if (tokenization.tokenizationType() == |
| 401 kAndroidPayTokenization[j].name) { | 402 kAndroidPayTokenization[j].name) { |
| 402 output->tokenization_type = kAndroidPayTokenization[j].code; | 403 output->tokenization_type = kAndroidPayTokenization[j].code; |
| 403 break; | 404 break; |
| 404 } | 405 } |
| 405 } | 406 } |
| 406 } | 407 } |
| 407 | 408 |
| 408 if (tokenization.hasParameters()) { | 409 if (tokenization.hasParameters()) { |
| 409 Vector<String> keys; | 410 const Vector<String>& keys = |
| 410 tokenization.parameters().getPropertyNames(keys); | 411 tokenization.parameters().getPropertyNames(exceptionState); |
| 412 if (exceptionState.hadException()) |
| 413 return; |
| 411 output->parameters.resize(keys.size()); | 414 output->parameters.resize(keys.size()); |
| 412 size_t numberOfParameters = 0; | 415 size_t numberOfParameters = 0; |
| 413 String value; | 416 String value; |
| 414 for (size_t i = 0; i < keys.size(); ++i) { | 417 for (size_t i = 0; i < keys.size(); ++i) { |
| 415 if (!DictionaryHelper::get(tokenization.parameters(), keys[i], value)) | 418 if (!DictionaryHelper::get(tokenization.parameters(), keys[i], value)) |
| 416 continue; | 419 continue; |
| 417 output->parameters[numberOfParameters] = | 420 output->parameters[numberOfParameters] = |
| 418 payments::mojom::blink::AndroidPayTokenizationParameter::New(); | 421 payments::mojom::blink::AndroidPayTokenizationParameter::New(); |
| 419 output->parameters[numberOfParameters]->key = keys[i]; | 422 output->parameters[numberOfParameters]->key = keys[i]; |
| 420 output->parameters[numberOfParameters]->value = value; | 423 output->parameters[numberOfParameters]->value = value; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 "Unable to parse payment method specific data"); | 465 "Unable to parse payment method specific data"); |
| 463 return; | 466 return; |
| 464 } | 467 } |
| 465 stringifiedData = | 468 stringifiedData = |
| 466 v8StringToWebCoreString<String>(value, DoNotExternalize); | 469 v8StringToWebCoreString<String>(value, DoNotExternalize); |
| 467 } | 470 } |
| 468 | 471 |
| 469 output[i] = payments::mojom::blink::PaymentMethodData::New(); | 472 output[i] = payments::mojom::blink::PaymentMethodData::New(); |
| 470 output[i]->supported_methods = paymentMethodData.supportedMethods(); | 473 output[i]->supported_methods = paymentMethodData.supportedMethods(); |
| 471 output[i]->stringified_data = stringifiedData; | 474 output[i]->stringified_data = stringifiedData; |
| 472 maybeSetAndroidPayMethodata(paymentMethodData.data(), output[i]); | 475 maybeSetAndroidPayMethodData(paymentMethodData.data(), output[i], |
| 476 exceptionState); |
| 477 if (exceptionState.hadException()) |
| 478 return; |
| 473 } | 479 } |
| 474 } | 480 } |
| 475 | 481 |
| 476 String getSelectedShippingOption(const PaymentDetails& details) { | 482 String getSelectedShippingOption(const PaymentDetails& details) { |
| 477 String result; | 483 String result; |
| 478 if (!details.hasShippingOptions()) | 484 if (!details.hasShippingOptions()) |
| 479 return result; | 485 return result; |
| 480 | 486 |
| 481 for (int i = details.shippingOptions().size() - 1; i >= 0; --i) { | 487 for (int i = details.shippingOptions().size() - 1; i >= 0; --i) { |
| 482 if (details.shippingOptions()[i].hasSelected() && | 488 if (details.shippingOptions()[i].hasSelected() && |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 m_completeResolver.clear(); | 972 m_completeResolver.clear(); |
| 967 m_showResolver.clear(); | 973 m_showResolver.clear(); |
| 968 m_abortResolver.clear(); | 974 m_abortResolver.clear(); |
| 969 m_canMakeActivePaymentResolver.clear(); | 975 m_canMakeActivePaymentResolver.clear(); |
| 970 if (m_clientBinding.is_bound()) | 976 if (m_clientBinding.is_bound()) |
| 971 m_clientBinding.Close(); | 977 m_clientBinding.Close(); |
| 972 m_paymentProvider.reset(); | 978 m_paymentProvider.reset(); |
| 973 } | 979 } |
| 974 | 980 |
| 975 } // namespace blink | 981 } // namespace blink |
| OLD | NEW |