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

Side by Side Diff: chrome/browser/autofill/contact_info.cc

Issue 2849008: AutoFill duplicate NAME_FULL checks. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/autofill/contact_info.h" 5 #include "chrome/browser/autofill/contact_info.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/autofill/autofill_type.h" 9 #include "chrome/browser/autofill/autofill_type.h"
10 #include "chrome/browser/autofill/field_types.h" 10 #include "chrome/browser/autofill/field_types.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 AutoFillFieldType field_type = type.field_type(); 105 AutoFillFieldType field_type = type.field_type();
106 DCHECK(type.group() == AutoFillType::CONTACT_INFO); 106 DCHECK(type.group() == AutoFillType::CONTACT_INFO);
107 if (field_type == NAME_FIRST) 107 if (field_type == NAME_FIRST)
108 SetFirst(value); 108 SetFirst(value);
109 else if (field_type == NAME_MIDDLE || field_type == NAME_MIDDLE_INITIAL) 109 else if (field_type == NAME_MIDDLE || field_type == NAME_MIDDLE_INITIAL)
110 SetMiddle(value); 110 SetMiddle(value);
111 else if (field_type == NAME_LAST) 111 else if (field_type == NAME_LAST)
112 SetLast(value); 112 SetLast(value);
113 else if (field_type == NAME_SUFFIX) 113 else if (field_type == NAME_SUFFIX)
114 set_suffix(value); 114 set_suffix(value);
115 else if (field_type == NAME_FULL) { 115 else if (field_type == EMAIL_ADDRESS)
116 // TODO(dhollowa): This needs formal spec on how names are split from
117 // unstructured string to structured fields.
118 std::vector<string16> values;
119 SplitStringAlongWhitespace(value, &values);
120 if (values.size() == 1) {
121 SetInfo(AutoFillType(NAME_FIRST), values[0]);
122 } else if (values.size() == 2) {
123 SetInfo(AutoFillType(NAME_FIRST), values[0]);
124 SetInfo(AutoFillType(NAME_LAST), values[1]);
125 } else if (values.size() == 3) {
126 SetInfo(AutoFillType(NAME_FIRST), values[0]);
127 SetInfo(AutoFillType(NAME_MIDDLE), values[1]);
128 SetInfo(AutoFillType(NAME_LAST), values[2]);
129 } else if (values.size() >= 4) {
130 SetInfo(AutoFillType(NAME_FIRST), values[0]);
131 SetInfo(AutoFillType(NAME_MIDDLE), values[1]);
132 SetInfo(AutoFillType(NAME_LAST), values[2]);
133 SetInfo(AutoFillType(NAME_SUFFIX), values[3]);
134 }
135 } else if (field_type == EMAIL_ADDRESS)
136 email_ = value; 116 email_ = value;
137 else if (field_type == COMPANY_NAME) 117 else if (field_type == COMPANY_NAME)
138 company_name_ = value; 118 company_name_ = value;
139 else if (field_type == NAME_FULL) 119 else if (field_type == NAME_FULL)
140 SetFullName(value); 120 SetFullName(value);
141 else 121 else
142 NOTREACHED(); 122 NOTREACHED();
143 } 123 }
144 124
145 ContactInfo::ContactInfo(const ContactInfo& contact_info) 125 ContactInfo::ContactInfo(const ContactInfo& contact_info)
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 SetLast(full_name_tokens.back()); 376 SetLast(full_name_tokens.back());
397 if (full_name_tokens.size() > 2) { 377 if (full_name_tokens.size() > 2) {
398 full_name_tokens.erase(full_name_tokens.begin()); 378 full_name_tokens.erase(full_name_tokens.begin());
399 full_name_tokens.pop_back(); 379 full_name_tokens.pop_back();
400 SetMiddle(JoinString(full_name_tokens, ' ')); 380 SetMiddle(JoinString(full_name_tokens, ' '));
401 } 381 }
402 } 382 }
403 } 383 }
404 } 384 }
405 385
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698