| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 ScriptPromise PaymentRequest::show(ScriptState* scriptState) | 191 ScriptPromise PaymentRequest::show(ScriptState* scriptState) |
| 192 { | 192 { |
| 193 if (m_showResolver) | 193 if (m_showResolver) |
| 194 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called show() once")); | 194 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Already called show() once")); |
| 195 | 195 |
| 196 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) | 196 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) |
| 197 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot show the payment request")); | 197 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, "Cannot show the payment request")); |
| 198 | 198 |
| 199 DCHECK(!m_paymentProvider.is_bound()); | 199 DCHECK(!m_paymentProvider.is_bound()); |
| 200 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService
(mojo::GetProxy(&m_paymentProvider)); | 200 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService
(mojo::GetProxy(&m_paymentProvider)); |
| 201 m_paymentProvider.set_connection_error_handler(sameThreadBindForMojo(&Paymen
tRequest::OnError, this)); | 201 m_paymentProvider.set_connection_error_handler(createBaseCallback(bind(&Paym
entRequest::OnError, WeakPersistentThisPointer<PaymentRequest>(this)))); |
| 202 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); | 202 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); |
| 203 m_paymentProvider->Show(std::move(m_supportedMethods), mojom::blink::Payment
Details::From(m_details), mojom::blink::PaymentOptions::From(m_options), m_strin
gifiedData.isNull() ? "" : m_stringifiedData); | 203 m_paymentProvider->Show(std::move(m_supportedMethods), mojom::blink::Payment
Details::From(m_details), mojom::blink::PaymentOptions::From(m_options), m_strin
gifiedData.isNull() ? "" : m_stringifiedData); |
| 204 | 204 |
| 205 m_showResolver = ScriptPromiseResolver::create(scriptState); | 205 m_showResolver = ScriptPromiseResolver::create(scriptState); |
| 206 return m_showResolver->promise(); | 206 return m_showResolver->promise(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void PaymentRequest::abort(ExceptionState& exceptionState) | 209 void PaymentRequest::abort(ExceptionState& exceptionState) |
| 210 { | 210 { |
| 211 if (!m_showResolver) { | 211 if (!m_showResolver) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 void PaymentRequest::clearResolversAndCloseMojoConnection() | 433 void PaymentRequest::clearResolversAndCloseMojoConnection() |
| 434 { | 434 { |
| 435 m_completeResolver.clear(); | 435 m_completeResolver.clear(); |
| 436 m_showResolver.clear(); | 436 m_showResolver.clear(); |
| 437 if (m_clientBinding.is_bound()) | 437 if (m_clientBinding.is_bound()) |
| 438 m_clientBinding.Close(); | 438 m_clientBinding.Close(); |
| 439 m_paymentProvider.reset(); | 439 m_paymentProvider.reset(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace blink | 442 } // namespace blink |
| OLD | NEW |