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/JSONValuesForV8.h" | 8 #include "bindings/core/v8/JSONValuesForV8.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); | 420 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); |
| 421 DCHECK(success); | 421 DCHECK(success); |
| 422 ALLOW_UNUSED_LOCAL(success); | 422 ALLOW_UNUSED_LOCAL(success); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void PaymentRequest::OnPaymentResponse(mojom::blink::PaymentResponsePtr response ) | 425 void PaymentRequest::OnPaymentResponse(mojom::blink::PaymentResponsePtr response ) |
| 426 { | 426 { |
| 427 DCHECK(m_showResolver); | 427 DCHECK(m_showResolver); |
| 428 DCHECK(!m_completeResolver); | 428 DCHECK(!m_completeResolver); |
| 429 | 429 |
| 430 if (response->shipping_address) { | 430 if (response->shipping_address) { |
|
please use gerrit instead
2016/06/06 01:09:34
void PaymentRequest::OnPaymentResponse(mojom::blin
zino
2016/06/06 10:02:13
Done.
| |
| 431 String errorMessage; | 431 String errorMessage; |
| 432 if (!PaymentsValidators::isValidShippingAddress(response->shipping_addre ss, &errorMessage)) { | 432 if (!PaymentsValidators::isValidShippingAddress(response->shipping_addre ss, &errorMessage)) { |
| 433 m_showResolver->reject(DOMException::create(SyntaxError, errorMessag e)); | 433 m_showResolver->reject(DOMException::create(SyntaxError, errorMessag e)); |
| 434 clearResolversAndCloseMojoConnection(); | 434 clearResolversAndCloseMojoConnection(); |
| 435 return; | 435 return; |
| 436 } | 436 } |
| 437 | 437 |
| 438 m_shippingAddress = new PaymentAddress(std::move(response->shipping_addr ess)); | 438 if (m_options.requestShipping()) |
|
please use gerrit instead
2016/06/06 01:09:34
Replace this block with:
m_shippingAddress = new
zino
2016/06/06 10:02:13
Done.
| |
| 439 m_shippingAddress = new PaymentAddress(response->shipping_address->C lone()); | |
| 440 else | |
| 441 m_shippingAddress = new PaymentAddress(std::move(response->shipping_ address)); | |
| 442 | |
| 439 m_shippingOption = response->shipping_option_id; | 443 m_shippingOption = response->shipping_option_id; |
| 440 } | 444 } |
| 441 | 445 |
| 442 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 446 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
| 443 | 447 |
| 444 // Do not close the mojo connection here. The merchant website should call | 448 // Do not close the mojo connection here. The merchant website should call |
| 445 // PaymentResponse::complete(boolean), which will be forwarded over the mojo | 449 // PaymentResponse::complete(boolean), which will be forwarded over the mojo |
| 446 // connection to display a success or failure message to the user. | 450 // connection to display a success or failure message to the user. |
| 447 m_showResolver.clear(); | 451 m_showResolver.clear(); |
| 448 } | 452 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 466 void PaymentRequest::clearResolversAndCloseMojoConnection() | 470 void PaymentRequest::clearResolversAndCloseMojoConnection() |
| 467 { | 471 { |
| 468 m_completeResolver.clear(); | 472 m_completeResolver.clear(); |
| 469 m_showResolver.clear(); | 473 m_showResolver.clear(); |
| 470 if (m_clientBinding.is_bound()) | 474 if (m_clientBinding.is_bound()) |
| 471 m_clientBinding.Close(); | 475 m_clientBinding.Close(); |
| 472 m_paymentProvider.reset(); | 476 m_paymentProvider.reset(); |
| 473 } | 477 } |
| 474 | 478 |
| 475 } // namespace blink | 479 } // namespace blink |
| OLD | NEW |