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

Unified Diff: chrome/browser/autofill/phone_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/name_field.cc ('k') | chrome/browser/autofill/regular_expressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/phone_field.cc
diff --git a/chrome/browser/autofill/phone_field.cc b/chrome/browser/autofill/phone_field.cc
index c285508b0f54c68c7e19005e15028910bd53e802..14214a1b132a33607b39a14bbdad22c7ae14b26e 100644
--- a/chrome/browser/autofill/phone_field.cc
+++ b/chrome/browser/autofill/phone_field.cc
@@ -10,74 +10,12 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_field.h"
+#include "chrome/browser/autofill/autofill_regex_constants.h"
#include "chrome/browser/autofill/autofill_scanner.h"
#include "chrome/browser/autofill/fax_number.h"
#include "chrome/browser/autofill/home_phone_number.h"
#include "ui/base/l10n/l10n_util.h"
-namespace {
-
-const char kPhoneRe[] =
- "phone|mobile"
- // de-DE
- "|telefonnummer"
- // es
- "|telefono|tel\xc3\xa9""fono"
- // fr-FR
- "|telfixe"
- // ja-JP
- "|\xe9\x9b\xbb\xe8\xa9\xb1"
- // pt-BR, pt-PT
- "|telefone|telemovel"
- // ru
- "|\xd1\x82\xd0\xb5\xd0\xbb\xd0\xb5\xd1\x84\xd0\xbe\xd0\xbd"
- // zh-CN
- "|\xe7\x94\xb5\xe8\xaf\x9d"
- // ko-KR
- "|(\xec\xa0\x84\xed\x99\x94|\xed\x95\xb8\xeb\x93\x9c\xed\x8f\xb0|\xed\x9c"
- "\xb4\xeb\x8c\x80\xed\x8f\xb0|\xed\x9c\xb4\xeb\x8c\x80\xec\xa0\x84\xed"
- "\x99\x94)(.?\xeb\xb2\x88\xed\x98\xb8)?";
-const char kCountryCodeRe[] =
- "country.*code|ccode|_cc";
-const char kAreaCodeNotextRe[] =
- "^\\($";
-const char kAreaCodeRe[] =
- "area.*code|acode|area"
- // ko-KR
- "|\xec\xa7\x80\xec\x97\xad.?\xeb\xb2\x88\xed\x98\xb8";
-const char kFaxRe[] =
- "fax"
- // fr-FR
- "|t\xc3\xa9l\xc3\xa9""copie|telecopie"
- // ja-JP
- "|\xe3\x83\x95\xe3\x82\xa1\xe3\x83\x83\xe3\x82\xaf\xe3\x82\xb9"
- // ru
- "|\xd1\x84\xd0\xb0\xd0\xba\xd1\x81"
- // zh-CN
- "|\xe4\xbc\xa0\xe7\x9c\x9f"
- // zh-TW
- "|\xe5\x82\xb3\xe7\x9c\x9f"
- // ko-KR
- "|\xed\x8c\xa9\xec\x8a\xa4(.?\xeb\xb2\x88\xed\x98\xb8)?";
-const char kPhonePrefixSeparatorRe[] =
- "^-$|^\\)$";
-const char kPhoneSuffixSeparatorRe[] =
- "^-$";
-const char kPhonePrefixRe[] =
- "prefix|exchange"
- // fr-FR
- "|preselection"
- // pt-BR, pt-PT
- "|ddd";
-const char kPhoneSuffixRe[] =
- "suffix";
-const char kPhoneExtensionRe[] =
- "\\bext|ext\\b|extension"
- // pt-BR, pt-PT
- "|ramal";
-
-} // namespace
-
// Phone field grammars - first matched grammar will be parsed. Grammars are
// separated by { REGEX_SEPARATOR, FIELD_NONE, 0 }. Suffix and extension are
// parsed separately unless they are necessary parts of the match.
@@ -239,12 +177,12 @@ bool PhoneField::ClassifyField(FieldTypeMap* map) const {
string16 PhoneField::GetCountryRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kCountryCodeRe);
+ return UTF8ToUTF16(autofill::kCountryCodeRe);
}
string16 PhoneField::GetAreaRegex() const {
// This one is the same for Home and Fax numbers.
- string16 area_code = UTF8ToUTF16(kAreaCodeRe);
+ string16 area_code = UTF8ToUTF16(autofill::kAreaCodeRe);
area_code.append(ASCIIToUTF16("|")); // Regexp separator.
area_code.append(GetAreaNoTextRegex());
return area_code;
@@ -252,14 +190,14 @@ string16 PhoneField::GetAreaRegex() const {
string16 PhoneField::GetAreaNoTextRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kAreaCodeNotextRe);
+ return UTF8ToUTF16(autofill::kAreaCodeNotextRe);
}
string16 PhoneField::GetPhoneRegex() const {
if (phone_type_ == HOME_PHONE)
- return UTF8ToUTF16(kPhoneRe);
+ return UTF8ToUTF16(autofill::kPhoneRe);
else if (phone_type_ == FAX_PHONE)
- return UTF8ToUTF16(kFaxRe);
+ return UTF8ToUTF16(autofill::kFaxRe);
else
NOTREACHED();
return string16();
@@ -267,27 +205,27 @@ string16 PhoneField::GetPhoneRegex() const {
string16 PhoneField::GetPrefixSeparatorRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kPhonePrefixSeparatorRe);
+ return UTF8ToUTF16(autofill::kPhonePrefixSeparatorRe);
}
string16 PhoneField::GetPrefixRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kPhonePrefixRe);
+ return UTF8ToUTF16(autofill::kPhonePrefixRe);
}
string16 PhoneField::GetSuffixSeparatorRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kPhoneSuffixSeparatorRe);
+ return UTF8ToUTF16(autofill::kPhoneSuffixSeparatorRe);
}
string16 PhoneField::GetSuffixRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kPhoneSuffixRe);
+ return UTF8ToUTF16(autofill::kPhoneSuffixRe);
}
string16 PhoneField::GetExtensionRegex() const {
// This one is the same for Home and Fax numbers.
- return UTF8ToUTF16(kPhoneExtensionRe);
+ return UTF8ToUTF16(autofill::kPhoneExtensionRe);
}
string16 PhoneField::GetRegExp(RegexType regex_id) const {
« no previous file with comments | « chrome/browser/autofill/name_field.cc ('k') | chrome/browser/autofill/regular_expressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698