| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/payments/payment_app_manager.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/optional.h" | |
| 11 #include "content/browser/payments/payment_app.pb.h" | |
| 12 #include "content/browser/payments/payment_app_context_impl.h" | |
| 13 #include "content/browser/payments/payment_app_database.h" | |
| 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | |
| 15 #include "content/browser/service_worker/service_worker_registration.h" | |
| 16 #include "content/public/browser/browser_thread.h" | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 PaymentAppManager::~PaymentAppManager() { | |
| 21 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 22 } | |
| 23 | |
| 24 PaymentAppManager::PaymentAppManager( | |
| 25 PaymentAppContextImpl* payment_app_context, | |
| 26 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request) | |
| 27 : payment_app_context_(payment_app_context), | |
| 28 binding_(this, std::move(request)), | |
| 29 weak_ptr_factory_(this) { | |
| 30 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 31 DCHECK(payment_app_context); | |
| 32 | |
| 33 binding_.set_connection_error_handler( | |
| 34 base::Bind(&PaymentAppManager::OnConnectionError, | |
| 35 base::Unretained(this))); | |
| 36 } | |
| 37 | |
| 38 void PaymentAppManager::Init(const std::string& scope) { | |
| 39 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 40 scope_ = GURL(scope); | |
| 41 } | |
| 42 | |
| 43 void PaymentAppManager::SetManifest( | |
| 44 payments::mojom::PaymentAppManifestPtr manifest, | |
| 45 const SetManifestCallback& callback) { | |
| 46 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 47 | |
| 48 // TODO(zino): Should implement requesting a permission for users to allow | |
| 49 // the payment app to be registered. Please see http://crbug.com/665949. | |
| 50 | |
| 51 payment_app_context_->payment_app_database()->WriteManifest( | |
| 52 scope_, std::move(manifest), callback); | |
| 53 } | |
| 54 | |
| 55 void PaymentAppManager::GetManifest(const GetManifestCallback& callback) { | |
| 56 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 57 | |
| 58 payment_app_context_->payment_app_database()->ReadManifest(scope_, callback); | |
| 59 } | |
| 60 | |
| 61 void PaymentAppManager::OnConnectionError() { | |
| 62 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 63 payment_app_context_->PaymentAppManagerHadConnectionError(this); | |
| 64 } | |
| 65 | |
| 66 } // namespace content | |
| OLD | NEW |