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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); | 468 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); |
| 469 m_shippingOption = response->shipping_option_id; | 469 m_shippingOption = response->shipping_option_id; |
| 470 } else { | 470 } else { |
| 471 if (response->shipping_address) { | 471 if (response->shipping_address) { |
| 472 m_showResolver->reject(DOMException::create(SyntaxError)); | 472 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 473 clearResolversAndCloseMojoConnection(); | 473 clearResolversAndCloseMojoConnection(); |
| 474 return; | 474 return; |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 if (m_options.requestPayerEmail() && response->payer_email.isEmpty()) { | |
| 479 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 480 clearResolversAndCloseMojoConnection(); | |
| 481 return; | |
| 482 } | |
|
please use gerrit instead
2016/06/10 17:46:51
Let's follow the convention of the shipping addres
| |
| 483 | |
| 484 if (m_options.requestPayerPhone() && response->payer_phone.isEmpty()) { | |
| 485 m_showResolver->reject(DOMException::create(SyntaxError)); | |
| 486 clearResolversAndCloseMojoConnection(); | |
| 487 return; | |
| 488 } | |
| 489 | |
| 478 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 490 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
| 479 | 491 |
| 480 // Do not close the mojo connection here. The merchant website should call | 492 // Do not close the mojo connection here. The merchant website should call |
| 481 // PaymentResponse::complete(boolean), which will be forwarded over the mojo | 493 // PaymentResponse::complete(boolean), which will be forwarded over the mojo |
| 482 // connection to display a success or failure message to the user. | 494 // connection to display a success or failure message to the user. |
| 483 m_showResolver.clear(); | 495 m_showResolver.clear(); |
| 484 } | 496 } |
| 485 | 497 |
| 486 void PaymentRequest::OnError() | 498 void PaymentRequest::OnError() |
| 487 { | 499 { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 502 void PaymentRequest::clearResolversAndCloseMojoConnection() | 514 void PaymentRequest::clearResolversAndCloseMojoConnection() |
| 503 { | 515 { |
| 504 m_completeResolver.clear(); | 516 m_completeResolver.clear(); |
| 505 m_showResolver.clear(); | 517 m_showResolver.clear(); |
| 506 if (m_clientBinding.is_bound()) | 518 if (m_clientBinding.is_bound()) |
| 507 m_clientBinding.Close(); | 519 m_clientBinding.Close(); |
| 508 m_paymentProvider.reset(); | 520 m_paymentProvider.reset(); |
| 509 } | 521 } |
| 510 | 522 |
| 511 } // namespace blink | 523 } // namespace blink |
| OLD | NEW |