blob: 40f1c18fcdda237baa26c3ef146db793cfa12d18 [file] [log] [blame]
Rouslan Solomakhin6d4c1c272019-11-22 17:09:271// 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 Solomakhin85beea02020-08-16 13:45:3117namespace content {
18class BrowserContext;
19} // namespace content
20
Rouslan Solomakhin6d4c1c272019-11-22 17:09:2721namespace payments {
22
23// Retrieves payment apps of all types.
24class PaymentAppService : public KeyedService {
25 public:
Rouslan Solomakhin85beea02020-08-16 13:45:3126 // The |context| pointer is not being saved.
27 explicit PaymentAppService(content::BrowserContext* context);
Rouslan Solomakhin6d4c1c272019-11-22 17:09:2728 ~PaymentAppService() override;
29
Danyao Wange865a302020-04-01 18:35:1430 // 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 Solomakhin6d4c1c272019-11-22 17:09:2737
Rouslan Solomakhin375926f2020-06-09 16:49:5338 // KeyedService implementation:
39 void Shutdown() override;
40
Rouslan Solomakhin6d4c1c272019-11-22 17:09:2741 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_