Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1179)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 1830883002: Add blink::ServiceRegistry and expose it from LocalFrame and Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "core/EventTypeNames.h" 11 #include "core/EventTypeNames.h"
12 #include "core/dom/DOMException.h" 12 #include "core/dom/DOMException.h"
13 #include "core/dom/ExceptionCode.h" 13 #include "core/dom/ExceptionCode.h"
14 #include "core/events/Event.h" 14 #include "core/events/Event.h"
15 #include "core/events/EventQueue.h" 15 #include "core/events/EventQueue.h"
16 #include "modules/EventTargetModulesNames.h" 16 #include "modules/EventTargetModulesNames.h"
17 #include "modules/payments/PaymentItem.h" 17 #include "modules/payments/PaymentItem.h"
18 #include "modules/payments/PaymentResponse.h" 18 #include "modules/payments/PaymentResponse.h"
19 #include "modules/payments/PaymentsValidators.h" 19 #include "modules/payments/PaymentsValidators.h"
20 #include "modules/payments/ShippingAddress.h" 20 #include "modules/payments/ShippingAddress.h"
21 #include "modules/payments/ShippingOption.h" 21 #include "modules/payments/ShippingOption.h"
22 #include "mojo/public/cpp/bindings/interface_request.h" 22 #include "mojo/public/cpp/bindings/interface_request.h"
23 #include "mojo/public/cpp/bindings/wtf_array.h" 23 #include "mojo/public/cpp/bindings/wtf_array.h"
24 #include "platform/MojoHelper.h" 24 #include "platform/MojoHelper.h"
25 #include "public/platform/Platform.h" 25 #include "public/platform/Platform.h"
26 #include "public/platform/ServiceRegistry.h"
26 #include <utility> 27 #include <utility>
27 28
28 namespace mojo { 29 namespace mojo {
29 30
30 template <> 31 template <>
31 struct TypeConverter<mojom::wtf::CurrencyAmountPtr, blink::CurrencyAmount> { 32 struct TypeConverter<mojom::wtf::CurrencyAmountPtr, blink::CurrencyAmount> {
32 static mojom::wtf::CurrencyAmountPtr Convert(const blink::CurrencyAmount& in put) 33 static mojom::wtf::CurrencyAmountPtr Convert(const blink::CurrencyAmount& in put)
33 { 34 {
34 mojom::wtf::CurrencyAmountPtr output = mojom::wtf::CurrencyAmount::New() ; 35 mojom::wtf::CurrencyAmountPtr output = mojom::wtf::CurrencyAmount::New() ;
35 output->currency_code = input.currencyCode(); 36 output->currency_code = input.currencyCode();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 PaymentRequest::~PaymentRequest() 155 PaymentRequest::~PaymentRequest()
155 { 156 {
156 } 157 }
157 158
158 ScriptPromise PaymentRequest::show(ScriptState* scriptState) 159 ScriptPromise PaymentRequest::show(ScriptState* scriptState)
159 { 160 {
160 if (m_showResolver) 161 if (m_showResolver)
161 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Already called show() once")); 162 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Already called show() once"));
162 163
163 DCHECK(!m_paymentProvider.is_bound()); 164 DCHECK(!m_paymentProvider.is_bound());
164 blink::Platform::current()->connectToRemoteService(mojo::GetProxy(&m_payment Provider)); 165 blink::Platform::current()->serviceRegistry()->connectToRemoteService(mojo:: GetProxy(&m_paymentProvider));
165 m_paymentProvider.set_connection_error_handler(sameThreadBindForMojo(&Paymen tRequest::OnError, this)); 166 m_paymentProvider.set_connection_error_handler(sameThreadBindForMojo(&Paymen tRequest::OnError, this));
166 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); 167 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind());
167 m_paymentProvider->Show(std::move(m_supportedMethods), mojom::wtf::PaymentDe tails::From(m_details), mojom::wtf::PaymentOptions::From(m_options), m_stringifi edData.isNull() ? "" : m_stringifiedData); 168 m_paymentProvider->Show(std::move(m_supportedMethods), mojom::wtf::PaymentDe tails::From(m_details), mojom::wtf::PaymentOptions::From(m_options), m_stringifi edData.isNull() ? "" : m_stringifiedData);
168 169
169 m_showResolver = ScriptPromiseResolver::create(scriptState); 170 m_showResolver = ScriptPromiseResolver::create(scriptState);
170 return m_showResolver->promise(); 171 return m_showResolver->promise();
171 } 172 }
172 173
173 void PaymentRequest::abort(ExceptionState& exceptionState) 174 void PaymentRequest::abort(ExceptionState& exceptionState)
174 { 175 {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 345
345 void PaymentRequest::cleanUp() 346 void PaymentRequest::cleanUp()
346 { 347 {
347 m_completeResolver.clear(); 348 m_completeResolver.clear();
348 m_showResolver.clear(); 349 m_showResolver.clear();
349 m_clientBinding.Close(); 350 m_clientBinding.Close();
350 m_paymentProvider.reset(); 351 m_paymentProvider.reset();
351 } 352 }
352 353
353 } // namespace blink 354 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698