OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 14 matching lines...) Expand all Loading... |
25 // All methods must be called on the UI thread. | 25 // All methods must be called on the UI thread. |
26 // | 26 // |
27 // Design Doc: | 27 // Design Doc: |
28 // https://docs.google.com/document/d/1rWsvKQAwIboN2ZDuYYAkfce8GF27twi4UHTt0hc
byxQ/edit?usp=sharing | 28 // https://docs.google.com/document/d/1rWsvKQAwIboN2ZDuYYAkfce8GF27twi4UHTt0hc
byxQ/edit?usp=sharing |
29 class CONTENT_EXPORT PaymentAppProvider { | 29 class CONTENT_EXPORT PaymentAppProvider { |
30 public: | 30 public: |
31 // This static function is actually implemented in PaymentAppProviderImpl.cc. | 31 // This static function is actually implemented in PaymentAppProviderImpl.cc. |
32 // Please see: content/browser/payments/payment_app_provider_impl.cc | 32 // Please see: content/browser/payments/payment_app_provider_impl.cc |
33 static PaymentAppProvider* GetInstance(); | 33 static PaymentAppProvider* GetInstance(); |
34 | 34 |
35 // The ManifestWithID is a pair of the service worker registration id and | |
36 // the payment app manifest data associated with it. | |
37 using ManifestWithID = | |
38 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; | |
39 using Manifests = std::vector<ManifestWithID>; | |
40 | |
41 using Instruments = std::vector<std::unique_ptr<StoredPaymentInstrument>>; | 35 using Instruments = std::vector<std::unique_ptr<StoredPaymentInstrument>>; |
42 using PaymentApps = std::map<GURL, Instruments>; | 36 using PaymentApps = std::map<GURL, Instruments>; |
43 | 37 |
44 // TODO(zino): Consider to use base::OnceCallback instead of base::Callback. | |
45 // Please see: http://crbug.com/704193 | |
46 using GetAllManifestsCallback = base::Callback<void(Manifests)>; | |
47 using GetAllPaymentAppsCallback = base::OnceCallback<void(PaymentApps)>; | 38 using GetAllPaymentAppsCallback = base::OnceCallback<void(PaymentApps)>; |
48 using InvokePaymentAppCallback = | 39 using InvokePaymentAppCallback = |
49 base::Callback<void(payments::mojom::PaymentAppResponsePtr)>; | 40 base::Callback<void(payments::mojom::PaymentAppResponsePtr)>; |
50 | 41 |
51 // Should be accessed only on the UI thread. | 42 // Should be accessed only on the UI thread. |
52 virtual void GetAllManifests(BrowserContext* browser_context, | |
53 const GetAllManifestsCallback& callback) = 0; | |
54 virtual void GetAllPaymentApps(BrowserContext* browser_context, | 43 virtual void GetAllPaymentApps(BrowserContext* browser_context, |
55 GetAllPaymentAppsCallback callback) = 0; | 44 GetAllPaymentAppsCallback callback) = 0; |
56 virtual void InvokePaymentApp( | 45 virtual void InvokePaymentApp( |
57 BrowserContext* browser_context, | 46 BrowserContext* browser_context, |
58 int64_t registration_id, | 47 int64_t registration_id, |
59 payments::mojom::PaymentAppRequestPtr app_request, | 48 payments::mojom::PaymentAppRequestPtr app_request, |
60 const InvokePaymentAppCallback& callback) = 0; | 49 const InvokePaymentAppCallback& callback) = 0; |
61 | 50 |
62 protected: | 51 protected: |
63 virtual ~PaymentAppProvider() {} | 52 virtual ~PaymentAppProvider() {} |
64 }; | 53 }; |
65 | 54 |
66 } // namespace content | 55 } // namespace content |
67 | 56 |
68 #endif // CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ | 57 #endif // CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ |
OLD | NEW |