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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 const AtomicString& PaymentRequest::interfaceName() const | 311 const AtomicString& PaymentRequest::interfaceName() const |
312 { | 312 { |
313 return EventTargetNames::PaymentRequest; | 313 return EventTargetNames::PaymentRequest; |
314 } | 314 } |
315 | 315 |
316 ExecutionContext* PaymentRequest::getExecutionContext() const | 316 ExecutionContext* PaymentRequest::getExecutionContext() const |
317 { | 317 { |
318 return ContextLifecycleObserver::getExecutionContext(); | 318 return ContextLifecycleObserver::getExecutionContext(); |
319 } | 319 } |
320 | 320 |
321 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, bool success) | 321 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, const PaymentCo
mplete result) |
322 { | 322 { |
323 if (m_completeResolver) | 323 if (m_completeResolver) |
324 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called complete() once")); | 324 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called complete() once")); |
325 | 325 |
326 // The payment provider should respond in PaymentRequest::OnComplete(). | 326 // The payment provider should respond in PaymentRequest::OnComplete(). |
327 m_paymentProvider->Complete(success); | 327 m_paymentProvider->Complete(mojom::blink::PaymentComplete(result)); |
328 | 328 |
329 m_completeResolver = ScriptPromiseResolver::create(scriptState); | 329 m_completeResolver = ScriptPromiseResolver::create(scriptState); |
330 return m_completeResolver->promise(); | 330 return m_completeResolver->promise(); |
331 } | 331 } |
332 | 332 |
333 void PaymentRequest::onUpdatePaymentDetails(const ScriptValue& detailsScriptValu
e) | 333 void PaymentRequest::onUpdatePaymentDetails(const ScriptValue& detailsScriptValu
e) |
334 { | 334 { |
335 if (!m_showResolver || !m_paymentProvider) | 335 if (!m_showResolver || !m_paymentProvider) |
336 return; | 336 return; |
337 | 337 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 { | 526 { |
527 m_completeResolver.clear(); | 527 m_completeResolver.clear(); |
528 m_showResolver.clear(); | 528 m_showResolver.clear(); |
529 m_abortResolver.clear(); | 529 m_abortResolver.clear(); |
530 if (m_clientBinding.is_bound()) | 530 if (m_clientBinding.is_bound()) |
531 m_clientBinding.Close(); | 531 m_clientBinding.Close(); |
532 m_paymentProvider.reset(); | 532 m_paymentProvider.reset(); |
533 } | 533 } |
534 | 534 |
535 } // namespace blink | 535 } // namespace blink |
OLD | NEW |