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_FORM_FIELD_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ |
6 #define CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ | 6 #define CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // information. |ParseFormFields| coordinates the parsing and extraction | 81 // information. |ParseFormFields| coordinates the parsing and extraction |
82 // of types from an input vector of |AutofillField| objects and delegates | 82 // of types from an input vector of |AutofillField| objects and delegates |
83 // the type extraction via this method. | 83 // the type extraction via this method. |
84 virtual bool ClassifyField(FieldTypeMap* map) const = 0; | 84 virtual bool ClassifyField(FieldTypeMap* map) const = 0; |
85 | 85 |
86 private: | 86 private: |
87 FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match); | 87 FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match); |
88 | 88 |
89 // Function pointer type for the parsing function that should be passed to the | 89 // Function pointer type for the parsing function that should be passed to the |
90 // ParseFormFieldsPass() helper function. | 90 // ParseFormFieldsPass() helper function. |
91 typedef FormField* ParseFunction(AutofillScanner* scanner, | 91 typedef FormField* ParseFunction(AutofillScanner* scanner); |
92 bool parse_new_field_types); | |
93 | 92 |
94 // Matches |pattern| to the contents of the field at the head of the | 93 // Matches |pattern| to the contents of the field at the head of the |
95 // |scanner|. | 94 // |scanner|. |
96 // Returns |true| if a match is found according to |match_type|, and |false| | 95 // Returns |true| if a match is found according to |match_type|, and |false| |
97 // otherwise. | 96 // otherwise. |
98 static bool MatchAndAdvance(AutofillScanner* scanner, | 97 static bool MatchAndAdvance(AutofillScanner* scanner, |
99 const string16& pattern, | 98 const string16& pattern, |
100 int match_type, | 99 int match_type, |
101 const AutofillField** match); | 100 const AutofillField** match); |
102 | 101 |
103 // Matches the regular expression |pattern| against the components of |field| | 102 // Matches the regular expression |pattern| against the components of |field| |
104 // as specified in the |match_type| bit field (see |MatchType|). | 103 // as specified in the |match_type| bit field (see |MatchType|). |
105 static bool Match(const AutofillField* field, | 104 static bool Match(const AutofillField* field, |
106 const string16& pattern, | 105 const string16& pattern, |
107 int match_type); | 106 int match_type); |
108 | 107 |
109 // Perform a "pass" over the |fields| where each pass uses the supplied | 108 // Perform a "pass" over the |fields| where each pass uses the supplied |
110 // |parse| method to match content to a given field type. | 109 // |parse| method to match content to a given field type. |
111 // |fields| is both an input and an output parameter. Upon exit |fields| | 110 // |fields| is both an input and an output parameter. Upon exit |fields| |
112 // holds any remaining unclassified fields for further processing. | 111 // holds any remaining unclassified fields for further processing. |
113 // Classification results of the processed fields are stored in |map|. | 112 // Classification results of the processed fields are stored in |map|. |
114 static void ParseFormFieldsPass(ParseFunction parse, | 113 static void ParseFormFieldsPass(ParseFunction parse, |
115 bool parse_new_field_types, | |
116 std::vector<const AutofillField*>* fields, | 114 std::vector<const AutofillField*>* fields, |
117 FieldTypeMap* map); | 115 FieldTypeMap* map); |
118 | 116 |
119 DISALLOW_COPY_AND_ASSIGN(FormField); | 117 DISALLOW_COPY_AND_ASSIGN(FormField); |
120 }; | 118 }; |
121 | 119 |
122 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ | 120 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ |
OLD | NEW |