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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/stored_payment_instrument.h" | 15 #include "content/public/browser/stored_payment_app.h" |
16 #include "third_party/WebKit/public/platform/modules/payments/payment_app.mojom.
h" | 16 #include "third_party/WebKit/public/platform/modules/payments/payment_app.mojom.
h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class BrowserContext; | 20 class BrowserContext; |
21 | 21 |
22 // This is providing the service worker based payment app related APIs to | 22 // This is providing the service worker based payment app related APIs to |
23 // Chrome layer. This class is a singleton, the instance of which can be | 23 // Chrome layer. This class is a singleton, the instance of which can be |
24 // retrieved using the static GetInstance() method. | 24 // retrieved using the static GetInstance() method. |
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 using Instruments = std::vector<std::unique_ptr<StoredPaymentInstrument>>; | 35 using PaymentApps = std::map<GURL, std::unique_ptr<StoredPaymentApp>>; |
36 using PaymentApps = std::map<GURL, Instruments>; | |
37 | |
38 using GetAllPaymentAppsCallback = base::OnceCallback<void(PaymentApps)>; | 36 using GetAllPaymentAppsCallback = base::OnceCallback<void(PaymentApps)>; |
39 using InvokePaymentAppCallback = | 37 using InvokePaymentAppCallback = |
40 base::Callback<void(payments::mojom::PaymentAppResponsePtr)>; | 38 base::Callback<void(payments::mojom::PaymentAppResponsePtr)>; |
41 | 39 |
42 // Should be accessed only on the UI thread. | 40 // Should be accessed only on the UI thread. |
43 virtual void GetAllPaymentApps(BrowserContext* browser_context, | 41 virtual void GetAllPaymentApps(BrowserContext* browser_context, |
44 GetAllPaymentAppsCallback callback) = 0; | 42 GetAllPaymentAppsCallback callback) = 0; |
45 virtual void InvokePaymentApp( | 43 virtual void InvokePaymentApp( |
46 BrowserContext* browser_context, | 44 BrowserContext* browser_context, |
47 int64_t registration_id, | 45 int64_t registration_id, |
48 payments::mojom::PaymentRequestEventDataPtr event_data, | 46 payments::mojom::PaymentRequestEventDataPtr event_data, |
49 const InvokePaymentAppCallback& callback) = 0; | 47 const InvokePaymentAppCallback& callback) = 0; |
50 | 48 |
51 protected: | 49 protected: |
52 virtual ~PaymentAppProvider() {} | 50 virtual ~PaymentAppProvider() {} |
53 }; | 51 }; |
54 | 52 |
55 } // namespace content | 53 } // namespace content |
56 | 54 |
57 #endif // CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ | 55 #endif // CONTENT_PUBLIC_BROWSER_PAYMENT_APP_PROVIDER_H_ |
OLD | NEW |