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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "chrome/browser/autofill/autofill_type.h" | 14 #include "chrome/browser/autofill/autofill_type.h" |
15 | 15 |
16 class AutofillField; | 16 class AutofillField; |
17 class AutofillScanner; | 17 class AutofillScanner; |
18 | 18 |
19 // Represents a logical form field in a web form. Classes that implement this | 19 // Represents a logical form field in a web form. Classes that implement this |
20 // interface can identify themselves as a particular type of form field, e.g. | 20 // interface can identify themselves as a particular type of form field, e.g. |
21 // name, phone number, or address field. | 21 // name, phone number, or address field. |
22 class FormField { | 22 class FormField { |
23 public: | 23 public: |
24 typedef FormField* ParseFunction(AutofillScanner* scanner, bool is_ecml); | 24 typedef FormField* ParseFunction(AutofillScanner* scanner); |
25 | 25 |
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 FieldTypeMap* map); | 32 FieldTypeMap* map); |
33 | 33 |
34 protected: | 34 protected: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 const AutofillField** match); | 99 const AutofillField** match); |
100 | 100 |
101 // Matches the regular expression |pattern| against the components of |field| | 101 // Matches the regular expression |pattern| against the components of |field| |
102 // as specified in the |match_type| bit field (see |MatchType|). | 102 // as specified in the |match_type| bit field (see |MatchType|). |
103 static bool Match(const AutofillField* field, | 103 static bool Match(const AutofillField* field, |
104 const string16& pattern, | 104 const string16& pattern, |
105 int match_type); | 105 int match_type); |
106 | 106 |
107 // Perform a "pass" over the |fields| where each pass uses the supplied | 107 // Perform a "pass" over the |fields| where each pass uses the supplied |
108 // |parse| method to match content to a given field type. | 108 // |parse| method to match content to a given field type. |
109 // |is_ecml| designates whether to match only ECML fields. | |
110 // |fields| is both an input and an output parameter. Upon exit |fields| | 109 // |fields| is both an input and an output parameter. Upon exit |fields| |
111 // holds any remaining unclassified fields for further processing. | 110 // holds any remaining unclassified fields for further processing. |
112 // Classification results of the proceessed fields are stored in |map|. | 111 // Classification results of the processed fields are stored in |map|. |
113 static void ParseFormFieldsPass(ParseFunction parse, | 112 static void ParseFormFieldsPass(ParseFunction parse, |
114 bool is_ecml, | |
115 std::vector<const AutofillField*>* fields, | 113 std::vector<const AutofillField*>* fields, |
116 FieldTypeMap* map); | 114 FieldTypeMap* map); |
117 | 115 |
118 DISALLOW_COPY_AND_ASSIGN(FormField); | 116 DISALLOW_COPY_AND_ASSIGN(FormField); |
119 }; | 117 }; |
120 | 118 |
121 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ | 119 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ |
OLD | NEW |