| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 const AtomicString& PaymentRequest::interfaceName() const | 308 const AtomicString& PaymentRequest::interfaceName() const |
| 309 { | 309 { |
| 310 return EventTargetNames::PaymentRequest; | 310 return EventTargetNames::PaymentRequest; |
| 311 } | 311 } |
| 312 | 312 |
| 313 ExecutionContext* PaymentRequest::getExecutionContext() const | 313 ExecutionContext* PaymentRequest::getExecutionContext() const |
| 314 { | 314 { |
| 315 return ContextLifecycleObserver::getExecutionContext(); | 315 return ContextLifecycleObserver::getExecutionContext(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, bool success) | 318 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, const PaymentCo
mplete result) |
| 319 { | 319 { |
| 320 if (m_completeResolver) | 320 if (m_completeResolver) |
| 321 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called complete() once")); | 321 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called complete() once")); |
| 322 | 322 |
| 323 // The payment provider should respond in PaymentRequest::OnComplete(). | 323 // The payment provider should respond in PaymentRequest::OnComplete(). |
| 324 m_paymentProvider->Complete(success); | 324 m_paymentProvider->Complete(mojom::blink::PaymentComplete(result)); |
| 325 | 325 |
| 326 m_completeResolver = ScriptPromiseResolver::create(scriptState); | 326 m_completeResolver = ScriptPromiseResolver::create(scriptState); |
| 327 return m_completeResolver->promise(); | 327 return m_completeResolver->promise(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void PaymentRequest::onUpdatePaymentDetails(const ScriptValue& detailsScriptValu
e) | 330 void PaymentRequest::onUpdatePaymentDetails(const ScriptValue& detailsScriptValu
e) |
| 331 { | 331 { |
| 332 if (!m_showResolver || !m_paymentProvider) | 332 if (!m_showResolver || !m_paymentProvider) |
| 333 return; | 333 return; |
| 334 | 334 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 void PaymentRequest::clearResolversAndCloseMojoConnection() | 503 void PaymentRequest::clearResolversAndCloseMojoConnection() |
| 504 { | 504 { |
| 505 m_completeResolver.clear(); | 505 m_completeResolver.clear(); |
| 506 m_showResolver.clear(); | 506 m_showResolver.clear(); |
| 507 if (m_clientBinding.is_bound()) | 507 if (m_clientBinding.is_bound()) |
| 508 m_clientBinding.Close(); | 508 m_clientBinding.Close(); |
| 509 m_paymentProvider.reset(); | 509 m_paymentProvider.reset(); |
| 510 } | 510 } |
| 511 | 511 |
| 512 } // namespace blink | 512 } // namespace blink |
| OLD | NEW |