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

Unified Diff: chrome/browser/autofill/name_field.cc

Issue 7891020: Make autofill regular expressions unicode again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extra gyp change Created 9 years, 3 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
« no previous file with comments | « chrome/browser/autofill/email_field.cc ('k') | chrome/browser/autofill/phone_field.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/name_field.cc
diff --git a/chrome/browser/autofill/name_field.cc b/chrome/browser/autofill/name_field.cc
index b4203645d85d2391d5fcc1c6fa01ec4e98fdff78..6057da02fbb52b49f41fbd00740f4a85e6192374 100644
--- a/chrome/browser/autofill/name_field.cc
+++ b/chrome/browser/autofill/name_field.cc
@@ -8,84 +8,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/autofill/autofill_regex_constants.h"
#include "chrome/browser/autofill/autofill_scanner.h"
#include "chrome/browser/autofill/autofill_type.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
-// The UTF-8 version of these regular expressions are in
-// regular_expressions.txt.
-const char kNameIgnoredRe[] =
- "user.?name|user.?id|nickname|maiden name|title|prefix|suffix"
- // de-DE
- "|vollst\xc3\xa4ndiger.?name"
- // zh-CN
- "|\xe7\x94\xa8\xe6\x88\xb7\xe5\x90\x8d"
- // ko-KR
- "|(\xec\x82\xac\xec\x9a\xa9\xec\x9e\x90.?)?\xec\x95\x84\xec\x9d\xb4\xeb"
- "\x94\x94|\xec\x82\xac\xec\x9a\xa9\xec\x9e\x90.?ID";
-const char kNameRe[] =
- "^name|full.?name|your.?name|customer.?name|firstandlastname|bill.?name"
- "|ship.?name"
- // es
- "|nombre.*y.*apellidos"
- // fr-FR
- "|^nom"
- // ja-JP
- "|\xe3\x81\x8a\xe5\x90\x8d\xe5\x89\x8d|\xe6\xb0\x8f\xe5\x90\x8d"
- // pt-BR, pt-PT
- "|^nome"
- // zh-CN
- "|\xe5\xa7\x93\xe5\x90\x8d"
- // ko-KR
- "|\xec\x84\xb1\xeb\xaa\x85";
-const char kNameSpecificRe[] =
- "^name"
- // fr-FR
- "|^nom"
- // pt-BR, pt-PT
- "|^nome";
-const char kFirstNameRe[] =
- "first.*name|initials|fname|first$"
- // de-DE
- "|vorname"
- // es
- "|nombre"
- // fr-FR
- "|forename|pr\xc3\xa9nom|prenom"
- // ja-JP
- "|\xe5\x90\x8d"
- // pt-BR, pt-PT
- "|nome"
- // ru
- "|\xd0\x98\xd0\xbc\xd1\x8f"
- // ko-KR
- "|\xec\x9d\xb4\xeb\xa6\x84";
-const char kMiddleInitialRe[] = "middle.*initial|m\\.i\\.|mi$|\\bmi\\b";
-const char kMiddleNameRe[] =
- "middle.*name|mname|middle$"
- // es
- "|apellido.?materno|lastlastname";
-const char kLastNameRe[] =
- "last.*name|lname|surname|last$|secondname"
- // de-DE
- "|nachname"
- // es
- "|apellido"
- // fr-FR
- "|famille|^nom"
- // it-IT
- "|cognome"
- // ja-JP
- "|\xe5\xa7\x93"
- // pt-BR, pt-PT
- "|morada|apelidos|surename|sobrenome"
- // ru
- "|\xd0\xa4\xd0\xb0\xd0\xbc\xd0\xb8\xd0\xbb\xd0\xb8\xd1\x8f"
- // ko-KR
- "|\xec\x84\xb1[^\xeb\xaa\x85]?";
-
// A form field that can parse a full name field.
class FullNameField : public NameField {
public:
@@ -146,7 +75,8 @@ bool NameField::ClassifyField(FieldTypeMap* map) const {
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,
+ UTF8ToUTF16(autofill::kNameIgnoredRe), NULL);
scanner->Rewind();
if (should_ignore)
return NULL;
@@ -155,7 +85,7 @@ FullNameField* FullNameField::Parse(AutofillScanner* scanner) {
// for example, Travelocity_Edit travel profile.html contains a field
// "Travel Profile Name".
const AutofillField* field = NULL;
- if (ParseField(scanner, UTF8ToUTF16(kNameRe), &field))
+ if (ParseField(scanner, UTF8ToUTF16(autofill::kNameRe), &field))
return new FullNameField(field);
return NULL;
@@ -178,7 +108,7 @@ FirstLastNameField* FirstLastNameField::ParseSpecificName(
const AutofillField* next;
if (ParseField(scanner,
- UTF8ToUTF16(kNameSpecificRe), &v->first_name_) &&
+ UTF8ToUTF16(autofill::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
@@ -214,13 +144,14 @@ 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, UTF8ToUTF16(autofill::kNameIgnoredRe),
MATCH_DEFAULT | MATCH_SELECT, NULL)) {
continue;
}
if (!v->first_name_ &&
- ParseField(scanner, UTF8ToUTF16(kFirstNameRe), &v->first_name_)) {
+ ParseField(scanner, UTF8ToUTF16(autofill::kFirstNameRe),
+ &v->first_name_)) {
continue;
}
@@ -230,18 +161,21 @@ 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, UTF8ToUTF16(autofill::kMiddleInitialRe),
+ &v->middle_name_)) {
v->middle_initial_ = true;
continue;
}
if (!v->middle_name_ &&
- ParseField(scanner, UTF8ToUTF16(kMiddleNameRe), &v->middle_name_)) {
+ ParseField(scanner, UTF8ToUTF16(autofill::kMiddleNameRe),
+ &v->middle_name_)) {
continue;
}
if (!v->last_name_ &&
- ParseField(scanner, UTF8ToUTF16(kLastNameRe), &v->last_name_)) {
+ ParseField(scanner, UTF8ToUTF16(autofill::kLastNameRe),
+ &v->last_name_)) {
continue;
}
« no previous file with comments | « chrome/browser/autofill/email_field.cc ('k') | chrome/browser/autofill/phone_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698