| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot abort() again until the previous abort() has r
esolved or rejected")); | 401 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot abort() again until the previous abort() has r
esolved or rejected")); |
| 402 | 402 |
| 403 if (!m_showResolver) | 403 if (!m_showResolver) |
| 404 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Never called show(), so nothing to abort")); | 404 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Never called show(), so nothing to abort")); |
| 405 | 405 |
| 406 m_abortResolver = ScriptPromiseResolver::create(scriptState); | 406 m_abortResolver = ScriptPromiseResolver::create(scriptState); |
| 407 m_paymentProvider->Abort(); | 407 m_paymentProvider->Abort(); |
| 408 return m_abortResolver->promise(); | 408 return m_abortResolver->promise(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool PaymentRequest::hasPendingActivity() const |
| 412 { |
| 413 return m_showResolver || m_completeResolver; |
| 414 } |
| 415 |
| 411 const AtomicString& PaymentRequest::interfaceName() const | 416 const AtomicString& PaymentRequest::interfaceName() const |
| 412 { | 417 { |
| 413 return EventTargetNames::PaymentRequest; | 418 return EventTargetNames::PaymentRequest; |
| 414 } | 419 } |
| 415 | 420 |
| 416 ExecutionContext* PaymentRequest::getExecutionContext() const | 421 ExecutionContext* PaymentRequest::getExecutionContext() const |
| 417 { | 422 { |
| 418 return ContextLifecycleObserver::getExecutionContext(); | 423 return ContextLifecycleObserver::getExecutionContext(); |
| 419 } | 424 } |
| 420 | 425 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 526 |
| 522 if (m_options.requestShipping()) | 527 if (m_options.requestShipping()) |
| 523 m_shippingOption = getSelectedShippingOption(details); | 528 m_shippingOption = getSelectedShippingOption(details); |
| 524 } | 529 } |
| 525 | 530 |
| 526 void PaymentRequest::contextDestroyed() | 531 void PaymentRequest::contextDestroyed() |
| 527 { | 532 { |
| 528 clearResolversAndCloseMojoConnection(); | 533 clearResolversAndCloseMojoConnection(); |
| 529 } | 534 } |
| 530 | 535 |
| 531 bool PaymentRequest::hasPendingActivity() const | |
| 532 { | |
| 533 return m_showResolver || m_completeResolver; | |
| 534 } | |
| 535 | |
| 536 void PaymentRequest::OnShippingAddressChange(mojom::blink::PaymentAddressPtr add
ress) | 536 void PaymentRequest::OnShippingAddressChange(mojom::blink::PaymentAddressPtr add
ress) |
| 537 { | 537 { |
| 538 DCHECK(m_showResolver); | 538 DCHECK(m_showResolver); |
| 539 DCHECK(!m_completeResolver); | 539 DCHECK(!m_completeResolver); |
| 540 | 540 |
| 541 String errorMessage; | 541 String errorMessage; |
| 542 if (!PaymentsValidators::isValidShippingAddress(address, &errorMessage)) { | 542 if (!PaymentsValidators::isValidShippingAddress(address, &errorMessage)) { |
| 543 m_showResolver->reject(DOMException::create(SyntaxError, errorMessage)); | 543 m_showResolver->reject(DOMException::create(SyntaxError, errorMessage)); |
| 544 clearResolversAndCloseMojoConnection(); | 544 clearResolversAndCloseMojoConnection(); |
| 545 return; | 545 return; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 m_completeTimer.stop(); | 697 m_completeTimer.stop(); |
| 698 m_completeResolver.clear(); | 698 m_completeResolver.clear(); |
| 699 m_showResolver.clear(); | 699 m_showResolver.clear(); |
| 700 m_abortResolver.clear(); | 700 m_abortResolver.clear(); |
| 701 if (m_clientBinding.is_bound()) | 701 if (m_clientBinding.is_bound()) |
| 702 m_clientBinding.Close(); | 702 m_clientBinding.Close(); |
| 703 m_paymentProvider.reset(); | 703 m_paymentProvider.reset(); |
| 704 } | 704 } |
| 705 | 705 |
| 706 } // namespace blink | 706 } // namespace blink |
| OLD | NEW |