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

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

Issue 1143253012: More work on removing variants from Autofill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work around iOS lameness Created 5 years, 6 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 #include "components/autofill/core/browser/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 10
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 std::vector<AutofillProfile>* merged_profiles) { 990 std::vector<AutofillProfile>* merged_profiles) {
991 merged_profiles->clear(); 991 merged_profiles->clear();
992 992
993 // Set to true if |existing_profiles| already contains an equivalent profile. 993 // Set to true if |existing_profiles| already contains an equivalent profile.
994 bool matching_profile_found = false; 994 bool matching_profile_found = false;
995 std::string guid = new_profile.guid(); 995 std::string guid = new_profile.guid();
996 996
997 // If we have already saved this address, merge in any missing values. 997 // If we have already saved this address, merge in any missing values.
998 // Only merge with the first match. 998 // Only merge with the first match.
999 for (AutofillProfile* existing_profile : existing_profiles) { 999 for (AutofillProfile* existing_profile : existing_profiles) {
1000 if (!matching_profile_found && 1000 if (!matching_profile_found && !new_profile.PrimaryValue().empty() &&
1001 !new_profile.PrimaryValue().empty() && 1001 existing_profile->SaveAdditionalInfo(new_profile, app_locale)) {
1002 AutofillProfile::AreProfileStringsSimilar(
1003 existing_profile->PrimaryValue(),
1004 new_profile.PrimaryValue())) {
1005 // Unverified profiles should always be updated with the newer data, 1002 // Unverified profiles should always be updated with the newer data,
1006 // whereas verified profiles should only ever be overwritten by verified 1003 // whereas verified profiles should only ever be overwritten by verified
1007 // data. If an automatically aggregated profile would overwrite a 1004 // data. If an automatically aggregated profile would overwrite a
1008 // verified profile, just drop it. 1005 // verified profile, just drop it.
1009 matching_profile_found = true; 1006 matching_profile_found = true;
1010 guid = existing_profile->guid(); 1007 guid = existing_profile->guid();
1011 if (!existing_profile->IsVerified() || new_profile.IsVerified())
1012 existing_profile->OverwriteWithOrAddTo(new_profile, app_locale);
1013 } 1008 }
1014 merged_profiles->push_back(*existing_profile); 1009 merged_profiles->push_back(*existing_profile);
1015 } 1010 }
1016 1011
1017 // If the new profile was not merged with an existing one, add it to the list. 1012 // If the new profile was not merged with an existing one, add it to the list.
1018 if (!matching_profile_found) 1013 if (!matching_profile_found)
1019 merged_profiles->push_back(new_profile); 1014 merged_profiles->push_back(new_profile);
1020 1015
1021 return guid; 1016 return guid;
1022 } 1017 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 } 1326 }
1332 if (IsExperimentalWalletIntegrationEnabled() && 1327 if (IsExperimentalWalletIntegrationEnabled() &&
1333 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { 1328 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) {
1334 profiles_.insert( 1329 profiles_.insert(
1335 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); 1330 profiles_.end(), server_profiles_.begin(), server_profiles_.end());
1336 } 1331 }
1337 return profiles_; 1332 return profiles_;
1338 } 1333 }
1339 1334
1340 } // namespace autofill 1335 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698