Rouslan Solomakhin | 6d4c1c27 | 2019-11-22 17:09:27 | [diff] [blame] | 1 | // Copyright 2019 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 | #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_APP_SERVICE_H_ |
| 6 | #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_APP_SERVICE_H_ |
| 7 | |
| 8 | #include <cstddef> |
| 9 | #include <memory> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include "base/macros.h" |
| 13 | #include "base/memory/weak_ptr.h" |
| 14 | #include "components/keyed_service/core/keyed_service.h" |
| 15 | #include "components/payments/content/payment_app_factory.h" |
| 16 | |
Rouslan Solomakhin | 85beea0 | 2020-08-16 13:45:31 | [diff] [blame] | 17 | namespace content { |
| 18 | class BrowserContext; |
| 19 | } // namespace content |
| 20 | |
Rouslan Solomakhin | 6d4c1c27 | 2019-11-22 17:09:27 | [diff] [blame] | 21 | namespace payments { |
| 22 | |
| 23 | // Retrieves payment apps of all types. |
| 24 | class PaymentAppService : public KeyedService { |
| 25 | public: |
Rouslan Solomakhin | 85beea0 | 2020-08-16 13:45:31 | [diff] [blame] | 26 | // The |context| pointer is not being saved. |
| 27 | explicit PaymentAppService(content::BrowserContext* context); |
Rouslan Solomakhin | 6d4c1c27 | 2019-11-22 17:09:27 | [diff] [blame] | 28 | ~PaymentAppService() override; |
| 29 | |
Danyao Wang | e865a30 | 2020-04-01 18:35:14 | [diff] [blame] | 30 | // Returns the number of payment app factories, which is the number of times |
| 31 | // that |delegate->OnDoneCreatingPaymentApps()| will be called as a result of |
| 32 | // Create(). |
| 33 | size_t GetNumberOfFactories() const; |
| 34 | |
| 35 | // Create payment apps for |delegate|. |
| 36 | void Create(base::WeakPtr<PaymentAppFactory::Delegate> delegate); |
Rouslan Solomakhin | 6d4c1c27 | 2019-11-22 17:09:27 | [diff] [blame] | 37 | |
Rouslan Solomakhin | 375926f | 2020-06-09 16:49:53 | [diff] [blame] | 38 | // KeyedService implementation: |
| 39 | void Shutdown() override; |
| 40 | |
Rouslan Solomakhin | 6d4c1c27 | 2019-11-22 17:09:27 | [diff] [blame] | 41 | private: |
| 42 | std::vector<std::unique_ptr<PaymentAppFactory>> factories_; |
| 43 | |
| 44 | DISALLOW_COPY_AND_ASSIGN(PaymentAppService); |
| 45 | }; |
| 46 | |
| 47 | } // namespace payments |
| 48 | |
| 49 | #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_APP_SERVICE_H_ |