Chromium Code Reviews| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 | 350 |
| 351 String errorMessage; | 351 String errorMessage; |
| 352 if (!PaymentsValidators::isValidErrorMsgFormat(details.error(), | 352 if (!PaymentsValidators::isValidErrorMsgFormat(details.error(), |
| 353 &errorMessage)) { | 353 &errorMessage)) { |
| 354 exceptionState.throwTypeError(errorMessage); | 354 exceptionState.throwTypeError(errorMessage); |
| 355 } | 355 } |
| 356 | 356 |
| 357 return keepShippingOptions; | 357 return keepShippingOptions; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void maybeSetAndroidPayMethodata( | 360 void maybeSetAndroidPayMethodData( |
| 361 const ScriptValue& input, | 361 const ScriptValue& input, |
| 362 payments::mojom::blink::PaymentMethodDataPtr& output) { | 362 payments::mojom::blink::PaymentMethodDataPtr& output, |
| 363 ExceptionState& exceptionState) { | |
| 363 AndroidPayMethodData androidPay; | 364 AndroidPayMethodData androidPay; |
| 364 TrackExceptionState exceptionState; | 365 TrackExceptionState trackExceptionState; |
|
haraken
2016/11/24 07:22:31
Why can't you use exceptionState here?
Yuki
2016/11/24 10:19:33
Reading the call site of this function, as "maybe"
haraken
2016/11/24 12:39:13
That sounds too arbitrary to me though. To keep th
Yuki
2016/11/25 08:31:04
Acknowledged.
| |
| 365 V8AndroidPayMethodData::toImpl(input.isolate(), input.v8Value(), androidPay, | 366 V8AndroidPayMethodData::toImpl(input.isolate(), input.v8Value(), androidPay, |
| 366 exceptionState); | 367 trackExceptionState); |
| 367 if (exceptionState.hadException()) | 368 if (trackExceptionState.hadException()) |
| 368 return; | 369 return; |
| 369 | 370 |
| 370 if (androidPay.hasEnvironment() && androidPay.environment() == "TEST") | 371 if (androidPay.hasEnvironment() && androidPay.environment() == "TEST") |
| 371 output->environment = payments::mojom::blink::AndroidPayEnvironment::TEST; | 372 output->environment = payments::mojom::blink::AndroidPayEnvironment::TEST; |
| 372 | 373 |
| 373 output->merchant_name = androidPay.merchantName(); | 374 output->merchant_name = androidPay.merchantName(); |
| 374 output->merchant_id = androidPay.merchantId(); | 375 output->merchant_id = androidPay.merchantId(); |
| 375 | 376 |
| 376 if (androidPay.hasAllowedCardNetworks()) { | 377 if (androidPay.hasAllowedCardNetworks()) { |
| 377 output->allowed_card_networks.resize( | 378 output->allowed_card_networks.resize( |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 399 if (tokenization.tokenizationType() == | 400 if (tokenization.tokenizationType() == |
| 400 kAndroidPayTokenization[j].name) { | 401 kAndroidPayTokenization[j].name) { |
| 401 output->tokenization_type = kAndroidPayTokenization[j].code; | 402 output->tokenization_type = kAndroidPayTokenization[j].code; |
| 402 break; | 403 break; |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 } | 406 } |
| 406 | 407 |
| 407 if (tokenization.hasParameters()) { | 408 if (tokenization.hasParameters()) { |
| 408 Vector<String> keys; | 409 Vector<String> keys; |
| 409 tokenization.parameters().getPropertyNames(keys); | 410 if (!tokenization.parameters().getPropertyNames(keys, exceptionState)) |
| 411 return; | |
| 410 output->parameters.resize(keys.size()); | 412 output->parameters.resize(keys.size()); |
| 411 size_t numberOfParameters = 0; | 413 size_t numberOfParameters = 0; |
| 412 String value; | 414 String value; |
| 413 for (size_t i = 0; i < keys.size(); ++i) { | 415 for (size_t i = 0; i < keys.size(); ++i) { |
| 414 if (!DictionaryHelper::get(tokenization.parameters(), keys[i], value)) | 416 if (!DictionaryHelper::get(tokenization.parameters(), keys[i], value)) |
| 415 continue; | 417 continue; |
| 416 output->parameters[numberOfParameters] = | 418 output->parameters[numberOfParameters] = |
| 417 payments::mojom::blink::AndroidPayTokenizationParameter::New(); | 419 payments::mojom::blink::AndroidPayTokenizationParameter::New(); |
| 418 output->parameters[numberOfParameters]->key = keys[i]; | 420 output->parameters[numberOfParameters]->key = keys[i]; |
| 419 output->parameters[numberOfParameters]->value = value; | 421 output->parameters[numberOfParameters]->value = value; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 "Unable to parse payment method specific data"); | 463 "Unable to parse payment method specific data"); |
| 462 return; | 464 return; |
| 463 } | 465 } |
| 464 stringifiedData = | 466 stringifiedData = |
| 465 v8StringToWebCoreString<String>(value, DoNotExternalize); | 467 v8StringToWebCoreString<String>(value, DoNotExternalize); |
| 466 } | 468 } |
| 467 | 469 |
| 468 output[i] = payments::mojom::blink::PaymentMethodData::New(); | 470 output[i] = payments::mojom::blink::PaymentMethodData::New(); |
| 469 output[i]->supported_methods = paymentMethodData.supportedMethods(); | 471 output[i]->supported_methods = paymentMethodData.supportedMethods(); |
| 470 output[i]->stringified_data = stringifiedData; | 472 output[i]->stringified_data = stringifiedData; |
| 471 maybeSetAndroidPayMethodata(paymentMethodData.data(), output[i]); | 473 maybeSetAndroidPayMethodData(paymentMethodData.data(), output[i], |
| 474 exceptionState); | |
| 475 if (exceptionState.hadException()) | |
| 476 return; | |
| 472 } | 477 } |
| 473 } | 478 } |
| 474 | 479 |
| 475 String getSelectedShippingOption(const PaymentDetails& details) { | 480 String getSelectedShippingOption(const PaymentDetails& details) { |
| 476 String result; | 481 String result; |
| 477 if (!details.hasShippingOptions()) | 482 if (!details.hasShippingOptions()) |
| 478 return result; | 483 return result; |
| 479 | 484 |
| 480 for (int i = details.shippingOptions().size() - 1; i >= 0; --i) { | 485 for (int i = details.shippingOptions().size() - 1; i >= 0; --i) { |
| 481 if (details.shippingOptions()[i].hasSelected() && | 486 if (details.shippingOptions()[i].hasSelected() && |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 m_completeResolver.clear(); | 968 m_completeResolver.clear(); |
| 964 m_showResolver.clear(); | 969 m_showResolver.clear(); |
| 965 m_abortResolver.clear(); | 970 m_abortResolver.clear(); |
| 966 m_canMakeActivePaymentResolver.clear(); | 971 m_canMakeActivePaymentResolver.clear(); |
| 967 if (m_clientBinding.is_bound()) | 972 if (m_clientBinding.is_bound()) |
| 968 m_clientBinding.Close(); | 973 m_clientBinding.Close(); |
| 969 m_paymentProvider.reset(); | 974 m_paymentProvider.reset(); |
| 970 } | 975 } |
| 971 | 976 |
| 972 } // namespace blink | 977 } // namespace blink |
| OLD | NEW |