OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 virtual const std::vector<AutofillProfile*>& GetProfiles() const; | 170 virtual const std::vector<AutofillProfile*>& GetProfiles() const; |
171 virtual const std::vector<AutofillProfile*>& web_profiles() const; | 171 virtual const std::vector<AutofillProfile*>& web_profiles() const; |
172 // Returns just LOCAL_CARD cards. | 172 // Returns just LOCAL_CARD cards. |
173 virtual const std::vector<CreditCard*>& GetLocalCreditCards() const; | 173 virtual const std::vector<CreditCard*>& GetLocalCreditCards() const; |
174 // Returns all credit cards, server and local. | 174 // Returns all credit cards, server and local. |
175 virtual const std::vector<CreditCard*>& GetCreditCards() const; | 175 virtual const std::vector<CreditCard*>& GetCreditCards() const; |
176 | 176 |
177 // Returns true if there is some data synced from Wallet. | 177 // Returns true if there is some data synced from Wallet. |
178 bool HasServerData() const; | 178 bool HasServerData() const; |
179 | 179 |
180 // Returns the profiles to suggest to the user, ordered by frecency. | |
181 const std::vector<AutofillProfile*> GetProfilesToSuggest() const; | |
182 | |
180 // Loads profiles that can suggest data for |type|. |field_contents| is the | 183 // Loads profiles that can suggest data for |type|. |field_contents| is the |
181 // part the user has already typed. |field_is_autofilled| is true if the field | 184 // part the user has already typed. |field_is_autofilled| is true if the field |
182 // has already been autofilled. |other_field_types| represents the rest of | 185 // has already been autofilled. |other_field_types| represents the rest of |
183 // form. | 186 // form. |
184 std::vector<Suggestion> GetProfileSuggestions( | 187 std::vector<Suggestion> GetProfileSuggestions( |
185 const AutofillType& type, | 188 const AutofillType& type, |
186 const base::string16& field_contents, | 189 const base::string16& field_contents, |
187 bool field_is_autofilled, | 190 bool field_is_autofilled, |
188 const std::vector<ServerFieldType>& other_field_types); | 191 const std::vector<ServerFieldType>& other_field_types); |
189 | 192 |
193 // Returns the credit cards to suggest to the users. Those have been deduped | |
194 // and ordered by frecency with the expired cards at the back. | |
Mathieu
2016/05/20 13:57:09
nit: back -> end of the list?
sebsg
2016/05/24 17:27:32
Done.
| |
195 const std::vector<CreditCard*> GetCreditCardsToSuggest() const; | |
196 | |
190 // Gets credit cards that can suggest data for |type|. See | 197 // Gets credit cards that can suggest data for |type|. See |
191 // GetProfileSuggestions for argument descriptions. The variant in each | 198 // GetProfileSuggestions for argument descriptions. The variant in each |
192 // GUID pair should be ignored. | 199 // GUID pair should be ignored. |
193 std::vector<Suggestion> GetCreditCardSuggestions( | 200 std::vector<Suggestion> GetCreditCardSuggestions( |
194 const AutofillType& type, | 201 const AutofillType& type, |
195 const base::string16& field_contents); | 202 const base::string16& field_contents); |
196 | 203 |
197 // Re-loads profiles and credit cards from the WebDatabase asynchronously. | 204 // Re-loads profiles and credit cards from the WebDatabase asynchronously. |
198 // In the general case, this is a no-op and will re-create the same | 205 // In the general case, this is a no-op and will re-create the same |
199 // in-memory model as existed prior to the call. If any change occurred to | 206 // in-memory model as existed prior to the call. If any change occurred to |
(...skipping 28 matching lines...) Expand all Loading... | |
228 | 235 |
229 // Returns our best guess for the country a user is likely to use when | 236 // Returns our best guess for the country a user is likely to use when |
230 // inputting a new address. The value is calculated once and cached, so it | 237 // inputting a new address. The value is calculated once and cached, so it |
231 // will only update when Chrome is restarted. | 238 // will only update when Chrome is restarted. |
232 virtual const std::string& GetDefaultCountryCodeForNewAddress() const; | 239 virtual const std::string& GetDefaultCountryCodeForNewAddress() const; |
233 | 240 |
234 // De-dupe credit card to suggest. Full server cards are prefered over their | 241 // De-dupe credit card to suggest. Full server cards are prefered over their |
235 // local duplicates, and local cards are preferred over their masked server | 242 // local duplicates, and local cards are preferred over their masked server |
236 // card duplicate. | 243 // card duplicate. |
237 static void DedupeCreditCardToSuggest( | 244 static void DedupeCreditCardToSuggest( |
238 std::list<const CreditCard*>* cards_to_suggest); | 245 std::list<CreditCard*>* cards_to_suggest); |
239 | 246 |
240 protected: | 247 protected: |
241 // Only PersonalDataManagerFactory and certain tests can create instances of | 248 // Only PersonalDataManagerFactory and certain tests can create instances of |
242 // PersonalDataManager. | 249 // PersonalDataManager. |
243 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); | 250 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); |
244 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); | 251 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); |
245 friend class autofill::AutofillInteractiveTest; | 252 friend class autofill::AutofillInteractiveTest; |
246 friend class autofill::AutofillTest; | 253 friend class autofill::AutofillTest; |
247 friend class autofill::PersonalDataManagerFactory; | 254 friend class autofill::PersonalDataManagerFactory; |
248 friend class PersonalDataManagerTest; | 255 friend class PersonalDataManagerTest; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 // |record_metrics| is true. Metrics should be recorded when the returned | 395 // |record_metrics| is true. Metrics should be recorded when the returned |
389 // profiles will be used to populate the fields shown in an Autofill popup. | 396 // profiles will be used to populate the fields shown in an Autofill popup. |
390 const std::vector<AutofillProfile*>& GetProfiles( | 397 const std::vector<AutofillProfile*>& GetProfiles( |
391 bool record_metrics) const; | 398 bool record_metrics) const; |
392 | 399 |
393 // Returns credit card suggestions based on the |cards_to_suggest| and the | 400 // Returns credit card suggestions based on the |cards_to_suggest| and the |
394 // |type| and |field_contents| of the credit card field. | 401 // |type| and |field_contents| of the credit card field. |
395 std::vector<Suggestion> GetSuggestionsForCards( | 402 std::vector<Suggestion> GetSuggestionsForCards( |
396 const AutofillType& type, | 403 const AutofillType& type, |
397 const base::string16& field_contents, | 404 const base::string16& field_contents, |
398 const std::list<const CreditCard*>& cards_to_suggest) const; | 405 const std::vector<CreditCard*>& cards_to_suggest) const; |
399 | 406 |
400 const std::string app_locale_; | 407 const std::string app_locale_; |
401 | 408 |
402 // The default country code for new addresses. | 409 // The default country code for new addresses. |
403 mutable std::string default_country_code_; | 410 mutable std::string default_country_code_; |
404 | 411 |
405 // The PrefService that this instance uses. Must outlive this instance. | 412 // The PrefService that this instance uses. Must outlive this instance. |
406 PrefService* pref_service_; | 413 PrefService* pref_service_; |
407 | 414 |
408 // The AccountTrackerService that this instance uses. Must outlive this | 415 // The AccountTrackerService that this instance uses. Must outlive this |
(...skipping 19 matching lines...) Expand all Loading... | |
428 | 435 |
429 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. | 436 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. |
430 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; | 437 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; |
431 | 438 |
432 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 439 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
433 }; | 440 }; |
434 | 441 |
435 } // namespace autofill | 442 } // namespace autofill |
436 | 443 |
437 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 444 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |