OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // interface can identify themselves as a particular type of form field, e.g. | 22 // interface can identify themselves as a particular type of form field, e.g. |
23 // name, phone number, or address field. | 23 // name, phone number, or address field. |
24 class FormField { | 24 class FormField { |
25 public: | 25 public: |
26 virtual ~FormField() {} | 26 virtual ~FormField() {} |
27 | 27 |
28 // Classifies each field in |fields| with its heuristically detected type. | 28 // Classifies each field in |fields| with its heuristically detected type. |
29 // The association is stored into |map|. Each field has a derived unique name | 29 // The association is stored into |map|. Each field has a derived unique name |
30 // that is used as the key into the |map|. | 30 // that is used as the key into the |map|. |
31 static void ParseFormFields(const std::vector<AutofillField*>& fields, | 31 static void ParseFormFields(const std::vector<AutofillField*>& fields, |
| 32 bool is_in_form_tag, |
32 ServerFieldTypeMap* map); | 33 ServerFieldTypeMap* map); |
33 | 34 |
34 protected: | 35 protected: |
35 // A bit-field used for matching specific parts of a field in question. | 36 // A bit-field used for matching specific parts of a field in question. |
36 enum MatchType { | 37 enum MatchType { |
37 // Attributes. | 38 // Attributes. |
38 MATCH_LABEL = 1 << 0, | 39 MATCH_LABEL = 1 << 0, |
39 MATCH_NAME = 1 << 1, | 40 MATCH_NAME = 1 << 1, |
40 MATCH_VALUE = 1 << 2, | 41 MATCH_VALUE = 1 << 2, |
41 | 42 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // as specified in the |match_type| bit field (see |MatchType|). | 109 // as specified in the |match_type| bit field (see |MatchType|). |
109 static bool Match(const AutofillField* field, | 110 static bool Match(const AutofillField* field, |
110 const base::string16& pattern, | 111 const base::string16& pattern, |
111 int match_type); | 112 int match_type); |
112 | 113 |
113 // Perform a "pass" over the |fields| where each pass uses the supplied | 114 // Perform a "pass" over the |fields| where each pass uses the supplied |
114 // |parse| method to match content to a given field type. | 115 // |parse| method to match content to a given field type. |
115 // |fields| is both an input and an output parameter. Upon exit |fields| | 116 // |fields| is both an input and an output parameter. Upon exit |fields| |
116 // holds any remaining unclassified fields for further processing. | 117 // holds any remaining unclassified fields for further processing. |
117 // Classification results of the processed fields are stored in |map|. | 118 // Classification results of the processed fields are stored in |map|. |
118 static void ParseFormFieldsPass(ParseFunction parse, | 119 // Returns the number of recognized fields. |
119 std::vector<AutofillField*>* fields, | 120 static size_t ParseFormFieldsPass(ParseFunction parse, |
120 ServerFieldTypeMap* map); | 121 std::vector<AutofillField*>* fields, |
| 122 ServerFieldTypeMap* map); |
121 | 123 |
122 // Returns true iff |type| matches |match_type|. | 124 // Returns true iff |type| matches |match_type|. |
123 static bool MatchesFormControlType(const std::string& type, int match_type); | 125 static bool MatchesFormControlType(const std::string& type, int match_type); |
124 | 126 |
125 DISALLOW_COPY_AND_ASSIGN(FormField); | 127 DISALLOW_COPY_AND_ASSIGN(FormField); |
126 }; | 128 }; |
127 | 129 |
128 } // namespace autofill | 130 } // namespace autofill |
129 | 131 |
130 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ | 132 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ |
OLD | NEW |