| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 315 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 316 ApplyDedupingRoutine_FeatureDisabled); | 316 ApplyDedupingRoutine_FeatureDisabled); |
| 317 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 317 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 318 ApplyDedupingRoutine_NopIfZeroProfiles); | 318 ApplyDedupingRoutine_NopIfZeroProfiles); |
| 319 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 319 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 320 ApplyDedupingRoutine_NopIfOneProfile); | 320 ApplyDedupingRoutine_NopIfOneProfile); |
| 321 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 321 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 322 ApplyDedupingRoutine_OncePerVersion); | 322 ApplyDedupingRoutine_OncePerVersion); |
| 323 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 323 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
| 324 ApplyDedupingRoutine_MultipleDedupes); | 324 ApplyDedupingRoutine_MultipleDedupes); |
| 325 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 326 ConvertWalletAddressesToLocalProfiles_NewProfile); | |
| 327 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | |
| 328 ConvertWalletAddressesToLocalProfiles_MergedProfile); | |
| 329 FRIEND_TEST_ALL_PREFIXES( | 325 FRIEND_TEST_ALL_PREFIXES( |
| 330 PersonalDataManagerTest, | 326 PersonalDataManagerTest, |
| 331 ConvertWalletAddressesToLocalProfiles_AlreadyConverted); | 327 ConvertWalletAddressesAndUpdateWalletCards_NewProfile); |
| 332 FRIEND_TEST_ALL_PREFIXES( | 328 FRIEND_TEST_ALL_PREFIXES( |
| 333 PersonalDataManagerTest, | 329 PersonalDataManagerTest, |
| 334 ConvertWalletAddressesToLocalProfiles_MultipleSimilarWalletAddresses); | 330 ConvertWalletAddressesAndUpdateWalletCards_MergedProfile); |
| 331 FRIEND_TEST_ALL_PREFIXES( |
| 332 PersonalDataManagerTest, |
| 333 ConvertWalletAddressesAndUpdateWalletCards_NewCard_AddressAlreadyConverted
); |
| 334 FRIEND_TEST_ALL_PREFIXES( |
| 335 PersonalDataManagerTest, |
| 336 ConvertWalletAddressesAndUpdateWalletCards_AlreadyConverted); |
| 337 FRIEND_TEST_ALL_PREFIXES( |
| 338 PersonalDataManagerTest, |
| 339 ConvertWalletAddressesAndUpdateWalletCards_MultipleSimilarWalletAddresses)
; |
| 335 friend class autofill::AutofillInteractiveTest; | 340 friend class autofill::AutofillInteractiveTest; |
| 336 friend class autofill::AutofillTest; | 341 friend class autofill::AutofillTest; |
| 337 friend class autofill::PersonalDataManagerFactory; | 342 friend class autofill::PersonalDataManagerFactory; |
| 338 friend class PersonalDataManagerTest; | 343 friend class PersonalDataManagerTest; |
| 339 friend class ProfileSyncServiceAutofillTest; | 344 friend class ProfileSyncServiceAutofillTest; |
| 340 friend class ::RemoveAutofillTester; | 345 friend class ::RemoveAutofillTester; |
| 341 friend std::default_delete<PersonalDataManager>; | 346 friend std::default_delete<PersonalDataManager>; |
| 342 friend void autofill_helper::SetProfiles( | 347 friend void autofill_helper::SetProfiles( |
| 343 int, std::vector<autofill::AutofillProfile>*); | 348 int, std::vector<autofill::AutofillProfile>*); |
| 344 friend void autofill_helper::SetCreditCards( | 349 friend void autofill_helper::SetCreditCards( |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, | 516 std::vector<std::unique_ptr<AutofillProfile>>* existing_profiles, |
| 512 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, | 517 std::unordered_set<AutofillProfile*>* profile_guids_to_delete, |
| 513 std::unordered_map<std::string, std::string>* guids_merge_map); | 518 std::unordered_map<std::string, std::string>* guids_merge_map); |
| 514 | 519 |
| 515 // Updates the credit cards' billing address reference based on the merges | 520 // Updates the credit cards' billing address reference based on the merges |
| 516 // that happened during the dedupe, as defined in |guids_merge_map|. Also | 521 // that happened during the dedupe, as defined in |guids_merge_map|. Also |
| 517 // updates the cards entries in the database. | 522 // updates the cards entries in the database. |
| 518 void UpdateCardsBillingAddressReference( | 523 void UpdateCardsBillingAddressReference( |
| 519 const std::unordered_map<std::string, std::string>& guids_merge_map); | 524 const std::unordered_map<std::string, std::string>& guids_merge_map); |
| 520 | 525 |
| 521 // Converts the wallet addresses to local autofill profiles. This should be | 526 // Converts the Wallet addresses to local autofill profiles. This should be |
| 522 // called after all the syncable data has been processed (local cards and | 527 // called after all the syncable data has been processed (local cards and |
| 523 // profiles, wallet data and metadata). | 528 // profiles, Wallet data and metadata). Also updates Wallet cards' billing |
| 524 void ConvertWalletAddressesToLocalProfiles(); | 529 // address id to point to the local profiles. |
| 530 void ConvertWalletAddressesAndUpdateWalletCards(); |
| 531 |
| 532 // Converts the Wallet addresses into local profiles either by merging with an |
| 533 // existing |local_profiles| of by adding a new one. Populates the |
| 534 // |server_id_profiles_map| to be used when updating cards where the address |
| 535 // was already converted. Also populates the |guids_merge_map| to keep the |
| 536 // link between the Wallet address and the equivalent local profile (from |
| 537 // merge or creation). |
| 538 bool ConvertWalletAddressesToLocalProfiles( |
| 539 std::vector<AutofillProfile>* local_profiles, |
| 540 std::unordered_map<std::string, AutofillProfile*>* server_id_profiles_map, |
| 541 std::unordered_map<std::string, std::string>* guids_merge_map); |
| 542 |
| 543 // Goes through the Wallet cards to find cards where the billing address is a |
| 544 // Wallet address which was already converted in a previous pass. Looks for a |
| 545 // matching local profile and updates the |guids_merge_map| to make the card |
| 546 // refert to it. |
| 547 bool UpdateWalletCardsAlreadyConvertedBillingAddresses( |
| 548 std::vector<AutofillProfile>* local_profiles, |
| 549 std::unordered_map<std::string, AutofillProfile*>* server_id_profiles_map, |
| 550 std::unordered_map<std::string, std::string>* guids_merge_map); |
| 525 | 551 |
| 526 // Tries to merge the |server_address| into the |existing_profiles| if | 552 // Tries to merge the |server_address| into the |existing_profiles| if |
| 527 // possible. Adds it to the list if no match is found. The existing profiles | 553 // possible. Adds it to the list if no match is found. The existing profiles |
| 528 // should be sorted by decreasing frecency outside of this method, since this | 554 // should be sorted by decreasing frecency outside of this method, since this |
| 529 // will be called multiple times in a row. Returns the guid of the new or | 555 // will be called multiple times in a row. Returns the guid of the new or |
| 530 // updated profile. | 556 // updated profile. |
| 531 std::string MergeServerAddressesIntoProfiles( | 557 std::string MergeServerAddressesIntoProfiles( |
| 532 const AutofillProfile& server_address, | 558 const AutofillProfile& server_address, |
| 533 std::vector<AutofillProfile>* existing_profiles); | 559 std::vector<AutofillProfile>* existing_profiles); |
| 534 | 560 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 // validation rules. | 605 // validation rules. |
| 580 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 606 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 581 #endif | 607 #endif |
| 582 | 608 |
| 583 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 609 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 584 }; | 610 }; |
| 585 | 611 |
| 586 } // namespace autofill | 612 } // namespace autofill |
| 587 | 613 |
| 588 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 614 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |