OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "components/payments/content/payment_request_spec.h" | 14 #include "components/payments/content/payment_request_spec.h" |
15 #include "components/payments/content/payment_response_helper.h" | 15 #include "components/payments/content/payment_response_helper.h" |
16 #include "components/payments/core/address_normalizer.h" | 16 #include "components/payments/core/address_normalizer.h" |
| 17 #include "components/payments/core/profile_util.h" |
17 #include "components/payments/mojom/payment_request.mojom.h" | 18 #include "components/payments/mojom/payment_request.mojom.h" |
18 | 19 |
19 namespace autofill { | 20 namespace autofill { |
20 class AutofillProfile; | 21 class AutofillProfile; |
21 class CreditCard; | 22 class CreditCard; |
22 class PersonalDataManager; | 23 class PersonalDataManager; |
23 class RegionDataLoader; | 24 class RegionDataLoader; |
24 } // namespace autofill | 25 } // namespace autofill |
25 | 26 |
26 namespace payments { | 27 namespace payments { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void SetSelectedInstrument(PaymentInstrument* instrument); | 151 void SetSelectedInstrument(PaymentInstrument* instrument); |
151 | 152 |
152 bool is_ready_to_pay() { return is_ready_to_pay_; } | 153 bool is_ready_to_pay() { return is_ready_to_pay_; } |
153 | 154 |
154 const std::string& GetApplicationLocale(); | 155 const std::string& GetApplicationLocale(); |
155 autofill::PersonalDataManager* GetPersonalDataManager(); | 156 autofill::PersonalDataManager* GetPersonalDataManager(); |
156 autofill::RegionDataLoader* GetRegionDataLoader(); | 157 autofill::RegionDataLoader* GetRegionDataLoader(); |
157 | 158 |
158 Delegate* delegate() { return delegate_; } | 159 Delegate* delegate() { return delegate_; } |
159 | 160 |
| 161 PaymentsProfileComparator* profile_comparator() { |
| 162 return &profile_comparator_; |
| 163 } |
| 164 |
160 private: | 165 private: |
161 // Fetches the Autofill Profiles for this user from the PersonalDataManager, | 166 // Fetches the Autofill Profiles for this user from the PersonalDataManager, |
162 // and stores copies of them, owned by this PaymentRequestState, in | 167 // and stores copies of them, owned by this PaymentRequestState, in |
163 // profile_cache_. | 168 // profile_cache_. |
164 void PopulateProfileCache(); | 169 void PopulateProfileCache(); |
165 | 170 |
166 // Sets the initial selections for instruments and profiles, and notifies | 171 // Sets the initial selections for instruments and profiles, and notifies |
167 // observers. | 172 // observers. |
168 void SetDefaultProfileSelections(); | 173 void SetDefaultProfileSelections(); |
169 | 174 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; | 209 std::vector<std::unique_ptr<autofill::AutofillProfile>> profile_cache_; |
205 std::vector<autofill::AutofillProfile*> shipping_profiles_; | 210 std::vector<autofill::AutofillProfile*> shipping_profiles_; |
206 std::vector<autofill::AutofillProfile*> contact_profiles_; | 211 std::vector<autofill::AutofillProfile*> contact_profiles_; |
207 // Credit cards are directly owned by the instruments in this list. | 212 // Credit cards are directly owned by the instruments in this list. |
208 std::vector<std::unique_ptr<PaymentInstrument>> available_instruments_; | 213 std::vector<std::unique_ptr<PaymentInstrument>> available_instruments_; |
209 | 214 |
210 PaymentRequestDelegate* payment_request_delegate_; | 215 PaymentRequestDelegate* payment_request_delegate_; |
211 | 216 |
212 std::unique_ptr<PaymentResponseHelper> response_helper_; | 217 std::unique_ptr<PaymentResponseHelper> response_helper_; |
213 | 218 |
| 219 PaymentsProfileComparator profile_comparator_; |
| 220 |
214 base::ObserverList<Observer> observers_; | 221 base::ObserverList<Observer> observers_; |
215 | 222 |
216 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); | 223 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); |
217 }; | 224 }; |
218 | 225 |
219 } // namespace payments | 226 } // namespace payments |
220 | 227 |
221 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 228 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
OLD | NEW |