| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 ScriptPromise PaymentRequest::show(ScriptState* scriptState) | 282 ScriptPromise PaymentRequest::show(ScriptState* scriptState) |
| 283 { | 283 { |
| 284 if (m_showResolver) | 284 if (m_showResolver) |
| 285 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called show() once")); | 285 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called show() once")); |
| 286 | 286 |
| 287 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) | 287 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) |
| 288 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot show the payment request")); | 288 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot show the payment request")); |
| 289 | 289 |
| 290 DCHECK(!m_paymentProvider.is_bound()); | 290 DCHECK(!m_paymentProvider.is_bound()); |
| 291 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService
(mojo::GetProxy(&m_paymentProvider)); | 291 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService
(mojo::GetProxy(&m_paymentProvider)); |
| 292 m_paymentProvider.set_connection_error_handler(createBaseCallback(bind(&Paym
entRequest::OnError, WeakPersistentThisPointer<PaymentRequest>(this)))); | 292 m_paymentProvider.set_connection_error_handler(createBaseCallback(bind(&Paym
entRequest::OnError, wrapWeakPersistent(this)))); |
| 293 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); | 293 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); |
| 294 m_paymentProvider->Show(mojo::WTFArray<mojom::blink::PaymentMethodDataPtr>::
From(m_methodData), mojom::blink::PaymentDetails::From(m_details), mojom::blink:
:PaymentOptions::From(m_options)); | 294 m_paymentProvider->Show(mojo::WTFArray<mojom::blink::PaymentMethodDataPtr>::
From(m_methodData), mojom::blink::PaymentDetails::From(m_details), mojom::blink:
:PaymentOptions::From(m_options)); |
| 295 | 295 |
| 296 m_showResolver = ScriptPromiseResolver::create(scriptState); | 296 m_showResolver = ScriptPromiseResolver::create(scriptState); |
| 297 return m_showResolver->promise(); | 297 return m_showResolver->promise(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) | 300 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) |
| 301 { | 301 { |
| 302 if (m_abortResolver) | 302 if (m_abortResolver) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 { | 541 { |
| 542 m_completeResolver.clear(); | 542 m_completeResolver.clear(); |
| 543 m_showResolver.clear(); | 543 m_showResolver.clear(); |
| 544 m_abortResolver.clear(); | 544 m_abortResolver.clear(); |
| 545 if (m_clientBinding.is_bound()) | 545 if (m_clientBinding.is_bound()) |
| 546 m_clientBinding.Close(); | 546 m_clientBinding.Close(); |
| 547 m_paymentProvider.reset(); | 547 m_paymentProvider.reset(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 } // namespace blink | 550 } // namespace blink |
| OLD | NEW |