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

Side by Side Diff: chrome/browser/autofill/phone_field.h

Issue 7892048: Autofill: Remove fax number completely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 19 matching lines...) Expand all
30 protected: 30 protected:
31 // FormField: 31 // FormField:
32 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE; 32 virtual bool ClassifyField(FieldTypeMap* map) const OVERRIDE;
33 33
34 private: 34 private:
35 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone); 35 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLinePhone);
36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone); 36 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLinePhone);
37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber); 37 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumber);
38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix); 38 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix);
39 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2); 39 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix2);
40 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseOneLineFax);
41 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ParseTwoLineFax);
42 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, ThreePartFaxNumberPrefixSuffix);
43 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber); 40 FRIEND_TEST_ALL_PREFIXES(PhoneFieldTest, CountryAndCityAndPhoneNumber);
44 41
45 PhoneField(); 42 PhoneField();
46 43
47 enum PhoneType {
48 PHONE_TYPE_FIRST = 0,
49 HOME_PHONE = PHONE_TYPE_FIRST,
50 FAX_PHONE,
51
52 // Must be last.
53 PHONE_TYPE_MAX,
54 };
55
56 // Some field names are different for phone and fax.
57 string16 GetCountryRegex() const;
58 // This string includes all area code separators, including NoText.
59 string16 GetAreaRegex() const;
60 // Separator of the area code in the case fields are formatted without
61 // any text indicating what fields are (e.g. field1 "(" field2 ")" field3 "-"
62 // field4 means Country Code, Area Code, Prefix, Suffix)
63 string16 GetAreaNoTextRegex() const;
64 string16 GetPhoneRegex() const;
65 string16 GetPrefixSeparatorRegex() const;
66 string16 GetPrefixRegex() const;
67 string16 GetSuffixSeparatorRegex() const;
68 string16 GetSuffixRegex() const;
69 string16 GetExtensionRegex() const;
70
71 // This is for easy description of the possible parsing paths of the phone 44 // This is for easy description of the possible parsing paths of the phone
72 // fields. 45 // fields.
73 enum RegexType { 46 enum RegexType {
74 REGEX_COUNTRY, 47 REGEX_COUNTRY,
75 REGEX_AREA, 48 REGEX_AREA,
76 REGEX_AREA_NOTEXT, 49 REGEX_AREA_NOTEXT,
77 REGEX_PHONE, 50 REGEX_PHONE,
78 REGEX_PREFIX_SEPARATOR, 51 REGEX_PREFIX_SEPARATOR,
79 REGEX_PREFIX, 52 REGEX_PREFIX,
80 REGEX_SUFFIX_SEPARATOR, 53 REGEX_SUFFIX_SEPARATOR,
81 REGEX_SUFFIX, 54 REGEX_SUFFIX,
82 REGEX_EXTENSION, 55 REGEX_EXTENSION,
83 56
84 // Separates regexps in grammar. 57 // Separates regexps in grammar.
85 REGEX_SEPARATOR, 58 REGEX_SEPARATOR,
86 }; 59 };
87 60
88 string16 GetRegExp(RegexType regex_id) const; 61 string16 GetRegExp(RegexType regex_id) const;
89 62
90 // |field| - field to fill up on successful parsing. 63 // |field| - field to fill up on successful parsing.
91 // |iter| - in/out. Form field iterator, points to the first field that is 64 // |iter| - in/out. Form field iterator, points to the first field that is
92 // attempted to be parsed. If parsing successful, points to the first field 65 // attempted to be parsed. If parsing successful, points to the first field
93 // after parsed fields. 66 // after parsed fields.
94 // |regular_phone| - true if the parsed phone is a HOME phone, false 67 // TODO(isherman): This method doc is out of date.
95 // otherwise. 68 static bool ParseInternal(PhoneField* field, AutofillScanner* scanner);
96 static bool ParseInternal(PhoneField* field,
97 AutofillScanner* scanner,
98 bool regular_phone);
99
100 void SetPhoneType(PhoneType phone_type);
101
102 // Field types are different as well, so we create a temporary phone number,
103 // to get relevant field types.
104 scoped_ptr<PhoneNumber> number_;
105 PhoneType phone_type_;
106
107 69
108 // Parsed fields. 70 // Parsed fields.
109 enum PhonePart { 71 enum PhonePart {
110 FIELD_NONE = -1, 72 FIELD_NONE = -1,
111 FIELD_COUNTRY_CODE, 73 FIELD_COUNTRY_CODE,
112 FIELD_AREA_CODE, 74 FIELD_AREA_CODE,
113 FIELD_PHONE, 75 FIELD_PHONE,
114 FIELD_SUFFIX, 76 FIELD_SUFFIX,
115 FIELD_EXTENSION, 77 FIELD_EXTENSION,
116 78
117 FIELD_MAX, 79 FIELD_MAX,
118 }; 80 };
119 81
120 // FIELD_PHONE is always present; holds suffix if prefix is present. 82 // FIELD_PHONE is always present; holds suffix if prefix is present.
121 // The rest could be NULL. 83 // The rest could be NULL.
122 const AutofillField* parsed_phone_fields_[FIELD_MAX]; 84 const AutofillField* parsed_phone_fields_[FIELD_MAX];
123 85
124 static struct Parser { 86 static struct Parser {
125 RegexType regex; // Field matching reg-ex. 87 RegexType regex; // Field matching reg-ex.
126 PhonePart phone_part; // Index of the field. 88 PhonePart phone_part; // Index of the field.
127 size_t max_size; // Max size of the field to match. 0 means any. 89 size_t max_size; // Max size of the field to match. 0 means any.
128 } phone_field_grammars_[]; 90 } phone_field_grammars_[];
129 91
130 DISALLOW_COPY_AND_ASSIGN(PhoneField); 92 DISALLOW_COPY_AND_ASSIGN(PhoneField);
131 }; 93 };
132 94
133 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_ 95 #endif // CHROME_BROWSER_AUTOFILL_PHONE_FIELD_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager_unittest.cc ('k') | chrome/browser/autofill/phone_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698