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

Side by Side 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 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/contact_info.h" 5 #include "components/autofill/core/browser/contact_info.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 10
(...skipping 24 matching lines...) Expand all
35 family_ = info.family_; 35 family_ = info.family_;
36 full_ = info.full_; 36 full_ = info.full_;
37 return *this; 37 return *this;
38 } 38 }
39 39
40 bool NameInfo::ParsedNamesAreEqual(const NameInfo& info) const { 40 bool NameInfo::ParsedNamesAreEqual(const NameInfo& info) const {
41 return given_ == info.given_ && middle_ == info.middle_ && 41 return given_ == info.given_ && middle_ == info.middle_ &&
42 family_ == info.family_; 42 family_ == info.family_;
43 } 43 }
44 44
45 void NameInfo::OverwriteName(const NameInfo& new_name) {
46 if (!new_name.given_.empty())
47 given_ = new_name.given_;
48
49 // For the middle name, don't overwrite a full middle name with an initial.
50 if (!new_name.middle_.empty() &&
51 (middle_.size() <= 1 || new_name.middle_.size() > 1))
52 middle_ = new_name.middle_;
53
54 if (!new_name.family_.empty())
55 family_ = new_name.family_;
56
57 if (!new_name.full_.empty())
58 full_ = new_name.full_;
59 }
60
61 bool NameInfo::NamePartsAreEmpty() const {
62 return given_.empty() && middle_.empty() && family_.empty();
63 }
64
45 void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { 65 void NameInfo::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
46 supported_types->insert(NAME_FIRST); 66 supported_types->insert(NAME_FIRST);
47 supported_types->insert(NAME_MIDDLE); 67 supported_types->insert(NAME_MIDDLE);
48 supported_types->insert(NAME_LAST); 68 supported_types->insert(NAME_LAST);
49 supported_types->insert(NAME_MIDDLE_INITIAL); 69 supported_types->insert(NAME_MIDDLE_INITIAL);
50 supported_types->insert(NAME_FULL); 70 supported_types->insert(NAME_FULL);
51 } 71 }
52 72
53 base::string16 NameInfo::GetRawInfo(ServerFieldType type) const { 73 base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
54 DCHECK_EQ(NAME, AutofillType(type).group()); 74 DCHECK_EQ(NAME, AutofillType(type).group());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return base::string16(); 242 return base::string16();
223 } 243 }
224 244
225 void CompanyInfo::SetRawInfo(ServerFieldType type, 245 void CompanyInfo::SetRawInfo(ServerFieldType type,
226 const base::string16& value) { 246 const base::string16& value) {
227 DCHECK_EQ(COMPANY_NAME, type); 247 DCHECK_EQ(COMPANY_NAME, type);
228 company_name_ = value; 248 company_name_ = value;
229 } 249 }
230 250
231 } // namespace autofill 251 } // namespace autofill
OLDNEW
« 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