| OLD | NEW |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 service_worker_version_(service_worker_version), | 49 service_worker_version_(service_worker_version), |
| 50 callback_(callback), | 50 callback_(callback), |
| 51 binding_(this) {} | 51 binding_(this) {} |
| 52 | 52 |
| 53 int payment_request_id_; | 53 int payment_request_id_; |
| 54 scoped_refptr<ServiceWorkerVersion> service_worker_version_; | 54 scoped_refptr<ServiceWorkerVersion> service_worker_version_; |
| 55 const PaymentAppProvider::InvokePaymentAppCallback callback_; | 55 const PaymentAppProvider::InvokePaymentAppCallback callback_; |
| 56 mojo::Binding<payments::mojom::PaymentAppResponseCallback> binding_; | 56 mojo::Binding<payments::mojom::PaymentAppResponseCallback> binding_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 void DidGetAllManifestsOnIO( | |
| 60 const PaymentAppProvider::GetAllManifestsCallback& callback, | |
| 61 PaymentAppProvider::Manifests manifests) { | |
| 62 BrowserThread::PostTask( | |
| 63 BrowserThread::UI, FROM_HERE, | |
| 64 base::Bind(callback, base::Passed(std::move(manifests)))); | |
| 65 } | |
| 66 | |
| 67 void GetAllManifestsOnIO( | |
| 68 scoped_refptr<PaymentAppContextImpl> payment_app_context, | |
| 69 const PaymentAppProvider::GetAllManifestsCallback& callback) { | |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 71 | |
| 72 payment_app_context->payment_app_database()->ReadAllManifests( | |
| 73 base::Bind(&DidGetAllManifestsOnIO, callback)); | |
| 74 } | |
| 75 | |
| 76 void DidGetAllPaymentAppsOnIO( | 59 void DidGetAllPaymentAppsOnIO( |
| 77 PaymentAppProvider::GetAllPaymentAppsCallback callback, | 60 PaymentAppProvider::GetAllPaymentAppsCallback callback, |
| 78 PaymentAppProvider::PaymentApps apps) { | 61 PaymentAppProvider::PaymentApps apps) { |
| 79 BrowserThread::PostTask( | 62 BrowserThread::PostTask( |
| 80 BrowserThread::UI, FROM_HERE, | 63 BrowserThread::UI, FROM_HERE, |
| 81 base::BindOnce(std::move(callback), base::Passed(std::move(apps)))); | 64 base::BindOnce(std::move(callback), base::Passed(std::move(apps)))); |
| 82 } | 65 } |
| 83 | 66 |
| 84 void GetAllPaymentAppsOnIO( | 67 void GetAllPaymentAppsOnIO( |
| 85 scoped_refptr<PaymentAppContextImpl> payment_app_context, | 68 scoped_refptr<PaymentAppContextImpl> payment_app_context, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 PaymentAppProvider* PaymentAppProvider::GetInstance() { | 141 PaymentAppProvider* PaymentAppProvider::GetInstance() { |
| 159 return PaymentAppProviderImpl::GetInstance(); | 142 return PaymentAppProviderImpl::GetInstance(); |
| 160 } | 143 } |
| 161 | 144 |
| 162 // static | 145 // static |
| 163 PaymentAppProviderImpl* PaymentAppProviderImpl::GetInstance() { | 146 PaymentAppProviderImpl* PaymentAppProviderImpl::GetInstance() { |
| 164 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 147 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 165 return base::Singleton<PaymentAppProviderImpl>::get(); | 148 return base::Singleton<PaymentAppProviderImpl>::get(); |
| 166 } | 149 } |
| 167 | 150 |
| 168 void PaymentAppProviderImpl::GetAllManifests( | |
| 169 BrowserContext* browser_context, | |
| 170 const GetAllManifestsCallback& callback) { | |
| 171 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 172 | |
| 173 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | |
| 174 BrowserContext::GetDefaultStoragePartition(browser_context)); | |
| 175 scoped_refptr<PaymentAppContextImpl> payment_app_context = | |
| 176 partition->GetPaymentAppContext(); | |
| 177 | |
| 178 BrowserThread::PostTask( | |
| 179 BrowserThread::IO, FROM_HERE, | |
| 180 base::Bind(&GetAllManifestsOnIO, payment_app_context, callback)); | |
| 181 } | |
| 182 | |
| 183 void PaymentAppProviderImpl::GetAllPaymentApps( | 151 void PaymentAppProviderImpl::GetAllPaymentApps( |
| 184 BrowserContext* browser_context, | 152 BrowserContext* browser_context, |
| 185 GetAllPaymentAppsCallback callback) { | 153 GetAllPaymentAppsCallback callback) { |
| 186 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 154 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 187 | 155 |
| 188 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( | 156 StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 189 BrowserContext::GetDefaultStoragePartition(browser_context)); | 157 BrowserContext::GetDefaultStoragePartition(browser_context)); |
| 190 scoped_refptr<PaymentAppContextImpl> payment_app_context = | 158 scoped_refptr<PaymentAppContextImpl> payment_app_context = |
| 191 partition->GetPaymentAppContext(); | 159 partition->GetPaymentAppContext(); |
| 192 | 160 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 213 base::Bind(&FindRegistrationOnIO, std::move(service_worker_context), | 181 base::Bind(&FindRegistrationOnIO, std::move(service_worker_context), |
| 214 registration_id, base::Passed(std::move(app_request)), | 182 registration_id, base::Passed(std::move(app_request)), |
| 215 callback)); | 183 callback)); |
| 216 } | 184 } |
| 217 | 185 |
| 218 PaymentAppProviderImpl::PaymentAppProviderImpl() {} | 186 PaymentAppProviderImpl::PaymentAppProviderImpl() {} |
| 219 | 187 |
| 220 PaymentAppProviderImpl::~PaymentAppProviderImpl() {} | 188 PaymentAppProviderImpl::~PaymentAppProviderImpl() {} |
| 221 | 189 |
| 222 } // namespace content | 190 } // namespace content |
| OLD | NEW |