Chromium Code Reviews| 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 <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 void GetNonEmptyTypes(ServerFieldTypeSet* non_empty_types); | 176 void GetNonEmptyTypes(ServerFieldTypeSet* non_empty_types); |
| 177 | 177 |
| 178 // Returns true if the credit card information is stored with a password. | 178 // Returns true if the credit card information is stored with a password. |
| 179 bool HasPassword(); | 179 bool HasPassword(); |
| 180 | 180 |
| 181 // Returns whether the personal data has been loaded from the web database. | 181 // Returns whether the personal data has been loaded from the web database. |
| 182 virtual bool IsDataLoaded() const; | 182 virtual bool IsDataLoaded() const; |
| 183 | 183 |
| 184 // This PersonalDataManager owns these profiles and credit cards. Their | 184 // This PersonalDataManager owns these profiles and credit cards. Their |
| 185 // lifetime is until the web database is updated with new profile and credit | 185 // lifetime is until the web database is updated with new profile and credit |
| 186 // card information, respectively. |GetProfiles()| returns both web and | 186 // card information, respectively. |
| 187 // auxiliary profiles. |web_profiles()| returns only web profiles. | 187 // TODO(crbug.com/687352): Remove one of these since they do the same thing. |
| 188 // |GetProfiles()| and |web_profiles()| returns only local profiles. | |
| 188 virtual const std::vector<AutofillProfile*>& GetProfiles() const; | 189 virtual const std::vector<AutofillProfile*>& GetProfiles() const; |
| 189 virtual std::vector<AutofillProfile*> web_profiles() const; | 190 virtual std::vector<AutofillProfile*> web_profiles() const; |
| 191 // Returns just SERVER_PROFILES. | |
| 192 virtual const std::vector<std::unique_ptr<AutofillProfile>>& server_profiles() | |
| 193 const; | |
| 190 // Returns just LOCAL_CARD cards. | 194 // Returns just LOCAL_CARD cards. |
| 191 virtual std::vector<CreditCard*> GetLocalCreditCards() const; | 195 virtual std::vector<CreditCard*> GetLocalCreditCards() const; |
| 192 // Returns all credit cards, server and local. | 196 // Returns all credit cards, server and local. |
| 193 virtual const std::vector<CreditCard*>& GetCreditCards() const; | 197 virtual const std::vector<CreditCard*>& GetCreditCards() const; |
|
Roger McFarlane (Chromium)
2017/02/02 16:05:01
Do you know why these are all virtual? Do they get
sebsg
2017/02/02 16:38:27
Yeah, they are overrriden in test_personal_data_ma
Roger McFarlane (Chromium)
2017/02/02 21:02:19
YOu can return a const ref if the function doesn't
| |
| 194 | 198 |
| 195 // Returns true if there is some data synced from Wallet. | |
| 196 bool HasServerData() const; | |
| 197 | |
| 198 // Returns the profiles to suggest to the user, ordered by frecency. | 199 // Returns the profiles to suggest to the user, ordered by frecency. |
| 199 const std::vector<AutofillProfile*> GetProfilesToSuggest() const; | 200 const std::vector<AutofillProfile*> GetProfilesToSuggest() const; |
| 200 | 201 |
| 201 // Loads profiles that can suggest data for |type|. |field_contents| is the | 202 // Loads profiles that can suggest data for |type|. |field_contents| is the |
| 202 // part the user has already typed. |field_is_autofilled| is true if the field | 203 // part the user has already typed. |field_is_autofilled| is true if the field |
| 203 // has already been autofilled. |other_field_types| represents the rest of | 204 // has already been autofilled. |other_field_types| represents the rest of |
| 204 // form. | 205 // form. |
| 205 std::vector<Suggestion> GetProfileSuggestions( | 206 std::vector<Suggestion> GetProfileSuggestions( |
| 206 const AutofillType& type, | 207 const AutofillType& type, |
| 207 const base::string16& field_contents, | 208 const base::string16& field_contents, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 310 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 310 ApplyDedupingRoutine_FeatureDisabled); | 311 ApplyDedupingRoutine_FeatureDisabled); |
| 311 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 312 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 312 ApplyDedupingRoutine_NopIfZeroProfiles); | 313 ApplyDedupingRoutine_NopIfZeroProfiles); |
| 313 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 314 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 314 ApplyDedupingRoutine_NopIfOneProfile); | 315 ApplyDedupingRoutine_NopIfOneProfile); |
| 315 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 316 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 316 ApplyDedupingRoutine_OncePerVersion); | 317 ApplyDedupingRoutine_OncePerVersion); |
| 317 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 318 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 318 ApplyDedupingRoutine_MultipleDedupes); | 319 ApplyDedupingRoutine_MultipleDedupes); |
| 320 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 321 ConvertWalletAddressesToLocalProfiles_NewProfile); | |
| 322 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 323 ConvertWalletAddressesToLocalProfiles_MergedProfile); | |
| 324 FRIEND_TEST_ALL_PREFIXES( | |
| 325 PersonalDataManagerTest, | |
| 326 ConvertWalletAddressesToLocalProfiles_AlreadyConverted); | |
| 327 FRIEND_TEST_ALL_PREFIXES( | |
| 328 PersonalDataManagerTest, | |
| 329 ConvertWalletAddressesToLocalProfiles_MultipleSimilarWalletAddresses); | |
| 319 friend class autofill::AutofillInteractiveTest; | 330 friend class autofill::AutofillInteractiveTest; |
| 320 friend class autofill::AutofillTest; | 331 friend class autofill::AutofillTest; |
| 321 friend class autofill::PersonalDataManagerFactory; | 332 friend class autofill::PersonalDataManagerFactory; |
| 322 friend class PersonalDataManagerTest; | 333 friend class PersonalDataManagerTest; |
| 323 friend class ProfileSyncServiceAutofillTest; | 334 friend class ProfileSyncServiceAutofillTest; |
| 324 friend class ::RemoveAutofillTester; | 335 friend class ::RemoveAutofillTester; |
| 325 friend std::default_delete<PersonalDataManager>; | 336 friend std::default_delete<PersonalDataManager>; |
| 326 friend void autofill_helper::SetProfiles( | 337 friend void autofill_helper::SetProfiles( |
| 327 int, std::vector<autofill::AutofillProfile>*); | 338 int, std::vector<autofill::AutofillProfile>*); |
| 328 friend void autofill_helper::SetCreditCards( | 339 friend void autofill_helper::SetCreditCards( |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, | 506 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, |
| 496 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, | 507 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, |
| 497 std::unordered_map<std::string, std::string>* guids_merge_map); | 508 std::unordered_map<std::string, std::string>* guids_merge_map); |
| 498 | 509 |
| 499 // Updates the credit cards' billing address reference based on the merges | 510 // Updates the credit cards' billing address reference based on the merges |
| 500 // that happened during the dedupe, as defined in |guids_merge_map|. Also | 511 // that happened during the dedupe, as defined in |guids_merge_map|. Also |
| 501 // updates the cards entries in the database. | 512 // updates the cards entries in the database. |
| 502 void UpdateCardsBillingAddressReference( | 513 void UpdateCardsBillingAddressReference( |
| 503 const std::unordered_map<std::string, std::string>& guids_merge_map); | 514 const std::unordered_map<std::string, std::string>& guids_merge_map); |
| 504 | 515 |
| 516 // Converts the wallet addresses to local autofill profiles. This should be | |
| 517 // called after all the syncable data has been processed (local cards and | |
| 518 // profiles, wallet data and metadata). | |
| 519 void ConvertWalletAddressesToLocalProfiles(); | |
| 520 | |
| 521 // Tries to merge the |server_address| into the |existing_profiles| if | |
| 522 // possible. Adds it to the list if no match is found. The existing profiles | |
| 523 // should be sorted by decreasing frecency outside of this method, since this | |
| 524 // will be called multiple times in a row. Returns the guid of the new or | |
| 525 // updated profile. | |
| 526 std::string MergeServerAddressesIntoProfiles( | |
| 527 const AutofillProfile& server_address, | |
| 528 std::vector<AutofillProfile>* existing_profiles); | |
| 529 | |
| 505 const std::string app_locale_; | 530 const std::string app_locale_; |
| 506 | 531 |
| 507 // The default country code for new addresses. | 532 // The default country code for new addresses. |
| 508 mutable std::string default_country_code_; | 533 mutable std::string default_country_code_; |
| 509 | 534 |
| 510 // The PrefService that this instance uses. Must outlive this instance. | 535 // The PrefService that this instance uses. Must outlive this instance. |
| 511 PrefService* pref_service_; | 536 PrefService* pref_service_; |
| 512 | 537 |
| 513 // The AccountTrackerService that this instance uses. Must outlive this | 538 // The AccountTrackerService that this instance uses. Must outlive this |
| 514 // instance. | 539 // instance. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 534 | 559 |
| 535 // An observer to listen for changes to prefs::kAutofillEnabled. | 560 // An observer to listen for changes to prefs::kAutofillEnabled. |
| 536 std::unique_ptr<BooleanPrefMember> enabled_pref_; | 561 std::unique_ptr<BooleanPrefMember> enabled_pref_; |
| 537 | 562 |
| 538 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. | 563 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. |
| 539 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; | 564 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; |
| 540 | 565 |
| 541 // True if autofill profile cleanup needs to be performed. | 566 // True if autofill profile cleanup needs to be performed. |
| 542 bool is_autofill_profile_cleanup_pending_ = false; | 567 bool is_autofill_profile_cleanup_pending_ = false; |
| 543 | 568 |
| 569 // Whether new information was received from the sync server. | |
| 570 bool has_synced_new_data = false; | |
| 571 | |
| 544 #if defined(OS_ANDROID) | 572 #if defined(OS_ANDROID) |
| 545 // The context for the request to be used to fetch libaddressinput's address | 573 // The context for the request to be used to fetch libaddressinput's address |
| 546 // validation rules. | 574 // validation rules. |
| 547 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 575 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 548 #endif | 576 #endif |
| 549 | 577 |
| 550 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 578 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 551 }; | 579 }; |
| 552 | 580 |
| 553 } // namespace autofill | 581 } // namespace autofill |
| 554 | 582 |
| 555 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 583 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |