| 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 #include "components/autofill/core/browser/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 // Delete the duplicate profiles. | 1553 // Delete the duplicate profiles. |
| 1554 for (const std::string& profile_guid_to_delete : profile_guids_to_delete) { | 1554 for (const std::string& profile_guid_to_delete : profile_guids_to_delete) { |
| 1555 RemoveByGUID(profile_guid_to_delete); | 1555 RemoveByGUID(profile_guid_to_delete); |
| 1556 } | 1556 } |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 void PersonalDataManager::FindAndMergeDuplicateProfiles( | 1559 void PersonalDataManager::FindAndMergeDuplicateProfiles( |
| 1560 const std::vector<AutofillProfile*>& existing_profiles, | 1560 const std::vector<AutofillProfile*>& existing_profiles, |
| 1561 AutofillProfile* profile_to_merge, | 1561 AutofillProfile* profile_to_merge, |
| 1562 std::vector<std::string>* profile_guids_to_delete) { | 1562 std::vector<std::string>* profile_guids_to_delete) { |
| 1563 AutofillMetrics::LogNumberOfProfilesConsideredForDedupe( |
| 1564 existing_profiles.size()); |
| 1563 for (AutofillProfile* existing_profile : existing_profiles) { | 1565 for (AutofillProfile* existing_profile : existing_profiles) { |
| 1564 // Don't try to merge a profile with itself or with any profile with a | 1566 // Don't try to merge a profile with itself or with any profile with a |
| 1565 // different PrimaryValue. | 1567 // different PrimaryValue. |
| 1566 if (existing_profile->guid() != profile_to_merge->guid() && | 1568 if (existing_profile->guid() != profile_to_merge->guid() && |
| 1567 AutofillProfile::CanonicalizeProfileString( | 1569 AutofillProfile::CanonicalizeProfileString( |
| 1568 existing_profile->PrimaryValue(app_locale_)) == | 1570 existing_profile->PrimaryValue(app_locale_)) == |
| 1569 AutofillProfile::CanonicalizeProfileString( | 1571 AutofillProfile::CanonicalizeProfileString( |
| 1570 profile_to_merge->PrimaryValue(app_locale_))) { | 1572 profile_to_merge->PrimaryValue(app_locale_))) { |
| 1571 if (existing_profile->SaveAdditionalInfo(*profile_to_merge, | 1573 if (existing_profile->SaveAdditionalInfo(*profile_to_merge, |
| 1572 app_locale_)) { | 1574 app_locale_)) { |
| 1573 // Since |profile_to_merge| was a duplicate of |existing_profile| and | 1575 // Since |profile_to_merge| was a duplicate of |existing_profile| and |
| 1574 // was merged sucessfully, it can now be deleted. | 1576 // was merged sucessfully, it can now be deleted. |
| 1575 profile_guids_to_delete->push_back(profile_to_merge->guid()); | 1577 profile_guids_to_delete->push_back(profile_to_merge->guid()); |
| 1576 | 1578 |
| 1577 // Now try to merge the new resulting profile with the rest of the | 1579 // Now try to merge the new resulting profile with the rest of the |
| 1578 // existing profiles. | 1580 // existing profiles. |
| 1579 profile_to_merge = existing_profile; | 1581 profile_to_merge = existing_profile; |
| 1580 } | 1582 } |
| 1581 } | 1583 } |
| 1582 } | 1584 } |
| 1585 |
| 1586 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe( |
| 1587 profile_guids_to_delete->size()); |
| 1583 } | 1588 } |
| 1584 | 1589 |
| 1585 } // namespace autofill | 1590 } // namespace autofill |
| OLD | NEW |