| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <unordered_map> |
| 12 #include <unordered_set> | 13 #include <unordered_set> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 18 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 #include "components/autofill/core/browser/autofill_profile.h" | 21 #include "components/autofill/core/browser/autofill_profile.h" |
| 21 #include "components/autofill/core/browser/credit_card.h" | 22 #include "components/autofill/core/browser/credit_card.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 282 } |
| 282 #endif | 283 #endif |
| 283 | 284 |
| 284 protected: | 285 protected: |
| 285 // Only PersonalDataManagerFactory and certain tests can create instances of | 286 // Only PersonalDataManagerFactory and certain tests can create instances of |
| 286 // PersonalDataManager. | 287 // PersonalDataManager. |
| 287 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); | 288 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); |
| 288 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); | 289 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); |
| 289 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 290 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 290 DedupeProfiles_ProfilesToDelete); | 291 DedupeProfiles_ProfilesToDelete); |
| 292 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 293 DedupeProfiles_GuidsMergeMap); |
| 294 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 295 UpdateCardsBillingAddressReference); |
| 291 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, ApplyProfileUseDatesFix); | 296 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, ApplyProfileUseDatesFix); |
| 292 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 297 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 293 ApplyProfileUseDatesFix_NotAppliedTwice); | 298 ApplyProfileUseDatesFix_NotAppliedTwice); |
| 294 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 299 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 300 ApplyDedupingRoutine_CardsBillingAddressIdUpdated); |
| 301 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 295 ApplyDedupingRoutine_MergedProfileValues); | 302 ApplyDedupingRoutine_MergedProfileValues); |
| 296 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 303 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 297 ApplyDedupingRoutine_VerifiedProfileFirst); | 304 ApplyDedupingRoutine_VerifiedProfileFirst); |
| 298 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 305 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 299 ApplyDedupingRoutine_VerifiedProfileLast); | 306 ApplyDedupingRoutine_VerifiedProfileLast); |
| 300 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 307 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 301 ApplyDedupingRoutine_MultipleVerifiedProfiles); | 308 ApplyDedupingRoutine_MultipleVerifiedProfiles); |
| 302 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 309 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 303 ApplyDedupingRoutine_FeatureDisabled); | 310 ApplyDedupingRoutine_FeatureDisabled); |
| 304 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 311 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 const base::string16& field_contents, | 472 const base::string16& field_contents, |
| 466 const std::vector<CreditCard*>& cards_to_suggest) const; | 473 const std::vector<CreditCard*>& cards_to_suggest) const; |
| 467 | 474 |
| 468 // Runs the Autofill use date fix routine if it's never been done. Returns | 475 // Runs the Autofill use date fix routine if it's never been done. Returns |
| 469 // whether the routine was run. | 476 // whether the routine was run. |
| 470 void ApplyProfileUseDatesFix(); | 477 void ApplyProfileUseDatesFix(); |
| 471 | 478 |
| 472 // Applies the deduping routine once per major version if the feature is | 479 // Applies the deduping routine once per major version if the feature is |
| 473 // enabled. Calls DedupeProfiles with the content of |web_profiles_| as a | 480 // enabled. Calls DedupeProfiles with the content of |web_profiles_| as a |
| 474 // parameter. Removes the profiles to delete from the database and updates the | 481 // parameter. Removes the profiles to delete from the database and updates the |
| 475 // others. Returns true if the routine was run. | 482 // others. Also updates the credit cards' billing address references. Returns |
| 483 // true if the routine was run. |
| 476 bool ApplyDedupingRoutine(); | 484 bool ApplyDedupingRoutine(); |
| 477 | 485 |
| 478 // Goes through all the |existing_profiles| and merges all similar unverified | 486 // Goes through all the |existing_profiles| and merges all similar unverified |
| 479 // profiles together. Also discards unverified profiles that are similar to a | 487 // profiles together. Also discards unverified profiles that are similar to a |
| 480 // verified profile. All the profiles except the results of the merges will be | 488 // verified profile. All the profiles except the results of the merges will be |
| 481 // added to |profile_guids_to_delete|. This routine should be run once per | 489 // added to |profile_guids_to_delete|. This routine should be run once per |
| 482 // major version. | 490 // major version. Records all the merges into the |guids_merge_map|. |
| 483 // | 491 // |
| 484 // This method should only be called by ApplyDedupingRoutine. It is split for | 492 // This method should only be called by ApplyDedupingRoutine. It is split for |
| 485 // testing purposes. | 493 // testing purposes. |
| 486 void DedupeProfiles( | 494 void DedupeProfiles( |
| 487 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, | 495 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, |
| 488 std::unordered_set<AutofillProfile*>* profile_guids_to_delete); | 496 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, |
| 497 std::unordered_map<std::string, std::string>* guids_merge_map); |
| 498 |
| 499 // Updates the credit cards' billing address reference based on the merges |
| 500 // that happened during the dedupe, as defined in |guids_merge_map|. Also |
| 501 // updates the cards entries in the database. |
| 502 void UpdateCardsBillingAddressReference( |
| 503 const std::unordered_map<std::string, std::string>& guids_merge_map); |
| 489 | 504 |
| 490 const std::string app_locale_; | 505 const std::string app_locale_; |
| 491 | 506 |
| 492 // The default country code for new addresses. | 507 // The default country code for new addresses. |
| 493 mutable std::string default_country_code_; | 508 mutable std::string default_country_code_; |
| 494 | 509 |
| 495 // The PrefService that this instance uses. Must outlive this instance. | 510 // The PrefService that this instance uses. Must outlive this instance. |
| 496 PrefService* pref_service_; | 511 PrefService* pref_service_; |
| 497 | 512 |
| 498 // The AccountTrackerService that this instance uses. Must outlive this | 513 // The AccountTrackerService that this instance uses. Must outlive this |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // validation rules. | 547 // validation rules. |
| 533 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 548 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 534 #endif | 549 #endif |
| 535 | 550 |
| 536 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 551 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 537 }; | 552 }; |
| 538 | 553 |
| 539 } // namespace autofill | 554 } // namespace autofill |
| 540 | 555 |
| 541 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 556 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |