| 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 put at the end of the |
| 195 // vector. |
| 196 const std::vector<CreditCard*> GetCreditCardsToSuggest() const; |
| 197 |
| 190 // Gets credit cards that can suggest data for |type|. See | 198 // Gets credit cards that can suggest data for |type|. See |
| 191 // GetProfileSuggestions for argument descriptions. The variant in each | 199 // GetProfileSuggestions for argument descriptions. The variant in each |
| 192 // GUID pair should be ignored. | 200 // GUID pair should be ignored. |
| 193 std::vector<Suggestion> GetCreditCardSuggestions( | 201 std::vector<Suggestion> GetCreditCardSuggestions( |
| 194 const AutofillType& type, | 202 const AutofillType& type, |
| 195 const base::string16& field_contents); | 203 const base::string16& field_contents); |
| 196 | 204 |
| 197 // Re-loads profiles and credit cards from the WebDatabase asynchronously. | 205 // 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 | 206 // 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 | 207 // in-memory model as existed prior to the call. If any change occurred to |
| (...skipping 28 matching lines...) Expand all Loading... |
| 228 | 236 |
| 229 // Returns our best guess for the country a user is likely to use when | 237 // 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 | 238 // inputting a new address. The value is calculated once and cached, so it |
| 231 // will only update when Chrome is restarted. | 239 // will only update when Chrome is restarted. |
| 232 virtual const std::string& GetDefaultCountryCodeForNewAddress() const; | 240 virtual const std::string& GetDefaultCountryCodeForNewAddress() const; |
| 233 | 241 |
| 234 // De-dupe credit card to suggest. Full server cards are prefered over their | 242 // 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 | 243 // local duplicates, and local cards are preferred over their masked server |
| 236 // card duplicate. | 244 // card duplicate. |
| 237 static void DedupeCreditCardToSuggest( | 245 static void DedupeCreditCardToSuggest( |
| 238 std::list<const CreditCard*>* cards_to_suggest); | 246 std::list<CreditCard*>* cards_to_suggest); |
| 239 | 247 |
| 240 protected: | 248 protected: |
| 241 // Only PersonalDataManagerFactory and certain tests can create instances of | 249 // Only PersonalDataManagerFactory and certain tests can create instances of |
| 242 // PersonalDataManager. | 250 // PersonalDataManager. |
| 243 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); | 251 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); |
| 244 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); | 252 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); |
| 245 friend class autofill::AutofillInteractiveTest; | 253 friend class autofill::AutofillInteractiveTest; |
| 246 friend class autofill::AutofillTest; | 254 friend class autofill::AutofillTest; |
| 247 friend class autofill::PersonalDataManagerFactory; | 255 friend class autofill::PersonalDataManagerFactory; |
| 248 friend class PersonalDataManagerTest; | 256 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 | 396 // |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. | 397 // profiles will be used to populate the fields shown in an Autofill popup. |
| 390 const std::vector<AutofillProfile*>& GetProfiles( | 398 const std::vector<AutofillProfile*>& GetProfiles( |
| 391 bool record_metrics) const; | 399 bool record_metrics) const; |
| 392 | 400 |
| 393 // Returns credit card suggestions based on the |cards_to_suggest| and the | 401 // Returns credit card suggestions based on the |cards_to_suggest| and the |
| 394 // |type| and |field_contents| of the credit card field. | 402 // |type| and |field_contents| of the credit card field. |
| 395 std::vector<Suggestion> GetSuggestionsForCards( | 403 std::vector<Suggestion> GetSuggestionsForCards( |
| 396 const AutofillType& type, | 404 const AutofillType& type, |
| 397 const base::string16& field_contents, | 405 const base::string16& field_contents, |
| 398 const std::list<const CreditCard*>& cards_to_suggest) const; | 406 const std::vector<CreditCard*>& cards_to_suggest) const; |
| 399 | 407 |
| 400 const std::string app_locale_; | 408 const std::string app_locale_; |
| 401 | 409 |
| 402 // The default country code for new addresses. | 410 // The default country code for new addresses. |
| 403 mutable std::string default_country_code_; | 411 mutable std::string default_country_code_; |
| 404 | 412 |
| 405 // The PrefService that this instance uses. Must outlive this instance. | 413 // The PrefService that this instance uses. Must outlive this instance. |
| 406 PrefService* pref_service_; | 414 PrefService* pref_service_; |
| 407 | 415 |
| 408 // The AccountTrackerService that this instance uses. Must outlive this | 416 // The AccountTrackerService that this instance uses. Must outlive this |
| (...skipping 19 matching lines...) Expand all Loading... |
| 428 | 436 |
| 429 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. | 437 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. |
| 430 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; | 438 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; |
| 431 | 439 |
| 432 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 440 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 433 }; | 441 }; |
| 434 | 442 |
| 435 } // namespace autofill | 443 } // namespace autofill |
| 436 | 444 |
| 437 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 445 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |