| 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone(
)); | 469 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone(
)); |
| 470 m_shippingOption = response->shipping_option_id; | 470 m_shippingOption = response->shipping_option_id; |
| 471 } else { | 471 } else { |
| 472 if (response->shipping_address) { | 472 if (response->shipping_address) { |
| 473 m_showResolver->reject(DOMException::create(SyntaxError)); | 473 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 474 clearResolversAndCloseMojoConnection(); | 474 clearResolversAndCloseMojoConnection(); |
| 475 return; | 475 return; |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 | 478 |
| 479 if (m_options.requestPayerEmail() && response->payer_email.isEmpty()) { |
| 480 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 481 clearResolversAndCloseMojoConnection(); |
| 482 return; |
| 483 } |
| 484 |
| 485 if (!m_options.requestPayerEmail() && !response->payer_email.isNull()) { |
| 486 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 487 clearResolversAndCloseMojoConnection(); |
| 488 return; |
| 489 } |
| 490 |
| 491 if (m_options.requestPayerPhone() && response->payer_phone.isEmpty()) { |
| 492 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 493 clearResolversAndCloseMojoConnection(); |
| 494 return; |
| 495 } |
| 496 |
| 497 if (!m_options.requestPayerPhone() && !response->payer_phone.isNull()) { |
| 498 m_showResolver->reject(DOMException::create(SyntaxError)); |
| 499 clearResolversAndCloseMojoConnection(); |
| 500 return; |
| 501 } |
| 502 |
| 479 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 503 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
| 480 | 504 |
| 481 // Do not close the mojo connection here. The merchant website should call | 505 // Do not close the mojo connection here. The merchant website should call |
| 482 // PaymentResponse::complete(boolean), which will be forwarded over the mojo | 506 // PaymentResponse::complete(boolean), which will be forwarded over the mojo |
| 483 // connection to display a success or failure message to the user. | 507 // connection to display a success or failure message to the user. |
| 484 m_showResolver.clear(); | 508 m_showResolver.clear(); |
| 485 } | 509 } |
| 486 | 510 |
| 487 void PaymentRequest::OnError() | 511 void PaymentRequest::OnError() |
| 488 { | 512 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 503 void PaymentRequest::clearResolversAndCloseMojoConnection() | 527 void PaymentRequest::clearResolversAndCloseMojoConnection() |
| 504 { | 528 { |
| 505 m_completeResolver.clear(); | 529 m_completeResolver.clear(); |
| 506 m_showResolver.clear(); | 530 m_showResolver.clear(); |
| 507 if (m_clientBinding.is_bound()) | 531 if (m_clientBinding.is_bound()) |
| 508 m_clientBinding.Close(); | 532 m_clientBinding.Close(); |
| 509 m_paymentProvider.reset(); | 533 m_paymentProvider.reset(); |
| 510 } | 534 } |
| 511 | 535 |
| 512 } // namespace blink | 536 } // namespace blink |
| OLD | NEW |