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_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "components/payments/mojom/payment_app.mojom.h" | 14 #include "components/payments/mojom/payment_app.mojom.h" |
14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
15 #include "content/browser/service_worker/service_worker_registration.h" | 16 #include "content/browser/service_worker/service_worker_registration.h" |
16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
17 #include "content/common/service_worker/service_worker_status_code.h" | 18 #include "content/common/service_worker/service_worker_status_code.h" |
| 19 #include "content/public/browser/payment_instrument.h" |
18 #include "mojo/public/cpp/bindings/binding.h" | 20 #include "mojo/public/cpp/bindings/binding.h" |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 class ServiceWorkerRegistration; | 24 class ServiceWorkerRegistration; |
23 | 25 |
24 class CONTENT_EXPORT PaymentAppDatabase { | 26 class CONTENT_EXPORT PaymentAppDatabase { |
25 public: | 27 public: |
26 using WriteManifestCallback = | 28 using WriteManifestCallback = |
27 base::OnceCallback<void(payments::mojom::PaymentAppManifestError)>; | 29 base::OnceCallback<void(payments::mojom::PaymentAppManifestError)>; |
28 using ReadManifestCallback = | 30 using ReadManifestCallback = |
29 base::OnceCallback<void(payments::mojom::PaymentAppManifestPtr, | 31 base::OnceCallback<void(payments::mojom::PaymentAppManifestPtr, |
30 payments::mojom::PaymentAppManifestError)>; | 32 payments::mojom::PaymentAppManifestError)>; |
31 using ManifestWithID = | 33 using ManifestWithID = |
32 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; | 34 std::pair<int64_t, payments::mojom::PaymentAppManifestPtr>; |
33 using Manifests = std::vector<ManifestWithID>; | 35 using Manifests = std::vector<ManifestWithID>; |
34 using ReadAllManifestsCallback = base::OnceCallback<void(Manifests)>; | 36 using ReadAllManifestsCallback = base::OnceCallback<void(Manifests)>; |
| 37 |
| 38 using Instruments = std::vector<std::unique_ptr<PaymentInstrument>>; |
| 39 using PaymentApps = std::map<GURL, Instruments>; |
| 40 using ReadAllPaymentAppsCallback = base::OnceCallback<void(PaymentApps)>; |
| 41 |
35 using DeletePaymentInstrumentCallback = | 42 using DeletePaymentInstrumentCallback = |
36 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; | 43 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
37 using ReadPaymentInstrumentCallback = | 44 using ReadPaymentInstrumentCallback = |
38 base::OnceCallback<void(payments::mojom::PaymentInstrumentPtr, | 45 base::OnceCallback<void(payments::mojom::PaymentInstrumentPtr, |
39 payments::mojom::PaymentHandlerStatus)>; | 46 payments::mojom::PaymentHandlerStatus)>; |
40 using KeysOfPaymentInstrumentsCallback = | 47 using KeysOfPaymentInstrumentsCallback = |
41 base::OnceCallback<void(const std::vector<std::string>&, | 48 base::OnceCallback<void(const std::vector<std::string>&, |
42 payments::mojom::PaymentHandlerStatus)>; | 49 payments::mojom::PaymentHandlerStatus)>; |
43 using HasPaymentInstrumentCallback = | 50 using HasPaymentInstrumentCallback = |
44 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; | 51 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
45 using WritePaymentInstrumentCallback = | 52 using WritePaymentInstrumentCallback = |
46 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; | 53 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
47 using ClearPaymentInstrumentsCallback = | 54 using ClearPaymentInstrumentsCallback = |
48 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; | 55 base::OnceCallback<void(payments::mojom::PaymentHandlerStatus)>; |
49 | 56 |
50 explicit PaymentAppDatabase( | 57 explicit PaymentAppDatabase( |
51 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 58 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
52 ~PaymentAppDatabase(); | 59 ~PaymentAppDatabase(); |
53 | 60 |
54 void WriteManifest(const GURL& scope, | 61 void WriteManifest(const GURL& scope, |
55 payments::mojom::PaymentAppManifestPtr manifest, | 62 payments::mojom::PaymentAppManifestPtr manifest, |
56 WriteManifestCallback callback); | 63 WriteManifestCallback callback); |
57 void ReadManifest(const GURL& scope, ReadManifestCallback callback); | 64 void ReadManifest(const GURL& scope, ReadManifestCallback callback); |
58 void ReadAllManifests(ReadAllManifestsCallback callback); | 65 void ReadAllManifests(ReadAllManifestsCallback callback); |
| 66 |
| 67 void ReadAllPaymentApps(ReadAllPaymentAppsCallback callback); |
| 68 |
59 void DeletePaymentInstrument(const GURL& scope, | 69 void DeletePaymentInstrument(const GURL& scope, |
60 const std::string& instrument_key, | 70 const std::string& instrument_key, |
61 DeletePaymentInstrumentCallback callback); | 71 DeletePaymentInstrumentCallback callback); |
62 void ReadPaymentInstrument(const GURL& scope, | 72 void ReadPaymentInstrument(const GURL& scope, |
63 const std::string& instrument_key, | 73 const std::string& instrument_key, |
64 ReadPaymentInstrumentCallback callback); | 74 ReadPaymentInstrumentCallback callback); |
65 void KeysOfPaymentInstruments(const GURL& scope, | 75 void KeysOfPaymentInstruments(const GURL& scope, |
66 KeysOfPaymentInstrumentsCallback callback); | 76 KeysOfPaymentInstrumentsCallback callback); |
67 void HasPaymentInstrument(const GURL& scope, | 77 void HasPaymentInstrument(const GURL& scope, |
68 const std::string& instrument_key, | 78 const std::string& instrument_key, |
(...skipping 23 matching lines...) Expand all Loading... |
92 void DidReadManifest(ReadManifestCallback callback, | 102 void DidReadManifest(ReadManifestCallback callback, |
93 const std::vector<std::string>& data, | 103 const std::vector<std::string>& data, |
94 ServiceWorkerStatusCode status); | 104 ServiceWorkerStatusCode status); |
95 | 105 |
96 // ReadAllManifests callbacks | 106 // ReadAllManifests callbacks |
97 void DidReadAllManifests( | 107 void DidReadAllManifests( |
98 ReadAllManifestsCallback callback, | 108 ReadAllManifestsCallback callback, |
99 const std::vector<std::pair<int64_t, std::string>>& raw_data, | 109 const std::vector<std::pair<int64_t, std::string>>& raw_data, |
100 ServiceWorkerStatusCode status); | 110 ServiceWorkerStatusCode status); |
101 | 111 |
| 112 // ReadAllPaymentApps callbacks |
| 113 void DidReadAllPaymentApps( |
| 114 ReadAllPaymentAppsCallback callback, |
| 115 const std::vector<std::pair<int64_t, std::string>>& raw_data, |
| 116 ServiceWorkerStatusCode status); |
| 117 |
102 // DeletePaymentInstrument callbacks | 118 // DeletePaymentInstrument callbacks |
103 void DidFindRegistrationToDeletePaymentInstrument( | 119 void DidFindRegistrationToDeletePaymentInstrument( |
104 const std::string& instrument_key, | 120 const std::string& instrument_key, |
105 DeletePaymentInstrumentCallback callback, | 121 DeletePaymentInstrumentCallback callback, |
106 ServiceWorkerStatusCode status, | 122 ServiceWorkerStatusCode status, |
107 scoped_refptr<ServiceWorkerRegistration> registration); | 123 scoped_refptr<ServiceWorkerRegistration> registration); |
108 void DidFindPaymentInstrument(int64_t registration_id, | 124 void DidFindPaymentInstrument(int64_t registration_id, |
109 const std::string& instrument_key, | 125 const std::string& instrument_key, |
110 DeletePaymentInstrumentCallback callback, | 126 DeletePaymentInstrumentCallback callback, |
111 const std::vector<std::string>& data, | 127 const std::vector<std::string>& data, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 186 |
171 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 187 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
172 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; | 188 base::WeakPtrFactory<PaymentAppDatabase> weak_ptr_factory_; |
173 | 189 |
174 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); | 190 DISALLOW_COPY_AND_ASSIGN(PaymentAppDatabase); |
175 }; | 191 }; |
176 | 192 |
177 } // namespace content | 193 } // namespace content |
178 | 194 |
179 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ | 195 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_DATABASE_H_ |
OLD | NEW |