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

Unified Diff: components/autofill/core/browser/contact_info.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
Index: components/autofill/core/browser/contact_info.cc
diff --git a/components/autofill/core/browser/contact_info.cc b/components/autofill/core/browser/contact_info.cc
index 1cb1b784f0b3b1cf5af0a99a772814fa04fdb6af..4953121726d749316ae081548d99b94a419b1994 100644
--- a/components/autofill/core/browser/contact_info.cc
+++ b/components/autofill/core/browser/contact_info.cc
@@ -42,6 +42,26 @@ bool NameInfo::ParsedNamesAreEqual(const NameInfo& info) const {
family_ == info.family_;
}
+void NameInfo::OverwriteName(const NameInfo& new_name) {
+ if (!new_name.given_.empty())
+ given_ = new_name.given_;
+
+ // For the middle name, don't overwrite a full middle name with an initial.
+ if (!new_name.middle_.empty() &&
+ (middle_.size() <= 1 || new_name.middle_.size() > 1))
+ middle_ = new_name.middle_;
+
+ if (!new_name.family_.empty())
+ family_ = new_name.family_;
+
+ if (!new_name.full_.empty())
+ full_ = new_name.full_;
+}
+
+bool NameInfo::NamePartsAreEmpty() const {
+ return given_.empty() && middle_.empty() && family_.empty();
+}
+
void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(NAME_FIRST);
supported_types->insert(NAME_MIDDLE);
« no previous file with comments | « components/autofill/core/browser/contact_info.h ('k') | components/autofill/core/browser/contact_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698