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

Side by Side Diff: components/autofill/core/browser/autofill_field.cc

Issue 113403006: Update some uses of char16 to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 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/autofill_field.h" 5 #include "components/autofill/core/browser/autofill_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sha1.h" 8 #include "base/sha1.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } else if (storable_type == CREDIT_CARD_TYPE) { 255 } else if (storable_type == CREDIT_CARD_TYPE) {
256 FillCreditCardTypeSelectControl(value, field); 256 FillCreditCardTypeSelectControl(value, field);
257 } 257 }
258 } 258 }
259 259
260 // Fills in the month control |field| with |value|. |value| should be a date 260 // Fills in the month control |field| with |value|. |value| should be a date
261 // formatted as MM/YYYY. If it isn't, filling will fail. 261 // formatted as MM/YYYY. If it isn't, filling will fail.
262 bool FillMonthControl(const base::string16& value, FormFieldData* field) { 262 bool FillMonthControl(const base::string16& value, FormFieldData* field) {
263 // Autofill formats a combined date as month/year. 263 // Autofill formats a combined date as month/year.
264 std::vector<base::string16> pieces; 264 std::vector<base::string16> pieces;
265 base::SplitString(value, char16('/'), &pieces); 265 base::SplitString(value, base::char16('/'), &pieces);
266 if (pieces.size() != 2) 266 if (pieces.size() != 2)
267 return false; 267 return false;
268 268
269 // HTML5 input="month" is formatted as year-month. 269 // HTML5 input="month" is formatted as year-month.
270 base::string16 month = pieces[0]; 270 base::string16 month = pieces[0];
271 base::string16 year = pieces[1]; 271 base::string16 year = pieces[1];
272 if ((month.size() != 1 && month.size() != 2) || year.size() != 4) 272 if ((month.size() != 1 && month.size() != 2) || year.size() != 4)
273 return false; 273 return false;
274 274
275 // HTML5 input="month" expects zero-padded months. 275 // HTML5 input="month" expects zero-padded months.
276 if (month.size() == 1) 276 if (month.size() == 1)
277 month = ASCIIToUTF16("0") + month; 277 month = ASCIIToUTF16("0") + month;
278 278
279 field->value = year + ASCIIToUTF16("-") + month; 279 field->value = year + ASCIIToUTF16("-") + month;
280 return true; 280 return true;
281 } 281 }
282 282
283 // Fills |field| with the street address in |value|. Translates newlines into 283 // Fills |field| with the street address in |value|. Translates newlines into
284 // equivalent separators when necessary, i.e. when filling a single-line field. 284 // equivalent separators when necessary, i.e. when filling a single-line field.
285 void FillStreetAddress(const base::string16& value, 285 void FillStreetAddress(const base::string16& value,
286 FormFieldData* field) { 286 FormFieldData* field) {
287 if (field->form_control_type == "textarea") { 287 if (field->form_control_type == "textarea") {
288 field->value = value; 288 field->value = value;
289 return; 289 return;
290 } 290 }
291 291
292 base::string16 one_line_value; 292 base::string16 one_line_value;
293 const char16 kNewline[] = { '\n', 0 }; 293 const base::char16 kNewline[] = { '\n', 0 };
294 const base::string16 separator = 294 const base::string16 separator =
295 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_SEPARATOR); 295 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_SEPARATOR);
296 base::ReplaceChars(value, kNewline, separator, &one_line_value); 296 base::ReplaceChars(value, kNewline, separator, &one_line_value);
297 field->value = one_line_value; 297 field->value = one_line_value;
298 } 298 }
299 299
300 std::string Hash32Bit(const std::string& str) { 300 std::string Hash32Bit(const std::string& str) {
301 std::string hash_bin = base::SHA1HashString(str); 301 std::string hash_bin = base::SHA1HashString(str);
302 DCHECK_EQ(20U, hash_bin.length()); 302 DCHECK_EQ(20U, hash_bin.length());
303 303
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 FillSelectControl(type, value, app_locale, field_data); 401 FillSelectControl(type, value, app_locale, field_data);
402 else if (field_data->form_control_type == "month") 402 else if (field_data->form_control_type == "month")
403 FillMonthControl(value, field_data); 403 FillMonthControl(value, field_data);
404 else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) 404 else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS)
405 FillStreetAddress(value, field_data); 405 FillStreetAddress(value, field_data);
406 else 406 else
407 field_data->value = value; 407 field_data->value = value;
408 } 408 }
409 409
410 } // namespace autofill 410 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/address.cc ('k') | components/autofill/core/browser/autofill_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698