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

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

Issue 2673006: AutoFill Profiles dialog implemented according to new mocks on Mac (Closed)
Patch Set: Revisions based on review comments. 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
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 == EMAIL_ADDRESS) 115 else if (field_type == NAME_FULL) {
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)
116 email_ = value; 136 email_ = value;
117 else if (field_type == COMPANY_NAME) 137 else if (field_type == COMPANY_NAME)
118 company_name_ = value; 138 company_name_ = value;
119 else 139 else
120 NOTREACHED(); 140 NOTREACHED();
121 } 141 }
122 142
123 ContactInfo::ContactInfo(const ContactInfo& contact_info) 143 ContactInfo::ContactInfo(const ContactInfo& contact_info)
124 : FormGroup(), 144 : FormGroup(),
125 first_tokens_(contact_info.first_tokens_), 145 first_tokens_(contact_info.first_tokens_),
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 370 }
351 371
352 void ContactInfo::SetLast(const string16& last) { 372 void ContactInfo::SetLast(const string16& last) {
353 last_ = last; 373 last_ = last;
354 last_tokens_.clear(); 374 last_tokens_.clear();
355 Tokenize(last, kNameSplitChars, &last_tokens_); 375 Tokenize(last, kNameSplitChars, &last_tokens_);
356 NameTokens::iterator iter; 376 NameTokens::iterator iter;
357 for (iter = last_tokens_.begin(); iter != last_tokens_.end(); ++iter) 377 for (iter = last_tokens_.begin(); iter != last_tokens_.end(); ++iter)
358 *iter = StringToLowerASCII(*iter); 378 *iter = StringToLowerASCII(*iter);
359 } 379 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm ('k') | chrome/browser/cocoa/disclosure_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698