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

Unified Diff: components/autofill/core/browser/name_field.cc

Issue 1453193002: autofill: switch autofill_regexes to RE2 library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reviews Created 5 years 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/name_field.cc
diff --git a/components/autofill/core/browser/name_field.cc b/components/autofill/core/browser/name_field.cc
index 8532de13c3a1b1f7bd25d04c3a3b90fdd7856a2a..e1e093462de5dd11ef75e3bc49516602c5e5402d 100644
--- a/components/autofill/core/browser/name_field.cc
+++ b/components/autofill/core/browser/name_field.cc
@@ -6,13 +6,10 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_regex_constants.h"
#include "components/autofill/core/browser/autofill_scanner.h"
#include "components/autofill/core/browser/autofill_type.h"
-using base::UTF8ToUTF16;
-
namespace autofill {
namespace {
@@ -80,7 +77,7 @@ bool NameField::ClassifyField(ServerFieldTypeMap* map) const {
scoped_ptr<FullNameField> FullNameField::Parse(AutofillScanner* scanner) {
// Exclude e.g. "username" or "nickname" fields.
scanner->SaveCursor();
- bool should_ignore = ParseField(scanner, UTF8ToUTF16(kNameIgnoredRe), NULL);
+ bool should_ignore = ParseField(scanner, kNameIgnoredRe, NULL);
scanner->Rewind();
if (should_ignore)
return NULL;
@@ -89,7 +86,7 @@ scoped_ptr<FullNameField> FullNameField::Parse(AutofillScanner* scanner) {
// for example, Travelocity_Edit travel profile.html contains a field
// "Travel Profile Name".
AutofillField* field = NULL;
- if (ParseField(scanner, UTF8ToUTF16(kNameRe), &field))
+ if (ParseField(scanner, kNameRe, &field))
return make_scoped_ptr(new FullNameField(field));
return NULL;
@@ -110,7 +107,7 @@ scoped_ptr<FirstLastNameField> FirstLastNameField::ParseSpecificName(
scanner->SaveCursor();
AutofillField* next = NULL;
- if (ParseField(scanner, UTF8ToUTF16(kNameSpecificRe), &v->first_name_) &&
+ if (ParseField(scanner, kNameSpecificRe, &v->first_name_) &&
ParseEmptyLabel(scanner, &next)) {
if (ParseEmptyLabel(scanner, &v->last_name_)) {
// There are three name fields; assume that the middle one is a
@@ -147,13 +144,12 @@ scoped_ptr<FirstLastNameField> FirstLastNameField::ParseComponentNames(
// Allow name fields to appear in any order.
while (!scanner->IsEnd()) {
// Skip over any unrelated fields, e.g. "username" or "nickname".
- if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kNameIgnoredRe),
+ if (ParseFieldSpecifics(scanner, kNameIgnoredRe,
MATCH_DEFAULT | MATCH_SELECT, NULL)) {
continue;
}
- if (!v->first_name_ &&
- ParseField(scanner, UTF8ToUTF16(kFirstNameRe), &v->first_name_)) {
+ if (!v->first_name_ && ParseField(scanner, kFirstNameRe, &v->first_name_)) {
continue;
}
@@ -163,18 +159,17 @@ scoped_ptr<FirstLastNameField> FirstLastNameField::ParseComponentNames(
// "txtmiddlename"); such a field probably actually represents a
// middle initial.
if (!v->middle_name_ &&
- ParseField(scanner, UTF8ToUTF16(kMiddleInitialRe), &v->middle_name_)) {
+ ParseField(scanner, kMiddleInitialRe, &v->middle_name_)) {
v->middle_initial_ = true;
continue;
}
if (!v->middle_name_ &&
- ParseField(scanner, UTF8ToUTF16(kMiddleNameRe), &v->middle_name_)) {
+ ParseField(scanner, kMiddleNameRe, &v->middle_name_)) {
continue;
}
- if (!v->last_name_ &&
- ParseField(scanner, UTF8ToUTF16(kLastNameRe), &v->last_name_)) {
+ if (!v->last_name_ && ParseField(scanner, kLastNameRe, &v->last_name_)) {
continue;
}

Powered by Google App Engine
This is Rietveld 408576698