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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); | 473 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); |
| 474 m_shippingOption = response->shipping_option_id; | 474 m_shippingOption = response->shipping_option_id; |
| 475 } else { | 475 } else { |
| 476 if (response->shipping_address) { | 476 if (response->shipping_address) { |
| 477 m_showResolver->reject(DOMException::create(SyntaxError)); | 477 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 478 clearResolversAndCloseMojoConnection(); | 478 clearResolversAndCloseMojoConnection(); |
| 479 return; | 479 return; |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 if (m_options.requestPayerEmail() && response->payer_email.isEmpty()) { | |
|
palmer
2016/06/16 21:23:34
Nit: This code is unnecessarily repetitive. Maybe
| |
| 484 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 485 clearResolversAndCloseMojoConnection(); | |
| 486 return; | |
| 487 } | |
| 488 | |
| 489 if (!m_options.requestPayerEmail() && !response->payer_email.isNull()) { | |
| 490 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 491 clearResolversAndCloseMojoConnection(); | |
| 492 return; | |
| 493 } | |
| 494 | |
| 495 if (m_options.requestPayerPhone() && response->payer_phone.isEmpty()) { | |
| 496 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 497 clearResolversAndCloseMojoConnection(); | |
| 498 return; | |
| 499 } | |
| 500 | |
| 501 if (!m_options.requestPayerPhone() && !response->payer_phone.isNull()) { | |
| 502 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 503 clearResolversAndCloseMojoConnection(); | |
| 504 return; | |
| 505 } | |
| 506 | |
| 483 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 507 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
| 484 | 508 |
| 485 // Do not close the mojo connection here. The merchant website should call | 509 // Do not close the mojo connection here. The merchant website should call |
| 486 // PaymentResponse::complete(boolean), which will be forwarded over the mojo | 510 // PaymentResponse::complete(boolean), which will be forwarded over the mojo |
| 487 // connection to display a success or failure message to the user. | 511 // connection to display a success or failure message to the user. |
| 488 m_showResolver.clear(); | 512 m_showResolver.clear(); |
| 489 } | 513 } |
| 490 | 514 |
| 491 void PaymentRequest::OnError() | 515 void PaymentRequest::OnError() |
| 492 { | 516 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 { | 550 { |
| 527 m_completeResolver.clear(); | 551 m_completeResolver.clear(); |
| 528 m_showResolver.clear(); | 552 m_showResolver.clear(); |
| 529 m_abortResolver.clear(); | 553 m_abortResolver.clear(); |
| 530 if (m_clientBinding.is_bound()) | 554 if (m_clientBinding.is_bound()) |
| 531 m_clientBinding.Close(); | 555 m_clientBinding.Close(); |
| 532 m_paymentProvider.reset(); | 556 m_paymentProvider.reset(); |
| 533 } | 557 } |
| 534 | 558 |
| 535 } // namespace blink | 559 } // namespace blink |
| OLD | NEW |