| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 ScriptPromise PaymentRequest::show(ScriptState* scriptState) | 348 ScriptPromise PaymentRequest::show(ScriptState* scriptState) |
| 349 { | 349 { |
| 350 if (m_showResolver) | 350 if (m_showResolver) |
| 351 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called show() once")); | 351 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called show() once")); |
| 352 | 352 |
| 353 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) | 353 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) |
| 354 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot show the payment request")); | 354 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot show the payment request")); |
| 355 | 355 |
| 356 DCHECK(!m_paymentProvider.is_bound()); | 356 DCHECK(!m_paymentProvider.is_bound()); |
| 357 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService
(mojo::GetProxy(&m_paymentProvider)); | 357 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService
(mojo::GetProxy(&m_paymentProvider)); |
| 358 m_paymentProvider.set_connection_error_handler(createBaseCallback(bind(&Paym
entRequest::OnError, wrapWeakPersistent(this)))); | 358 m_paymentProvider.set_connection_error_handler(createBaseCallback(WTF::bind(
&PaymentRequest::OnError, wrapWeakPersistent(this)))); |
| 359 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); | 359 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); |
| 360 m_paymentProvider->Show(mojo::WTFArray<mojom::blink::PaymentMethodDataPtr>::
From(m_methodData), mojom::blink::PaymentDetails::From(m_details), mojom::blink:
:PaymentOptions::From(m_options)); | 360 m_paymentProvider->Show(mojo::WTFArray<mojom::blink::PaymentMethodDataPtr>::
From(m_methodData), mojom::blink::PaymentDetails::From(m_details), mojom::blink:
:PaymentOptions::From(m_options)); |
| 361 | 361 |
| 362 m_showResolver = ScriptPromiseResolver::create(scriptState); | 362 m_showResolver = ScriptPromiseResolver::create(scriptState); |
| 363 return m_showResolver->promise(); | 363 return m_showResolver->promise(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) | 366 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) |
| 367 { | 367 { |
| 368 if (m_abortResolver) | 368 if (m_abortResolver) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 { | 607 { |
| 608 m_completeResolver.clear(); | 608 m_completeResolver.clear(); |
| 609 m_showResolver.clear(); | 609 m_showResolver.clear(); |
| 610 m_abortResolver.clear(); | 610 m_abortResolver.clear(); |
| 611 if (m_clientBinding.is_bound()) | 611 if (m_clientBinding.is_bound()) |
| 612 m_clientBinding.Close(); | 612 m_clientBinding.Close(); |
| 613 m_paymentProvider.reset(); | 613 m_paymentProvider.reset(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 } // namespace blink | 616 } // namespace blink |
| OLD | NEW |