| 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()) { | 483 if ((m_options.requestPayerEmail() && response->payer_email.isEmpty()) |
| 484 || (m_options.requestPayerPhone() && response->payer_phone.isEmpty()) |
| 485 || (!m_options.requestPayerEmail() && !response->payer_email.isNull()) |
| 486 || (!m_options.requestPayerPhone() && !response->payer_phone.isNull()))
{ |
| 484 m_showResolver->reject(DOMException::create(SyntaxError)); | 487 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 485 clearResolversAndCloseMojoConnection(); | 488 clearResolversAndCloseMojoConnection(); |
| 486 return; | 489 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 } | 490 } |
| 506 | 491 |
| 507 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 492 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
| 508 | 493 |
| 509 // Do not close the mojo connection here. The merchant website should call | 494 // Do not close the mojo connection here. The merchant website should call |
| 510 // PaymentResponse::complete(boolean), which will be forwarded over the mojo | 495 // PaymentResponse::complete(boolean), which will be forwarded over the mojo |
| 511 // connection to display a success or failure message to the user. | 496 // connection to display a success or failure message to the user. |
| 512 m_showResolver.clear(); | 497 m_showResolver.clear(); |
| 513 } | 498 } |
| 514 | 499 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 { | 535 { |
| 551 m_completeResolver.clear(); | 536 m_completeResolver.clear(); |
| 552 m_showResolver.clear(); | 537 m_showResolver.clear(); |
| 553 m_abortResolver.clear(); | 538 m_abortResolver.clear(); |
| 554 if (m_clientBinding.is_bound()) | 539 if (m_clientBinding.is_bound()) |
| 555 m_clientBinding.Close(); | 540 m_clientBinding.Close(); |
| 556 m_paymentProvider.reset(); | 541 m_paymentProvider.reset(); |
| 557 } | 542 } |
| 558 | 543 |
| 559 } // namespace blink | 544 } // namespace blink |
| OLD | NEW |