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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); | 444 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); |
| 445 m_shippingOption = response->shipping_option_id; | 445 m_shippingOption = response->shipping_option_id; |
| 446 } else { | 446 } else { |
| 447 if (response->shipping_address) { | 447 if (response->shipping_address) { |
| 448 m_showResolver->reject(DOMException::create(SyntaxError)); | 448 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 449 clearResolversAndCloseMojoConnection(); | 449 clearResolversAndCloseMojoConnection(); |
| 450 return; | 450 return; |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 if (m_options.requestPayerEmail() && (response->payer_email.isNull() || resp onse->payer_email.isEmpty())) { | |
|
zino
2016/06/07 16:40:08
nit: Should be "if (m_options.requestPayerEmail()
| |
| 455 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 456 clearResolversAndCloseMojoConnection(); | |
| 457 return; | |
| 458 } | |
| 459 | |
| 460 if (m_options.requestPayerPhone() && (response->payer_phone.isNull() || resp onse->payer_phone.isEmpty())) { | |
|
zino
2016/06/07 16:40:08
ditto
| |
| 461 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 462 clearResolversAndCloseMojoConnection(); | |
| 463 return; | |
| 464 } | |
| 465 | |
| 454 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 466 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
| 455 | 467 |
| 456 // Do not close the mojo connection here. The merchant website should call | 468 // Do not close the mojo connection here. The merchant website should call |
| 457 // PaymentResponse::complete(boolean), which will be forwarded over the mojo | 469 // PaymentResponse::complete(boolean), which will be forwarded over the mojo |
| 458 // connection to display a success or failure message to the user. | 470 // connection to display a success or failure message to the user. |
| 459 m_showResolver.clear(); | 471 m_showResolver.clear(); |
| 460 } | 472 } |
| 461 | 473 |
| 462 void PaymentRequest::OnError() | 474 void PaymentRequest::OnError() |
| 463 { | 475 { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 478 void PaymentRequest::clearResolversAndCloseMojoConnection() | 490 void PaymentRequest::clearResolversAndCloseMojoConnection() |
| 479 { | 491 { |
| 480 m_completeResolver.clear(); | 492 m_completeResolver.clear(); |
| 481 m_showResolver.clear(); | 493 m_showResolver.clear(); |
| 482 if (m_clientBinding.is_bound()) | 494 if (m_clientBinding.is_bound()) |
| 483 m_clientBinding.Close(); | 495 m_clientBinding.Close(); |
| 484 m_paymentProvider.reset(); | 496 m_paymentProvider.reset(); |
| 485 } | 497 } |
| 486 | 498 |
| 487 } // namespace blink | 499 } // namespace blink |
| OLD | NEW |