OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/autofill/email_field.h" | 5 #include "chrome/browser/autofill/email_field.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/autofill_regex_constants.h" |
8 #include "chrome/browser/autofill/autofill_scanner.h" | 9 #include "chrome/browser/autofill/autofill_scanner.h" |
9 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
10 | 11 |
11 namespace { | |
12 | |
13 const char kEmailRe[] = | |
14 "e.?mail" | |
15 // ja-JP | |
16 "|\xe3\x83\xa1\xe3\x83\xbc\xe3\x83\xab\xe3\x82\xa2\xe3\x83\x89\xe3\x83\xac" | |
17 "\xe3\x82\xb9" | |
18 // ru | |
19 "|\xd0\xad\xd0\xbb\xd0\xb5\xd0\xba\xd1\x82\xd1\x80\xd0\xbe\xd0\xbd\xd0\xbd" | |
20 "\xd0\xbe\xd0\xb9.?\xd0\x9f\xd0\xbe\xd1\x87\xd1\x82\xd1\x8b" | |
21 // zh-CN | |
22 "|\xe9\x82\xae\xe4\xbb\xb6|\xe9\x82\xae\xe7\xae\xb1" | |
23 // zh-TW | |
24 "|\xe9\x9b\xbb\xe9\x83\xb5\xe5\x9c\xb0\xe5\x9d\x80" | |
25 // ko-KR | |
26 "|(\xec\x9d\xb4\xeb\xa9\x94\xec\x9d\xbc|\xec\xa0\x84\xec\x9e\x90.?\xec\x9a" | |
27 "\xb0\xed\x8e\xb8|[Ee]-?mail)(.?\xec\xa3\xbc\xec\x86\x8c)?"; | |
28 | |
29 } // namespace | |
30 | |
31 // static | 12 // static |
32 FormField* EmailField::Parse(AutofillScanner* scanner) { | 13 FormField* EmailField::Parse(AutofillScanner* scanner) { |
33 const AutofillField* field; | 14 const AutofillField* field; |
34 if (ParseFieldSpecifics(scanner, UTF8ToUTF16(kEmailRe), | 15 if (ParseFieldSpecifics(scanner, UTF8ToUTF16(autofill::kEmailRe), |
35 MATCH_DEFAULT | MATCH_EMAIL, &field)) { | 16 MATCH_DEFAULT | MATCH_EMAIL, &field)) { |
36 return new EmailField(field); | 17 return new EmailField(field); |
37 } | 18 } |
38 | 19 |
39 return NULL; | 20 return NULL; |
40 } | 21 } |
41 | 22 |
42 EmailField::EmailField(const AutofillField* field) : field_(field) { | 23 EmailField::EmailField(const AutofillField* field) : field_(field) { |
43 } | 24 } |
44 | 25 |
45 bool EmailField::ClassifyField(FieldTypeMap* map) const { | 26 bool EmailField::ClassifyField(FieldTypeMap* map) const { |
46 return AddClassification(field_, EMAIL_ADDRESS, map); | 27 return AddClassification(field_, EMAIL_ADDRESS, map); |
47 } | 28 } |
OLD | NEW |