| 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 virtual bool GetFieldInfo(FieldTypeMap* field_type_map) const OVERRIDE; | |
| 29 | |
| 30 static PhoneField* Parse(AutofillScanner* scanner, bool is_ecml); | 28 static PhoneField* Parse(AutofillScanner* scanner, bool is_ecml); |
| 31 static PhoneField* ParseECML(AutofillScanner* scanner); | 29 static PhoneField* ParseECML(AutofillScanner* scanner); |
| 32 | 30 |
| 31 protected: |
| 32 // FormField: |
| 33 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; |
| 34 |
| 33 private: | 35 private: |
| 36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone); |
| 37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhoneEcml); |
| 38 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); |
| 42 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix); |
| 43 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLineFax); |
| 44 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLineFax); |
| 45 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix); |
| 46 |
| 34 PhoneField(); | 47 PhoneField(); |
| 35 | 48 |
| 36 enum PhoneType { | 49 enum PhoneType { |
| 37 PHONE_TYPE_FIRST = 0, | 50 PHONE_TYPE_FIRST = 0, |
| 38 HOME_PHONE = PHONE_TYPE_FIRST, | 51 HOME_PHONE = PHONE_TYPE_FIRST, |
| 39 FAX_PHONE, | 52 FAX_PHONE, |
| 40 | 53 |
| 41 // Must be last. | 54 // Must be last. |
| 42 PHONE_TYPE_MAX, | 55 PHONE_TYPE_MAX, |
| 43 }; | 56 }; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 static struct Parser { | 126 static struct Parser { |
| 114 RegexType regex; // Field matching reg-ex. | 127 RegexType regex; // Field matching reg-ex. |
| 115 PhonePart phone_part; // Index of the field. | 128 PhonePart phone_part; // Index of the field. |
| 116 int max_size; // Max size of the field to match. 0 means any. | 129 int max_size; // Max size of the field to match. 0 means any. |
| 117 } phone_field_grammars_[]; | 130 } phone_field_grammars_[]; |
| 118 | 131 |
| 119 DISALLOW_COPY_AND_ASSIGN(PhoneField); | 132 DISALLOW_COPY_AND_ASSIGN(PhoneField); |
| 120 }; | 133 }; |
| 121 | 134 |
| 122 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ | 135 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ |
| OLD | NEW |