Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: components/autofill/core/browser/personal_data_manager.h

Issue 2658843004: [Autofill] Convert wallet addresses to local autofill profiles. (Closed)
Patch Set: Addressed Mathp's comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 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.
196 bool HasServerData() const;
197
198 // Returns the profiles to suggest to the user, ordered by frecency. 198 // Returns the profiles to suggest to the user, ordered by frecency.
199 const std::vector<AutofillProfile*> GetProfilesToSuggest() const; 199 const std::vector<AutofillProfile*> GetProfilesToSuggest() const;
200 200
201 // Loads profiles that can suggest data for |type|. |field_contents| is the 201 // 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 202 // 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 203 // has already been autofilled. |other_field_types| represents the rest of
204 // form. 204 // form.
205 std::vector<Suggestion> GetProfileSuggestions( 205 std::vector<Suggestion> GetProfileSuggestions(
206 const AutofillType& type, 206 const AutofillType& type,
207 const base::string16& field_contents, 207 const base::string16& field_contents,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, 309 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
310 ApplyDedupingRoutine_FeatureDisabled); 310 ApplyDedupingRoutine_FeatureDisabled);
311 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, 311 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
312 ApplyDedupingRoutine_NopIfZeroProfiles); 312 ApplyDedupingRoutine_NopIfZeroProfiles);
313 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, 313 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
314 ApplyDedupingRoutine_NopIfOneProfile); 314 ApplyDedupingRoutine_NopIfOneProfile);
315 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, 315 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
316 ApplyDedupingRoutine_OncePerVersion); 316 ApplyDedupingRoutine_OncePerVersion);
317 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, 317 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
318 ApplyDedupingRoutine_MultipleDedupes); 318 ApplyDedupingRoutine_MultipleDedupes);
319 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
320 ConvertWalletAddressesToLocalProfiles_NewProfile);
321 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest,
322 ConvertWalletAddressesToLocalProfiles_MergedProfile);
323 FRIEND_TEST_ALL_PREFIXES(
324 PersonalDataManagerTest,
325 ConvertWalletAddressesToLocalProfiles_AlreadyConverted);
326 FRIEND_TEST_ALL_PREFIXES(
327 PersonalDataManagerTest,
328 ConvertWalletAddressesToLocalProfiles_MultipleSimilarWalletAddresses);
319 friend class autofill::AutofillInteractiveTest; 329 friend class autofill::AutofillInteractiveTest;
320 friend class autofill::AutofillTest; 330 friend class autofill::AutofillTest;
321 friend class autofill::PersonalDataManagerFactory; 331 friend class autofill::PersonalDataManagerFactory;
322 friend class PersonalDataManagerTest; 332 friend class PersonalDataManagerTest;
323 friend class ProfileSyncServiceAutofillTest; 333 friend class ProfileSyncServiceAutofillTest;
324 friend class ::RemoveAutofillTester; 334 friend class ::RemoveAutofillTester;
325 friend std::default_delete<PersonalDataManager>; 335 friend std::default_delete<PersonalDataManager>;
326 friend void autofill_helper::SetProfiles( 336 friend void autofill_helper::SetProfiles(
327 int, std::vector<autofill::AutofillProfile>*); 337 int, std::vector<autofill::AutofillProfile>*);
328 friend void autofill_helper::SetCreditCards( 338 friend void autofill_helper::SetCreditCards(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, 505 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles,
496 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, 506 std::unordered_set<AutofillProfile*>* profile_guids_to_delete,
497 std::unordered_map<std::string, std::string>* guids_merge_map); 507 std::unordered_map<std::string, std::string>* guids_merge_map);
498 508
499 // Updates the credit cards' billing address reference based on the merges 509 // Updates the credit cards' billing address reference based on the merges
500 // that happened during the dedupe, as defined in |guids_merge_map|. Also 510 // that happened during the dedupe, as defined in |guids_merge_map|. Also
501 // updates the cards entries in the database. 511 // updates the cards entries in the database.
502 void UpdateCardsBillingAddressReference( 512 void UpdateCardsBillingAddressReference(
503 const std::unordered_map<std::string, std::string>& guids_merge_map); 513 const std::unordered_map<std::string, std::string>& guids_merge_map);
504 514
515 // Converts the wallet addresses to local autofill profiles. This should be
516 // called after all the syncable data has been processed (local cards and
517 // profiles, wallet data and metadata).
518 void ConvertWalletAddressesToLocalProfiles();
519
520 // Tries to merge the |server_address| into the |existing_profiles| if
521 // possible. Adds it to the list if no match is found. The existing profiles
522 // should be sorted by decreasing frecency outside of this method, since this
523 // will be called multiple times in a row. Returns the guid of the new or
524 // updated profile.
525 std::string MergeServerAddressesIntoProfiles(
526 const AutofillProfile& server_address,
527 std::vector<AutofillProfile>* existing_profiles);
528
505 const std::string app_locale_; 529 const std::string app_locale_;
506 530
507 // The default country code for new addresses. 531 // The default country code for new addresses.
508 mutable std::string default_country_code_; 532 mutable std::string default_country_code_;
509 533
510 // The PrefService that this instance uses. Must outlive this instance. 534 // The PrefService that this instance uses. Must outlive this instance.
511 PrefService* pref_service_; 535 PrefService* pref_service_;
512 536
513 // The AccountTrackerService that this instance uses. Must outlive this 537 // The AccountTrackerService that this instance uses. Must outlive this
514 // instance. 538 // instance.
(...skipping 19 matching lines...) Expand all
534 558
535 // An observer to listen for changes to prefs::kAutofillEnabled. 559 // An observer to listen for changes to prefs::kAutofillEnabled.
536 std::unique_ptr<BooleanPrefMember> enabled_pref_; 560 std::unique_ptr<BooleanPrefMember> enabled_pref_;
537 561
538 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. 562 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled.
539 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; 563 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_;
540 564
541 // True if autofill profile cleanup needs to be performed. 565 // True if autofill profile cleanup needs to be performed.
542 bool is_autofill_profile_cleanup_pending_ = false; 566 bool is_autofill_profile_cleanup_pending_ = false;
543 567
568 // Whether new information was received from the sync server.
569 bool has_synced_new_data = false;
Mathieu 2017/02/02 15:52:30 has_synced_new_data_?
sebsg 2017/02/02 16:38:27 Done.
570
544 #if defined(OS_ANDROID) 571 #if defined(OS_ANDROID)
545 // The context for the request to be used to fetch libaddressinput's address 572 // The context for the request to be used to fetch libaddressinput's address
546 // validation rules. 573 // validation rules.
547 scoped_refptr<net::URLRequestContextGetter> context_getter_; 574 scoped_refptr<net::URLRequestContextGetter> context_getter_;
548 #endif 575 #endif
549 576
550 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); 577 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager);
551 }; 578 };
552 579
553 } // namespace autofill 580 } // namespace autofill
554 581
555 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ 582 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698