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

Unified Diff: components/autofill/browser/personal_data_manager.cc

Issue 16034018: [Autofill] Support "importing" verified profiles and credit cards. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up comments Created 7 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/personal_data_manager.cc
diff --git a/components/autofill/browser/personal_data_manager.cc b/components/autofill/browser/personal_data_manager.cc
index a3995485e567040d7f3716867acd3910d225dff9..332d9054958eac479a1775c19149bef8debd5d35 100644
--- a/components/autofill/browser/personal_data_manager.cc
+++ b/components/autofill/browser/personal_data_manager.cc
@@ -725,7 +725,7 @@ bool PersonalDataManager::IsValidLearnableProfile(
// static
bool PersonalDataManager::MergeProfile(
- const AutofillProfile& profile,
+ const AutofillProfile& new_profile,
const std::vector<AutofillProfile*>& existing_profiles,
const std::string& app_locale,
std::vector<AutofillProfile>* merged_profiles) {
@@ -739,17 +739,18 @@ bool PersonalDataManager::MergeProfile(
for (std::vector<AutofillProfile*>::const_iterator iter =
existing_profiles.begin();
iter != existing_profiles.end(); ++iter) {
- if (!merged) {
- if (!profile.PrimaryValue().empty() &&
- StringToLowerASCII((*iter)->PrimaryValue()) ==
- StringToLowerASCII(profile.PrimaryValue())) {
+ AutofillProfile* existing_profile = *iter;
+ if (!merged &&
+ !new_profile.PrimaryValue().empty() &&
+ StringToLowerASCII(existing_profile->PrimaryValue()) ==
+ StringToLowerASCII(new_profile.PrimaryValue())) {
+ if (!existing_profile->IsVerified()) {
+ (*iter)->OverwriteWithOrAddTo(new_profile, app_locale);
merged = true;
-
+ } else if (!new_profile.IsVerified()) {
// Automatically aggregated profiles should never overwrite explicitly
// user-entered ones. If one would, just drop it.
- DCHECK(!profile.IsVerified());
- if (!(*iter)->IsVerified())
- (*iter)->OverwriteWithOrAddTo(profile, app_locale);
+ merged = true;
Evan Stade 2013/06/12 20:40:17 nit: merged = true is a little confusing here, sin
Evan Stade 2013/06/12 20:40:17 So if the old profile is verified, and the new pro
Ilya Sherman 2013/06/13 05:41:37 Is it better now with "merged = true;" outside of
Ilya Sherman 2013/06/13 05:41:37 Done.
Evan Stade 2013/06/13 17:48:29 my suggestion would be: // Set to true if |existi
Ilya Sherman 2013/06/14 23:58:25 Done.
}
}
merged_profiles->push_back(**iter);
@@ -757,7 +758,7 @@ bool PersonalDataManager::MergeProfile(
// If the new profile was not merged with an existing one, add it to the list.
if (!merged)
- merged_profiles->push_back(profile);
+ merged_profiles->push_back(new_profile);
return merged;
}
« no previous file with comments | « components/autofill/browser/personal_data_manager.h ('k') | components/autofill/browser/personal_data_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698