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

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

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/contact_info.h" 5 #include "components/autofill/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 void NameInfo::GetSupportedTypes(FieldTypeSet* supported_types) const { 45 void NameInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
46 supported_types->insert(NAME_FIRST); 46 supported_types->insert(NAME_FIRST);
47 supported_types->insert(NAME_MIDDLE); 47 supported_types->insert(NAME_MIDDLE);
48 supported_types->insert(NAME_LAST); 48 supported_types->insert(NAME_LAST);
49 supported_types->insert(NAME_MIDDLE_INITIAL); 49 supported_types->insert(NAME_MIDDLE_INITIAL);
50 supported_types->insert(NAME_FULL); 50 supported_types->insert(NAME_FULL);
51 } 51 }
52 52
53 string16 NameInfo::GetRawInfo(AutofillFieldType type) const { 53 base::string16 NameInfo::GetRawInfo(AutofillFieldType type) const {
54 if (type == NAME_FIRST) 54 if (type == NAME_FIRST)
55 return first(); 55 return first();
56 56
57 if (type == NAME_MIDDLE) 57 if (type == NAME_MIDDLE)
58 return middle(); 58 return middle();
59 59
60 if (type == NAME_LAST) 60 if (type == NAME_LAST)
61 return last(); 61 return last();
62 62
63 if (type == NAME_MIDDLE_INITIAL) 63 if (type == NAME_MIDDLE_INITIAL)
64 return MiddleInitial(); 64 return MiddleInitial();
65 65
66 if (type == NAME_FULL) 66 if (type == NAME_FULL)
67 return FullName(); 67 return FullName();
68 68
69 return string16(); 69 return base::string16();
70 } 70 }
71 71
72 void NameInfo::SetRawInfo(AutofillFieldType type, const string16& value) { 72 void NameInfo::SetRawInfo(AutofillFieldType type, const base::string16& value) {
73 DCHECK_EQ(AutofillType::NAME, AutofillType(type).group()); 73 DCHECK_EQ(AutofillType::NAME, AutofillType(type).group());
74 if (type == NAME_FIRST) 74 if (type == NAME_FIRST)
75 first_ = value; 75 first_ = value;
76 else if (type == NAME_MIDDLE || type == NAME_MIDDLE_INITIAL) 76 else if (type == NAME_MIDDLE || type == NAME_MIDDLE_INITIAL)
77 middle_ = value; 77 middle_ = value;
78 else if (type == NAME_LAST) 78 else if (type == NAME_LAST)
79 last_ = value; 79 last_ = value;
80 else if (type == NAME_FULL) 80 else if (type == NAME_FULL)
81 SetFullName(value); 81 SetFullName(value);
82 else 82 else
83 NOTREACHED(); 83 NOTREACHED();
84 } 84 }
85 85
86 string16 NameInfo::FullName() const { 86 base::string16 NameInfo::FullName() const {
87 std::vector<string16> full_name; 87 std::vector<base::string16> full_name;
88 if (!first_.empty()) 88 if (!first_.empty())
89 full_name.push_back(first_); 89 full_name.push_back(first_);
90 90
91 if (!middle_.empty()) 91 if (!middle_.empty())
92 full_name.push_back(middle_); 92 full_name.push_back(middle_);
93 93
94 if (!last_.empty()) 94 if (!last_.empty())
95 full_name.push_back(last_); 95 full_name.push_back(last_);
96 96
97 return JoinString(full_name, ' '); 97 return JoinString(full_name, ' ');
98 } 98 }
99 99
100 string16 NameInfo::MiddleInitial() const { 100 base::string16 NameInfo::MiddleInitial() const {
101 if (middle_.empty()) 101 if (middle_.empty())
102 return string16(); 102 return base::string16();
103 103
104 string16 middle_name(middle()); 104 base::string16 middle_name(middle());
105 string16 initial; 105 base::string16 initial;
106 initial.push_back(middle_name[0]); 106 initial.push_back(middle_name[0]);
107 return initial; 107 return initial;
108 } 108 }
109 109
110 void NameInfo::SetFullName(const string16& full) { 110 void NameInfo::SetFullName(const base::string16& full) {
111 // Clear the names. 111 // Clear the names.
112 first_ = string16(); 112 first_ = base::string16();
113 middle_ = string16(); 113 middle_ = base::string16();
114 last_ = string16(); 114 last_ = base::string16();
115 115
116 std::vector<string16> full_name_tokens; 116 std::vector<base::string16> full_name_tokens;
117 Tokenize(full, ASCIIToUTF16(" "), &full_name_tokens); 117 Tokenize(full, ASCIIToUTF16(" "), &full_name_tokens);
118 118
119 // There are four possibilities: empty; first name; first and last names; 119 // There are four possibilities: empty; first name; first and last names;
120 // first, middle (possibly multiple strings) and then the last name. 120 // first, middle (possibly multiple strings) and then the last name.
121 if (full_name_tokens.size() > 0) { 121 if (full_name_tokens.size() > 0) {
122 first_ = full_name_tokens[0]; 122 first_ = full_name_tokens[0];
123 if (full_name_tokens.size() > 1) { 123 if (full_name_tokens.size() > 1) {
124 last_ = full_name_tokens.back(); 124 last_ = full_name_tokens.back();
125 if (full_name_tokens.size() > 2) { 125 if (full_name_tokens.size() > 2) {
126 full_name_tokens.erase(full_name_tokens.begin()); 126 full_name_tokens.erase(full_name_tokens.begin());
(...skipping 17 matching lines...) Expand all
144 return *this; 144 return *this;
145 145
146 email_ = info.email_; 146 email_ = info.email_;
147 return *this; 147 return *this;
148 } 148 }
149 149
150 void EmailInfo::GetSupportedTypes(FieldTypeSet* supported_types) const { 150 void EmailInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
151 supported_types->insert(EMAIL_ADDRESS); 151 supported_types->insert(EMAIL_ADDRESS);
152 } 152 }
153 153
154 string16 EmailInfo::GetRawInfo(AutofillFieldType type) const { 154 base::string16 EmailInfo::GetRawInfo(AutofillFieldType type) const {
155 if (type == EMAIL_ADDRESS) 155 if (type == EMAIL_ADDRESS)
156 return email_; 156 return email_;
157 157
158 return string16(); 158 return base::string16();
159 } 159 }
160 160
161 void EmailInfo::SetRawInfo(AutofillFieldType type, const string16& value) { 161 void EmailInfo::SetRawInfo(AutofillFieldType type,
162 const base::string16& value) {
162 DCHECK_EQ(EMAIL_ADDRESS, type); 163 DCHECK_EQ(EMAIL_ADDRESS, type);
163 email_ = value; 164 email_ = value;
164 } 165 }
165 166
166 CompanyInfo::CompanyInfo() {} 167 CompanyInfo::CompanyInfo() {}
167 168
168 CompanyInfo::CompanyInfo(const CompanyInfo& info) : FormGroup() { 169 CompanyInfo::CompanyInfo(const CompanyInfo& info) : FormGroup() {
169 *this = info; 170 *this = info;
170 } 171 }
171 172
172 CompanyInfo::~CompanyInfo() {} 173 CompanyInfo::~CompanyInfo() {}
173 174
174 CompanyInfo& CompanyInfo::operator=(const CompanyInfo& info) { 175 CompanyInfo& CompanyInfo::operator=(const CompanyInfo& info) {
175 if (this == &info) 176 if (this == &info)
176 return *this; 177 return *this;
177 178
178 company_name_ = info.company_name_; 179 company_name_ = info.company_name_;
179 return *this; 180 return *this;
180 } 181 }
181 182
182 void CompanyInfo::GetSupportedTypes(FieldTypeSet* supported_types) const { 183 void CompanyInfo::GetSupportedTypes(FieldTypeSet* supported_types) const {
183 supported_types->insert(COMPANY_NAME); 184 supported_types->insert(COMPANY_NAME);
184 } 185 }
185 186
186 string16 CompanyInfo::GetRawInfo(AutofillFieldType type) const { 187 base::string16 CompanyInfo::GetRawInfo(AutofillFieldType type) const {
187 if (type == COMPANY_NAME) 188 if (type == COMPANY_NAME)
188 return company_name_; 189 return company_name_;
189 190
190 return string16(); 191 return base::string16();
191 } 192 }
192 193
193 void CompanyInfo::SetRawInfo(AutofillFieldType type, const string16& value) { 194 void CompanyInfo::SetRawInfo(AutofillFieldType type,
195 const base::string16& value) {
194 DCHECK_EQ(COMPANY_NAME, type); 196 DCHECK_EQ(COMPANY_NAME, type);
195 company_name_ = value; 197 company_name_ = value;
196 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698