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

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

Issue 969103003: Don't save duplicates of wallet addresses to local Autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make test work Created 5 years, 9 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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 void PersonalDataManager::LoadProfiles() { 1116 void PersonalDataManager::LoadProfiles() {
1117 if (!database_.get()) { 1117 if (!database_.get()) {
1118 NOTREACHED(); 1118 NOTREACHED();
1119 return; 1119 return;
1120 } 1120 }
1121 1121
1122 CancelPendingQuery(&pending_profiles_query_); 1122 CancelPendingQuery(&pending_profiles_query_);
1123 CancelPendingQuery(&pending_server_profiles_query_); 1123 CancelPendingQuery(&pending_server_profiles_query_);
1124 1124
1125 pending_profiles_query_ = database_->GetAutofillProfiles(this); 1125 pending_profiles_query_ = database_->GetAutofillProfiles(this);
1126 pending_server_profiles_query_ = database_->GetAutofillServerProfiles(this); 1126 pending_server_profiles_query_ = database_->GetServerProfiles(this);
1127 } 1127 }
1128 1128
1129 // Win, Linux, Android and iOS implementations do nothing. Mac implementation 1129 // Win, Linux, Android and iOS implementations do nothing. Mac implementation
1130 // fills in the contents of |auxiliary_profiles_|. 1130 // fills in the contents of |auxiliary_profiles_|.
1131 #if defined(OS_IOS) || !defined(OS_MACOSX) 1131 #if defined(OS_IOS) || !defined(OS_MACOSX)
1132 void PersonalDataManager::LoadAuxiliaryProfiles(bool record_metrics) const { 1132 void PersonalDataManager::LoadAuxiliaryProfiles(bool record_metrics) const {
1133 } 1133 }
1134 #endif 1134 #endif
1135 1135
1136 void PersonalDataManager::LoadCreditCards() { 1136 void PersonalDataManager::LoadCreditCards() {
(...skipping 20 matching lines...) Expand all
1157 } 1157 }
1158 *handle = 0; 1158 *handle = 0;
1159 } 1159 }
1160 1160
1161 std::string PersonalDataManager::SaveImportedProfile( 1161 std::string PersonalDataManager::SaveImportedProfile(
1162 const AutofillProfile& imported_profile) { 1162 const AutofillProfile& imported_profile) {
1163 if (is_off_the_record_) 1163 if (is_off_the_record_)
1164 return std::string(); 1164 return std::string();
1165 1165
1166 // Don't save a web profile if the data in the profile is a subset of an 1166 // Don't save a web profile if the data in the profile is a subset of an
1167 // auxiliary profile. 1167 // auxiliary profile...
1168 for (std::vector<AutofillProfile*>::const_iterator iter = 1168 for (AutofillProfile* profile : auxiliary_profiles_) {
1169 auxiliary_profiles_.begin(); 1169 if (imported_profile.IsSubsetOf(*profile, app_locale_))
1170 iter != auxiliary_profiles_.end(); ++iter) { 1170 return profile->guid();
1171 if (imported_profile.IsSubsetOf(**iter, app_locale_)) 1171 }
1172 return (*iter)->guid(); 1172
1173 // ...or server profile.
1174 for (AutofillProfile* profile : server_profiles_) {
1175 if (imported_profile.IsSubsetOf(*profile, app_locale_))
1176 return profile->guid();
1173 } 1177 }
1174 1178
1175 std::vector<AutofillProfile> profiles; 1179 std::vector<AutofillProfile> profiles;
1176 std::string guid = 1180 std::string guid =
1177 MergeProfile(imported_profile, web_profiles_.get(), app_locale_, 1181 MergeProfile(imported_profile, web_profiles_.get(), app_locale_,
1178 &profiles); 1182 &profiles);
1179 SetProfiles(&profiles); 1183 SetProfiles(&profiles);
1180 return guid; 1184 return guid;
1181 } 1185 }
1182 1186
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 } 1283 }
1280 if (IsExperimentalWalletIntegrationEnabled() && 1284 if (IsExperimentalWalletIntegrationEnabled() &&
1281 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { 1285 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) {
1282 profiles_.insert( 1286 profiles_.insert(
1283 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); 1287 profiles_.end(), server_profiles_.begin(), server_profiles_.end());
1284 } 1288 }
1285 return profiles_; 1289 return profiles_;
1286 } 1290 }
1287 1291
1288 } // namespace autofill 1292 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698