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

Unified Diff: components/autofill/core/browser/autofill_profile.cc

Issue 1973873002: [Autofill] Improve the merging of two profiles' names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 7 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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_profile.cc
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc
index 70b8519b09ab0c34c3f34b14a514b0ac8f7ce194..0f69602a9265b7a33035cbcbb7552847a1b150ad 100644
--- a/components/autofill/core/browser/autofill_profile.cc
+++ b/components/autofill/core/browser/autofill_profile.cc
@@ -499,7 +499,9 @@ bool AutofillProfile::OverwriteName(const NameInfo& imported_name,
l10n::CaseInsensitiveCompare compare;
AutofillType type = AutofillType(NAME_FULL);
base::string16 full_name = name_.GetInfo(type, app_locale);
- if (compare.StringsEqual(full_name,
+ // Always overwrite if the name parts are empty.
+ if (!name_.NamePartsAreEmpty() &&
+ compare.StringsEqual(full_name,
imported_name.GetInfo(type, app_locale))) {
// The imported name has the same full name string as the name for this
// profile. Because full names are _heuristically_ parsed into
@@ -514,7 +516,7 @@ bool AutofillProfile::OverwriteName(const NameInfo& imported_name,
return false;
}
- name_ = imported_name;
+ name_.OverwriteName(imported_name);
return true;
}
@@ -585,6 +587,7 @@ bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
ServerFieldTypeSet field_types, other_field_types;
GetNonEmptyTypes(app_locale, &field_types);
profile.GetNonEmptyTypes(app_locale, &other_field_types);
+
// The address needs to be compared line by line to take into account the
// logic for empty fields implemented in the loop.
field_types.erase(ADDRESS_HOME_STREET_ADDRESS);
@@ -641,6 +644,7 @@ bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
}
continue;
}
+
// Special case for the state to support abbreviations. Currently only the
// US states are supported.
if (field_type == ADDRESS_HOME_STATE) {
@@ -664,6 +668,20 @@ bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
}
}
+ // Special case for middle name to support initials.
+ if (field_type == NAME_MIDDLE) {
+ base::string16 middle_name = GetRawInfo(NAME_MIDDLE);
+ base::string16 profile_middle_name = profile.GetRawInfo(NAME_MIDDLE);
+ DCHECK(!middle_name.empty());
+ DCHECK(!profile_middle_name.empty());
+ // If one of the two middle names is an initial that matches the first
+ // letter of the other middle name, they are considered equivalent.
+ if ((middle_name.size() == 1 || profile_middle_name.size() == 1) &&
+ middle_name[0] == profile_middle_name[0]) {
+ continue;
+ }
+ }
+
if (!compare.StringsEqual(profile.GetRawInfo(field_type),
GetRawInfo(field_type))) {
return false;
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698