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