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

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

Issue 2775343002: PaymentHandler: Initial implementation for PaymentInstruments. (Closed)
Patch Set: PaymentHandler: Initial implementation for PaymentInstruments. Created 3 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/PaymentManager.h" 5 #include "modules/payments/PaymentManager.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "modules/payments/PaymentAppManifest.h" 10 #include "modules/payments/PaymentAppManifest.h"
11 #include "modules/payments/PaymentAppOption.h" 11 #include "modules/payments/PaymentAppOption.h"
12 #include "modules/payments/PaymentInstruments.h"
12 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 13 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
13 #include "platform/mojo/MojoHelper.h" 14 #include "platform/mojo/MojoHelper.h"
14 #include "public/platform/InterfaceProvider.h" 15 #include "public/platform/InterfaceProvider.h"
15 #include "public/platform/Platform.h" 16 #include "public/platform/Platform.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 19
19 using payments::mojom::blink::PaymentAppManifest; 20 using payments::mojom::blink::PaymentAppManifest;
20 using payments::mojom::blink::PaymentAppManifestPtr; 21 using payments::mojom::blink::PaymentAppManifestPtr;
21 using payments::mojom::blink::PaymentAppOption; 22 using payments::mojom::blink::PaymentAppOption;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 122 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
122 ScriptPromise promise = resolver->promise(); 123 ScriptPromise promise = resolver->promise();
123 124
124 m_manager->GetManifest(convertToBaseCallback( 125 m_manager->GetManifest(convertToBaseCallback(
125 WTF::bind(&PaymentManager::onGetManifest, wrapPersistent(this), 126 WTF::bind(&PaymentManager::onGetManifest, wrapPersistent(this),
126 wrapPersistent(resolver)))); 127 wrapPersistent(resolver))));
127 128
128 return promise; 129 return promise;
129 } 130 }
130 131
132 PaymentInstruments* PaymentManager::instruments() {
133 if (!m_instruments) {
please use gerrit instead 2017/03/29 21:30:16 No need for {} in a single-line if statement body.
zino 2017/03/30 00:12:53 Done.
134 m_instruments = new PaymentInstruments();
135 }
136 return m_instruments;
137 }
138
131 DEFINE_TRACE(PaymentManager) { 139 DEFINE_TRACE(PaymentManager) {
132 visitor->trace(m_registration); 140 visitor->trace(m_registration);
141 visitor->trace(m_instruments);
133 } 142 }
134 143
135 PaymentManager::PaymentManager(ServiceWorkerRegistration* registration) 144 PaymentManager::PaymentManager(ServiceWorkerRegistration* registration)
136 : m_registration(registration) { 145 : m_registration(registration), m_instruments(nullptr) {
137 DCHECK(registration); 146 DCHECK(registration);
138 Platform::current()->interfaceProvider()->getInterface( 147 Platform::current()->interfaceProvider()->getInterface(
139 mojo::MakeRequest(&m_manager)); 148 mojo::MakeRequest(&m_manager));
140 149
141 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind( 150 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind(
142 &PaymentManager::onServiceConnectionError, wrapWeakPersistent(this)))); 151 &PaymentManager::onServiceConnectionError, wrapWeakPersistent(this))));
143 152
144 m_manager->Init(m_registration->scope()); 153 m_manager->Init(m_registration->scope());
145 } 154 }
146 155
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 "No payment app manifest associated with the service worker.")); 199 "No payment app manifest associated with the service worker."));
191 break; 200 break;
192 } 201 }
193 } 202 }
194 203
195 void PaymentManager::onServiceConnectionError() { 204 void PaymentManager::onServiceConnectionError() {
196 m_manager.reset(); 205 m_manager.reset();
197 } 206 }
198 207
199 } // namespace blink 208 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698