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

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

Issue 2196843003: Blink ServiceRegistry -> InterfaceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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 "bindings/modules/v8/V8PaymentDetails.h" 11 #include "bindings/modules/v8/V8PaymentDetails.h"
12 #include "core/EventTypeNames.h" 12 #include "core/EventTypeNames.h"
13 #include "core/dom/DOMException.h" 13 #include "core/dom/DOMException.h"
14 #include "core/dom/ExceptionCode.h" 14 #include "core/dom/ExceptionCode.h"
15 #include "core/events/Event.h" 15 #include "core/events/Event.h"
16 #include "core/events/EventQueue.h" 16 #include "core/events/EventQueue.h"
17 #include "modules/EventTargetModulesNames.h" 17 #include "modules/EventTargetModulesNames.h"
18 #include "modules/payments/PaymentAddress.h" 18 #include "modules/payments/PaymentAddress.h"
19 #include "modules/payments/PaymentItem.h" 19 #include "modules/payments/PaymentItem.h"
20 #include "modules/payments/PaymentRequestUpdateEvent.h" 20 #include "modules/payments/PaymentRequestUpdateEvent.h"
21 #include "modules/payments/PaymentResponse.h" 21 #include "modules/payments/PaymentResponse.h"
22 #include "modules/payments/PaymentShippingOption.h" 22 #include "modules/payments/PaymentShippingOption.h"
23 #include "modules/payments/PaymentsValidators.h" 23 #include "modules/payments/PaymentsValidators.h"
24 #include "mojo/public/cpp/bindings/interface_request.h" 24 #include "mojo/public/cpp/bindings/interface_request.h"
25 #include "mojo/public/cpp/bindings/wtf_array.h" 25 #include "mojo/public/cpp/bindings/wtf_array.h"
26 #include "platform/mojo/MojoHelper.h" 26 #include "platform/mojo/MojoHelper.h"
27 #include "public/platform/ServiceRegistry.h" 27 #include "public/platform/InterfaceProvider.h"
28 #include "wtf/HashSet.h" 28 #include "wtf/HashSet.h"
29 #include <utility> 29 #include <utility>
30 30
31 namespace mojo { 31 namespace mojo {
32 32
33 using blink::mojom::blink::PaymentCurrencyAmount; 33 using blink::mojom::blink::PaymentCurrencyAmount;
34 using blink::mojom::blink::PaymentCurrencyAmountPtr; 34 using blink::mojom::blink::PaymentCurrencyAmountPtr;
35 using blink::mojom::blink::PaymentDetails; 35 using blink::mojom::blink::PaymentDetails;
36 using blink::mojom::blink::PaymentDetailsModifier; 36 using blink::mojom::blink::PaymentDetailsModifier;
37 using blink::mojom::blink::PaymentDetailsModifierPtr; 37 using blink::mojom::blink::PaymentDetailsModifierPtr;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 ScriptPromise PaymentRequest::show(ScriptState* scriptState) 375 ScriptPromise PaymentRequest::show(ScriptState* scriptState)
376 { 376 {
377 if (m_showResolver) 377 if (m_showResolver)
378 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Already called show() once")); 378 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Already called show() once"));
379 379
380 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) 380 if (!scriptState->domWindow() || !scriptState->domWindow()->frame())
381 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Cannot show the payment request")); 381 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Cannot show the payment request"));
382 382
383 DCHECK(!m_paymentProvider.is_bound()); 383 DCHECK(!m_paymentProvider.is_bound());
384 scriptState->domWindow()->frame()->serviceRegistry()->connectToRemoteService (mojo::GetProxy(&m_paymentProvider)); 384 scriptState->domWindow()->frame()->interfaceProvider()->getInterface(mojo::G etProxy(&m_paymentProvider));
385 m_paymentProvider.set_connection_error_handler(convertToBaseCallback(WTF::bi nd(&PaymentRequest::OnError, wrapWeakPersistent(this), mojom::blink::PaymentErro rReason::UNKNOWN))); 385 m_paymentProvider.set_connection_error_handler(convertToBaseCallback(WTF::bi nd(&PaymentRequest::OnError, wrapWeakPersistent(this), mojom::blink::PaymentErro rReason::UNKNOWN)));
386 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); 386 m_paymentProvider->SetClient(m_clientBinding.CreateInterfacePtrAndBind());
387 m_paymentProvider->Show(mojo::WTFArray<mojom::blink::PaymentMethodDataPtr>:: From(m_methodData), mojom::blink::PaymentDetails::From(m_details), mojom::blink: :PaymentOptions::From(m_options)); 387 m_paymentProvider->Show(mojo::WTFArray<mojom::blink::PaymentMethodDataPtr>:: From(m_methodData), mojom::blink::PaymentDetails::From(m_details), mojom::blink: :PaymentOptions::From(m_options));
388 388
389 m_showResolver = ScriptPromiseResolver::create(scriptState); 389 m_showResolver = ScriptPromiseResolver::create(scriptState);
390 return m_showResolver->promise(); 390 return m_showResolver->promise();
391 } 391 }
392 392
393 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) 393 ScriptPromise PaymentRequest::abort(ScriptState* scriptState)
394 { 394 {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 { 673 {
674 m_completeResolver.clear(); 674 m_completeResolver.clear();
675 m_showResolver.clear(); 675 m_showResolver.clear();
676 m_abortResolver.clear(); 676 m_abortResolver.clear();
677 if (m_clientBinding.is_bound()) 677 if (m_clientBinding.is_bound())
678 m_clientBinding.Close(); 678 m_clientBinding.Close();
679 m_paymentProvider.reset(); 679 m_paymentProvider.reset();
680 } 680 }
681 681
682 } // namespace blink 682 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698