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(687352): Remove one of these since they do the same thing. |
|
Mathieu
2017/02/02 01:22:53
nit: TODO(crbug.com/687352)
sebsg
2017/02/02 15:18:51
Done.
| |
| 188 // |GetProfiles()| and |web_profiles()| returns only web profiles. | |
|
Mathieu
2017/02/02 01:22:52
"web" profiles means nothing...
sebsg
2017/02/02 15:18:51
Done.
| |
| 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 std::vector<AutofillProfile*> server_profiles() const; | |
| 190 // Returns just LOCAL_CARD cards. | 193 // Returns just LOCAL_CARD cards. |
| 191 virtual std::vector<CreditCard*> GetLocalCreditCards() const; | 194 virtual std::vector<CreditCard*> GetLocalCreditCards() const; |
| 192 // Returns all credit cards, server and local. | 195 // Returns all credit cards, server and local. |
| 193 virtual const std::vector<CreditCard*>& GetCreditCards() const; | 196 virtual const std::vector<CreditCard*>& GetCreditCards() const; |
| 194 | 197 |
| 195 // Returns true if there is some data synced from Wallet. | 198 // Returns true if there is some data synced from Wallet. |
| 196 bool HasServerData() const; | 199 bool HasServerData() const; |
| 197 | 200 |
| 198 // Returns the profiles to suggest to the user, ordered by frecency. | 201 // Returns the profiles to suggest to the user, ordered by frecency. |
| 199 const std::vector<AutofillProfile*> GetProfilesToSuggest() const; | 202 const std::vector<AutofillProfile*> GetProfilesToSuggest() const; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 312 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 310 ApplyDedupingRoutine_FeatureDisabled); | 313 ApplyDedupingRoutine_FeatureDisabled); |
| 311 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 314 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 312 ApplyDedupingRoutine_NopIfZeroProfiles); | 315 ApplyDedupingRoutine_NopIfZeroProfiles); |
| 313 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 316 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 314 ApplyDedupingRoutine_NopIfOneProfile); | 317 ApplyDedupingRoutine_NopIfOneProfile); |
| 315 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 318 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 316 ApplyDedupingRoutine_OncePerVersion); | 319 ApplyDedupingRoutine_OncePerVersion); |
| 317 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 320 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 318 ApplyDedupingRoutine_MultipleDedupes); | 321 ApplyDedupingRoutine_MultipleDedupes); |
| 322 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 323 ConvertWalletAddressesToLocalProfiles_NewProfile); | |
| 324 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 325 ConvertWalletAddressesToLocalProfiles_MergedProfile); | |
| 326 FRIEND_TEST_ALL_PREFIXES( | |
| 327 PersonalDataManagerTest, | |
| 328 ConvertWalletAddressesToLocalProfiles_AlreadyConverted); | |
| 329 FRIEND_TEST_ALL_PREFIXES( | |
| 330 PersonalDataManagerTest, | |
| 331 ConvertWalletAddressesToLocalProfiles_MultipleSimilarWalletAddresses); | |
| 319 friend class autofill::AutofillInteractiveTest; | 332 friend class autofill::AutofillInteractiveTest; |
| 320 friend class autofill::AutofillTest; | 333 friend class autofill::AutofillTest; |
| 321 friend class autofill::PersonalDataManagerFactory; | 334 friend class autofill::PersonalDataManagerFactory; |
| 322 friend class PersonalDataManagerTest; | 335 friend class PersonalDataManagerTest; |
| 323 friend class ProfileSyncServiceAutofillTest; | 336 friend class ProfileSyncServiceAutofillTest; |
| 324 friend class ::RemoveAutofillTester; | 337 friend class ::RemoveAutofillTester; |
| 325 friend std::default_delete<PersonalDataManager>; | 338 friend std::default_delete<PersonalDataManager>; |
| 326 friend void autofill_helper::SetProfiles( | 339 friend void autofill_helper::SetProfiles( |
| 327 int, std::vector<autofill::AutofillProfile>*); | 340 int, std::vector<autofill::AutofillProfile>*); |
| 328 friend void autofill_helper::SetCreditCards( | 341 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, | 508 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, |
| 496 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, | 509 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, |
| 497 std::unordered_map<std::string, std::string>* guids_merge_map); | 510 std::unordered_map<std::string, std::string>* guids_merge_map); |
| 498 | 511 |
| 499 // Updates the credit cards' billing address reference based on the merges | 512 // Updates the credit cards' billing address reference based on the merges |
| 500 // that happened during the dedupe, as defined in |guids_merge_map|. Also | 513 // that happened during the dedupe, as defined in |guids_merge_map|. Also |
| 501 // updates the cards entries in the database. | 514 // updates the cards entries in the database. |
| 502 void UpdateCardsBillingAddressReference( | 515 void UpdateCardsBillingAddressReference( |
| 503 const std::unordered_map<std::string, std::string>& guids_merge_map); | 516 const std::unordered_map<std::string, std::string>& guids_merge_map); |
| 504 | 517 |
| 518 // Converts the wallet addresses to local autofill profiles. This should be | |
| 519 // called after all sync is done. | |
|
Mathieu
2017/02/02 01:22:52
can you be more precise with "all sync"
sebsg
2017/02/02 15:18:51
Done.
| |
| 520 void ConvertWalletAddressesToLocalProfiles(); | |
| 521 | |
| 522 // Tries to merge the |server_address| into the |local_profiles| if possible. | |
| 523 // Adds it to the list if no match is found. The local profiles should be | |
| 524 // sorted by decreasing frecency outside of this method, since this will be | |
| 525 // called multiple times in a row. Returns the guid of the new or updated | |
| 526 // profile. | |
| 527 std::string MergeServerAddressesIntoLocalProfiles( | |
| 528 const AutofillProfile& server_address, | |
| 529 std::vector<AutofillProfile>* local_profiles); | |
| 530 | |
| 505 const std::string app_locale_; | 531 const std::string app_locale_; |
| 506 | 532 |
| 507 // The default country code for new addresses. | 533 // The default country code for new addresses. |
| 508 mutable std::string default_country_code_; | 534 mutable std::string default_country_code_; |
| 509 | 535 |
| 510 // The PrefService that this instance uses. Must outlive this instance. | 536 // The PrefService that this instance uses. Must outlive this instance. |
| 511 PrefService* pref_service_; | 537 PrefService* pref_service_; |
| 512 | 538 |
| 513 // The AccountTrackerService that this instance uses. Must outlive this | 539 // The AccountTrackerService that this instance uses. Must outlive this |
| 514 // instance. | 540 // instance. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 534 | 560 |
| 535 // An observer to listen for changes to prefs::kAutofillEnabled. | 561 // An observer to listen for changes to prefs::kAutofillEnabled. |
| 536 std::unique_ptr<BooleanPrefMember> enabled_pref_; | 562 std::unique_ptr<BooleanPrefMember> enabled_pref_; |
| 537 | 563 |
| 538 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. | 564 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. |
| 539 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; | 565 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; |
| 540 | 566 |
| 541 // True if autofill profile cleanup needs to be performed. | 567 // True if autofill profile cleanup needs to be performed. |
| 542 bool is_autofill_profile_cleanup_pending_ = false; | 568 bool is_autofill_profile_cleanup_pending_ = false; |
| 543 | 569 |
| 570 // Whether new information was received from the sync server. | |
| 571 bool has_synced_new_data = false; | |
| 572 | |
| 544 #if defined(OS_ANDROID) | 573 #if defined(OS_ANDROID) |
| 545 // The context for the request to be used to fetch libaddressinput's address | 574 // The context for the request to be used to fetch libaddressinput's address |
| 546 // validation rules. | 575 // validation rules. |
| 547 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 576 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 548 #endif | 577 #endif |
| 549 | 578 |
| 550 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 579 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 551 }; | 580 }; |
| 552 | 581 |
| 553 } // namespace autofill | 582 } // namespace autofill |
| 554 | 583 |
| 555 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 584 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |