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

Unified Diff: components/autofill/core/browser/validation.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, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/validation.cc
diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc
index 62509cbfbb553ce82534a435c894dc39aff0079e..c1b11d9709e9a14d2978a2713307f4abbef2582f 100644
--- a/components/autofill/core/browser/validation.cc
+++ b/components/autofill/core/browser/validation.cc
@@ -13,14 +13,6 @@
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/state_names.h"
-using base::StringPiece16;
-
-namespace {
-
-// The separator characters for SSNs.
-const base::char16 kSSNSeparators[] = {' ', '-', 0};
-
-} // namespace
namespace autofill {
@@ -156,7 +148,7 @@ bool IsValidZip(const base::string16& text) {
bool IsSSN(const base::string16& text) {
base::string16 number_string;
- base::RemoveChars(text, kSSNSeparators, &number_string);
+ base::RemoveChars(text, base::ASCIIToUTF16("- "), &number_string);
// A SSN is of the form AAA-GG-SSSS (A = area number, G = group number, S =
// serial number). The validation we do here is simply checking if the area,
@@ -186,8 +178,8 @@ bool IsSSN(const base::string16& text) {
return false;
int area;
- if (!base::StringToInt(StringPiece16(number_string.begin(),
- number_string.begin() + 3),
+ if (!base::StringToInt(base::StringPiece16(number_string.begin(),
+ number_string.begin() + 3),
&area)) {
return false;
}
@@ -198,16 +190,16 @@ bool IsSSN(const base::string16& text) {
}
int group;
- if (!base::StringToInt(StringPiece16(number_string.begin() + 3,
- number_string.begin() + 5),
+ if (!base::StringToInt(base::StringPiece16(number_string.begin() + 3,
+ number_string.begin() + 5),
&group)
|| group == 0) {
return false;
}
int serial;
- if (!base::StringToInt(StringPiece16(number_string.begin() + 5,
- number_string.begin() + 9),
+ if (!base::StringToInt(base::StringPiece16(number_string.begin() + 5,
+ number_string.begin() + 9),
&serial)
|| serial == 0) {
return false;
« no previous file with comments | « components/autofill/core/browser/phone_number.cc ('k') | components/cloud_devices/common/cloud_devices_urls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698