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 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ |
6 #define CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ | 6 #define CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/autofill/autofill_type.h" | 13 #include "chrome/browser/autofill/autofill_type.h" |
14 #include "chrome/browser/autofill/form_field.h" | 14 #include "chrome/browser/autofill/form_field.h" |
15 #include "chrome/browser/autofill/phone_number.h" | 15 #include "chrome/browser/autofill/phone_number.h" |
16 | 16 |
17 class AutofillField; | 17 class AutofillField; |
18 class AutofillScanner; | 18 class AutofillScanner; |
19 | 19 |
20 // A phone number in one of the following formats: | 20 // A phone number in one of the following formats: |
21 // - area code, prefix, suffix | 21 // - area code, prefix, suffix |
22 // - area code, number | 22 // - area code, number |
23 // - number | 23 // - number |
24 class PhoneField : public FormField { | 24 class PhoneField : public FormField { |
25 public: | 25 public: |
26 virtual ~PhoneField(); | 26 virtual ~PhoneField(); |
27 | 27 |
28 static FormField* Parse(AutofillScanner* scanner, bool is_ecml); | 28 static FormField* Parse(AutofillScanner* scanner); |
29 static FormField* ParseECML(AutofillScanner* scanner); | |
30 | 29 |
31 protected: | 30 protected: |
32 // FormField: | 31 // FormField: |
33 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; | 32 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; |
34 | 33 |
35 private: | 34 private: |
36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone); | 35 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone); |
37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhoneEcml); | |
38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone); | 36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone); |
39 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhoneEcmlShipTo); | |
40 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhoneEcmlBillTo); | |
41 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber); | 37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber); |
42 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix); | 38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix); |
43 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2); | 39 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2); |
44 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLineFax); | 40 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLineFax); |
45 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLineFax); | 41 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLineFax); |
46 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix); | 42 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix); |
47 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber); | 43 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber); |
48 | 44 |
49 PhoneField(); | 45 PhoneField(); |
50 | 46 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 static struct Parser { | 124 static struct Parser { |
129 RegexType regex; // Field matching reg-ex. | 125 RegexType regex; // Field matching reg-ex. |
130 PhonePart phone_part; // Index of the field. | 126 PhonePart phone_part; // Index of the field. |
131 int max_size; // Max size of the field to match. 0 means any. | 127 int max_size; // Max size of the field to match. 0 means any. |
132 } phone_field_grammars_[]; | 128 } phone_field_grammars_[]; |
133 | 129 |
134 DISALLOW_COPY_AND_ASSIGN(PhoneField); | 130 DISALLOW_COPY_AND_ASSIGN(PhoneField); |
135 }; | 131 }; |
136 | 132 |
137 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ | 133 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ |
OLD | NEW |