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

Side by Side Diff: content/browser/payments/payment_app_provider_impl.cc

Issue 2873683002: PaymentHandler: Implement GetAllPaymentApps(). (Closed)
Patch Set: PaymentHandler: Implement GetAllPaymentApps(). Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/browser/payments/payment_app_provider_impl.h" 5 #include "content/browser/payments/payment_app_provider_impl.h"
6 6
7 #include "content/browser/payments/payment_app_context_impl.h" 7 #include "content/browser/payments/payment_app_context_impl.h"
8 #include "content/browser/service_worker/service_worker_context_wrapper.h" 8 #include "content/browser/service_worker/service_worker_context_wrapper.h"
9 #include "content/browser/service_worker/service_worker_metrics.h" 9 #include "content/browser/service_worker/service_worker_metrics.h"
10 #include "content/browser/service_worker/service_worker_version.h" 10 #include "content/browser/service_worker/service_worker_version.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 void GetAllManifestsOnIO( 67 void GetAllManifestsOnIO(
68 scoped_refptr<PaymentAppContextImpl> payment_app_context, 68 scoped_refptr<PaymentAppContextImpl> payment_app_context,
69 const PaymentAppProvider::GetAllManifestsCallback& callback) { 69 const PaymentAppProvider::GetAllManifestsCallback& callback) {
70 DCHECK_CURRENTLY_ON(BrowserThread::IO); 70 DCHECK_CURRENTLY_ON(BrowserThread::IO);
71 71
72 payment_app_context->payment_app_database()->ReadAllManifests( 72 payment_app_context->payment_app_database()->ReadAllManifests(
73 base::Bind(&DidGetAllManifestsOnIO, callback)); 73 base::Bind(&DidGetAllManifestsOnIO, callback));
74 } 74 }
75 75
76 void DidGetAllPaymentAppsOnIO(
77 PaymentAppProvider::GetAllPaymentAppsCallback callback,
78 PaymentAppProvider::PaymentApps apps) {
79 BrowserThread::PostTask(
80 BrowserThread::UI, FROM_HERE,
81 base::BindOnce(std::move(callback), base::Passed(std::move(apps))));
82 }
83
84 void GetAllPaymentAppsOnIO(
85 scoped_refptr<PaymentAppContextImpl> payment_app_context,
86 PaymentAppProvider::GetAllPaymentAppsCallback callback) {
87 DCHECK_CURRENTLY_ON(BrowserThread::IO);
88
89 payment_app_context->payment_app_database()->ReadAllPaymentApps(
90 base::BindOnce(&DidGetAllPaymentAppsOnIO, std::move(callback)));
91 }
92
76 void DispatchPaymentRequestEventError( 93 void DispatchPaymentRequestEventError(
77 ServiceWorkerStatusCode service_worker_status) { 94 ServiceWorkerStatusCode service_worker_status) {
78 NOTIMPLEMENTED(); 95 NOTIMPLEMENTED();
79 } 96 }
80 97
81 void DispatchPaymentRequestEvent( 98 void DispatchPaymentRequestEvent(
82 payments::mojom::PaymentAppRequestPtr app_request, 99 payments::mojom::PaymentAppRequestPtr app_request,
83 const PaymentAppProvider::InvokePaymentAppCallback& callback, 100 const PaymentAppProvider::InvokePaymentAppCallback& callback,
84 scoped_refptr<ServiceWorkerVersion> active_version) { 101 scoped_refptr<ServiceWorkerVersion> active_version) {
85 DCHECK_CURRENTLY_ON(BrowserThread::IO); 102 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( 173 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
157 BrowserContext::GetDefaultStoragePartition(browser_context)); 174 BrowserContext::GetDefaultStoragePartition(browser_context));
158 scoped_refptr<PaymentAppContextImpl> payment_app_context = 175 scoped_refptr<PaymentAppContextImpl> payment_app_context =
159 partition->GetPaymentAppContext(); 176 partition->GetPaymentAppContext();
160 177
161 BrowserThread::PostTask( 178 BrowserThread::PostTask(
162 BrowserThread::IO, FROM_HERE, 179 BrowserThread::IO, FROM_HERE,
163 base::Bind(&GetAllManifestsOnIO, payment_app_context, callback)); 180 base::Bind(&GetAllManifestsOnIO, payment_app_context, callback));
164 } 181 }
165 182
183 void PaymentAppProviderImpl::GetAllPaymentApps(
184 BrowserContext* browser_context,
185 GetAllPaymentAppsCallback callback) {
186 DCHECK_CURRENTLY_ON(BrowserThread::UI);
187
188 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
189 BrowserContext::GetDefaultStoragePartition(browser_context));
nasko 2017/05/09 22:46:44 Are payments supported in Chrome Apps? If yes, the
zino 2017/05/10 15:57:42 This feature shouldn't be supported in Chrome Apps
nasko 2017/05/11 21:45:39 If this is the case, do we block the API in the ca
zino 2017/05/12 20:59:21 Oh, I thought that the service worker is only allo
nasko 2017/05/12 21:12:10 chrome-extension: is likely treated as a secure co
190 scoped_refptr<PaymentAppContextImpl> payment_app_context =
191 partition->GetPaymentAppContext();
192
193 BrowserThread::PostTask(
194 BrowserThread::IO, FROM_HERE,
195 base::BindOnce(&GetAllPaymentAppsOnIO, payment_app_context,
196 std::move(callback)));
197 }
198
166 void PaymentAppProviderImpl::InvokePaymentApp( 199 void PaymentAppProviderImpl::InvokePaymentApp(
167 BrowserContext* browser_context, 200 BrowserContext* browser_context,
168 int64_t registration_id, 201 int64_t registration_id,
169 payments::mojom::PaymentAppRequestPtr app_request, 202 payments::mojom::PaymentAppRequestPtr app_request,
170 const InvokePaymentAppCallback& callback) { 203 const InvokePaymentAppCallback& callback) {
171 DCHECK_CURRENTLY_ON(BrowserThread::UI); 204 DCHECK_CURRENTLY_ON(BrowserThread::UI);
172 205
173 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( 206 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
174 BrowserContext::GetDefaultStoragePartition(browser_context)); 207 BrowserContext::GetDefaultStoragePartition(browser_context));
175 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = 208 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context =
176 partition->GetServiceWorkerContext(); 209 partition->GetServiceWorkerContext();
177 210
178 BrowserThread::PostTask( 211 BrowserThread::PostTask(
179 BrowserThread::IO, FROM_HERE, 212 BrowserThread::IO, FROM_HERE,
180 base::Bind(&FindRegistrationOnIO, std::move(service_worker_context), 213 base::Bind(&FindRegistrationOnIO, std::move(service_worker_context),
181 registration_id, base::Passed(std::move(app_request)), 214 registration_id, base::Passed(std::move(app_request)),
182 callback)); 215 callback));
183 } 216 }
184 217
185 PaymentAppProviderImpl::PaymentAppProviderImpl() {} 218 PaymentAppProviderImpl::PaymentAppProviderImpl() {}
186 219
187 PaymentAppProviderImpl::~PaymentAppProviderImpl() {} 220 PaymentAppProviderImpl::~PaymentAppProviderImpl() {}
188 221
189 } // namespace content 222 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698