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; |
} |