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

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

Issue 296593003: Make various string_util functions take StringPieces instead of char[]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resync Created 6 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 | 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 // Fills |field| with the street address in |value|. Translates newlines into 285 // Fills |field| with the street address in |value|. Translates newlines into
286 // equivalent separators when necessary, i.e. when filling a single-line field. 286 // equivalent separators when necessary, i.e. when filling a single-line field.
287 void FillStreetAddress(const base::string16& value, 287 void FillStreetAddress(const base::string16& value,
288 FormFieldData* field) { 288 FormFieldData* field) {
289 if (field->form_control_type == "textarea") { 289 if (field->form_control_type == "textarea") {
290 field->value = value; 290 field->value = value;
291 return; 291 return;
292 } 292 }
293 293
294 base::string16 one_line_value; 294 const base::string16& separator =
295 const base::char16 kNewline[] = { '\n', 0 };
296 const base::string16 separator =
297 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_SEPARATOR); 295 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_LINE_SEPARATOR);
298 base::ReplaceChars(value, kNewline, separator, &one_line_value); 296 base::ReplaceChars(value, base::ASCIIToUTF16("\n"), separator, &field->value);
299 field->value = one_line_value;
300 } 297 }
301 298
302 std::string Hash32Bit(const std::string& str) { 299 std::string Hash32Bit(const std::string& str) {
303 std::string hash_bin = base::SHA1HashString(str); 300 std::string hash_bin = base::SHA1HashString(str);
304 DCHECK_EQ(20U, hash_bin.length()); 301 DCHECK_EQ(20U, hash_bin.length());
305 302
306 uint32 hash32 = ((hash_bin[0] & 0xFF) << 24) | 303 uint32 hash32 = ((hash_bin[0] & 0xFF) << 24) |
307 ((hash_bin[1] & 0xFF) << 16) | 304 ((hash_bin[1] & 0xFF) << 16) |
308 ((hash_bin[2] & 0xFF) << 8) | 305 ((hash_bin[2] & 0xFF) << 8) |
309 (hash_bin[3] & 0xFF); 306 (hash_bin[3] & 0xFF);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) { 404 } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) {
408 FillStreetAddress(value, field_data); 405 FillStreetAddress(value, field_data);
409 return true; 406 return true;
410 } 407 }
411 408
412 field_data->value = value; 409 field_data->value = value;
413 return true; 410 return true;
414 } 411 }
415 412
416 } // namespace autofill 413 } // namespace autofill
OLDNEW
« no previous file with comments | « chromeos/system/name_value_pairs_parser.cc ('k') | components/autofill/core/browser/autofill_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698