| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "content/browser/payments/payment_app_provider_impl.h" |
| |
| #include "content/browser/payments/payment_app_context_impl.h" |
| #include "content/browser/storage_partition_impl.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| |
| namespace content { |
| namespace { |
| |
| void DidGetAllManifestsOnIO( |
| const PaymentAppProvider::GetAllManifestsCallback& callback, |
| PaymentAppProvider::Manifests manifests) { |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| base::Bind(callback, base::Passed(std::move(manifests)))); |
| } |
| |
| void GetAllManifestsOnIO( |
| const scoped_refptr<PaymentAppContextImpl>& payment_app_context, |
| const PaymentAppProvider::GetAllManifestsCallback& callback) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| |
| payment_app_context->payment_app_database()->ReadAllManifests( |
| base::Bind(&DidGetAllManifestsOnIO, callback)); |
| } |
| |
| } // namespace |
| |
| // static |
| PaymentAppProvider* PaymentAppProvider::GetInstance() { |
| return PaymentAppProviderImpl::GetInstance(); |
| } |
| |
| // static |
| PaymentAppProviderImpl* PaymentAppProviderImpl::GetInstance() { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| return base::Singleton<PaymentAppProviderImpl>::get(); |
| } |
| |
| void PaymentAppProviderImpl::GetAllManifests( |
| BrowserContext* browser_context, |
| const GetAllManifestsCallback& callback) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| |
| StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| BrowserContext::GetDefaultStoragePartition(browser_context)); |
| scoped_refptr<PaymentAppContextImpl> payment_app_context = |
| partition->GetPaymentAppContext(); |
| |
| BrowserThread::PostTask( |
| BrowserThread::IO, FROM_HERE, |
| base::Bind(&GetAllManifestsOnIO, payment_app_context, callback)); |
| } |
| |
| void PaymentAppProviderImpl::InvokePaymentApp( |
| BrowserContext* browser_context, |
| int64_t registration_id, |
| payments::mojom::PaymentAppRequestDataPtr data) { |
| NOTIMPLEMENTED(); |
| } |
| |
| PaymentAppProviderImpl::PaymentAppProviderImpl() {} |
| |
| PaymentAppProviderImpl::~PaymentAppProviderImpl() {} |
| |
| } // namespace content |