| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // card duplicate. | 246 // card duplicate. |
| 247 static void DedupeCreditCardToSuggest( | 247 static void DedupeCreditCardToSuggest( |
| 248 std::list<CreditCard*>* cards_to_suggest); | 248 std::list<CreditCard*>* cards_to_suggest); |
| 249 | 249 |
| 250 protected: | 250 protected: |
| 251 // Only PersonalDataManagerFactory and certain tests can create instances of | 251 // Only PersonalDataManagerFactory and certain tests can create instances of |
| 252 // PersonalDataManager. | 252 // PersonalDataManager. |
| 253 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); | 253 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); |
| 254 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); | 254 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); |
| 255 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 255 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 256 FindAndMergeDuplicateProfiles_ProfilesToDelete); | 256 DedupeProfiles_ProfilesToDelete); |
| 257 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 258 FindAndMergeDuplicateProfiles_MergedProfileValues); | |
| 259 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, ApplyProfileUseDatesFix); | 257 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, ApplyProfileUseDatesFix); |
| 260 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 258 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 261 ApplyProfileUseDatesFix_NotAppliedTwice); | 259 ApplyProfileUseDatesFix_NotAppliedTwice); |
| 260 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 261 ApplyDedupingRoutine_MergedProfileValues); |
| 262 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 263 ApplyDedupingRoutine_VerifiedProfileFirst); |
| 264 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 265 ApplyDedupingRoutine_VerifiedProfileLast); |
| 266 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 267 ApplyDedupingRoutine_MultipleVerifiedProfiles); |
| 268 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 269 ApplyDedupingRoutine_FeatureDisabled); |
| 270 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 271 ApplyDedupingRoutine_OncePerVersion); |
| 272 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 273 ApplyDedupingRoutine_MultipleDedupes); |
| 262 friend class autofill::AutofillInteractiveTest; | 274 friend class autofill::AutofillInteractiveTest; |
| 263 friend class autofill::AutofillTest; | 275 friend class autofill::AutofillTest; |
| 264 friend class autofill::PersonalDataManagerFactory; | 276 friend class autofill::PersonalDataManagerFactory; |
| 265 friend class PersonalDataManagerTest; | 277 friend class PersonalDataManagerTest; |
| 266 #if defined(OS_IOS) | 278 #if defined(OS_IOS) |
| 267 // TODO(crbug.com/513344): Remove this once Chrome on iOS is unforked. | 279 // TODO(crbug.com/513344): Remove this once Chrome on iOS is unforked. |
| 268 friend class ::PersonalDataManagerFactory; | 280 friend class ::PersonalDataManagerFactory; |
| 269 #endif | 281 #endif |
| 270 friend class ProfileSyncServiceAutofillTest; | 282 friend class ProfileSyncServiceAutofillTest; |
| 271 friend class ::RemoveAutofillTester; | 283 friend class ::RemoveAutofillTester; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 const std::vector<AutofillProfile*>& GetProfiles( | 419 const std::vector<AutofillProfile*>& GetProfiles( |
| 408 bool record_metrics) const; | 420 bool record_metrics) const; |
| 409 | 421 |
| 410 // Returns credit card suggestions based on the |cards_to_suggest| and the | 422 // Returns credit card suggestions based on the |cards_to_suggest| and the |
| 411 // |type| and |field_contents| of the credit card field. | 423 // |type| and |field_contents| of the credit card field. |
| 412 std::vector<Suggestion> GetSuggestionsForCards( | 424 std::vector<Suggestion> GetSuggestionsForCards( |
| 413 const AutofillType& type, | 425 const AutofillType& type, |
| 414 const base::string16& field_contents, | 426 const base::string16& field_contents, |
| 415 const std::vector<CreditCard*>& cards_to_suggest) const; | 427 const std::vector<CreditCard*>& cards_to_suggest) const; |
| 416 | 428 |
| 417 // Goes through the |existing_profiles| to find similar profiles to | |
| 418 // |profile_to_merge|. If a similar profile is found |profile_to_merge| is | |
| 419 // merged into it, gets deleted and the result becomes the new | |
| 420 // |profile_to_merge|. The process continues until the end of | |
| 421 // |existing_profiles| is reached. | |
| 422 // | |
| 423 // |existing_profiles| should be sorted by frecency to ensure that the more | |
| 424 // relevant profiles get merged into the less relevant ones. | |
| 425 void FindMergeAndDeleteDuplicateProfiles( | |
| 426 const std::vector<AutofillProfile*>& existing_profiles, | |
| 427 AutofillProfile* profile_to_merge); | |
| 428 | |
| 429 // Goes through the |existing_profiles| to find similar profiles to | |
| 430 // |profile_to_merge|. If a similar profile is found |profile_to_merge| is | |
| 431 // merged into it, its GUID gets added to |profile_guids_to_delete| and the | |
| 432 // result becomes the new |profile_to_merge|. The process continues until the | |
| 433 // end of |existing_profiles| is reached. | |
| 434 // | |
| 435 // Note: This method is exposed for testability and should not be called | |
| 436 // directly in the code except in FindMergeAndDeleteDuplicateProfiles. Please | |
| 437 // use that method instead. | |
| 438 void FindAndMergeDuplicateProfiles( | |
| 439 const std::vector<AutofillProfile*>& existing_profiles, | |
| 440 AutofillProfile* profile_to_merge, | |
| 441 std::vector<std::string>* profile_guids_to_delete); | |
| 442 | |
| 443 // Runs the Autofill use date fix routine if it's never been done. Returns | 429 // Runs the Autofill use date fix routine if it's never been done. Returns |
| 444 // whether the routine was run. | 430 // whether the routine was run. |
| 445 void ApplyProfileUseDatesFix(); | 431 void ApplyProfileUseDatesFix(); |
| 446 | 432 |
| 433 // Applies the deduping routine once per major version if the feature is |
| 434 // enabled. Calls DedupeProfiles with the content of |web_profiles_| as a |
| 435 // parameter. Removes the profiles to delete from the database and updates the |
| 436 // others. Returns true if the routine was run. |
| 437 bool ApplyDedupingRoutine(); |
| 438 |
| 439 // Goes through all the |existing_profiles| and merges all similar unverified |
| 440 // profiles together. Also discards unverified profiles that are similar to a |
| 441 // verified profile. All the profiles except the results of the merges will be |
| 442 // added to |profile_guids_to_delete|. This routine should be run once per |
| 443 // major version. |
| 444 // |
| 445 // This method should only be called by ApplyDedupingRoutine. It is split for |
| 446 // testing purposes. |
| 447 void DedupeProfiles( |
| 448 std::vector<AutofillProfile*>* existing_profiles, |
| 449 std::unordered_set<AutofillProfile*>* profile_guids_to_delete); |
| 450 |
| 447 const std::string app_locale_; | 451 const std::string app_locale_; |
| 448 | 452 |
| 449 // The default country code for new addresses. | 453 // The default country code for new addresses. |
| 450 mutable std::string default_country_code_; | 454 mutable std::string default_country_code_; |
| 451 | 455 |
| 452 // The PrefService that this instance uses. Must outlive this instance. | 456 // The PrefService that this instance uses. Must outlive this instance. |
| 453 PrefService* pref_service_; | 457 PrefService* pref_service_; |
| 454 | 458 |
| 455 // The AccountTrackerService that this instance uses. Must outlive this | 459 // The AccountTrackerService that this instance uses. Must outlive this |
| 456 // instance. | 460 // instance. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 475 | 479 |
| 476 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. | 480 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. |
| 477 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; | 481 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; |
| 478 | 482 |
| 479 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 483 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 480 }; | 484 }; |
| 481 | 485 |
| 482 } // namespace autofill | 486 } // namespace autofill |
| 483 | 487 |
| 484 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 488 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |