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

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

Issue 7014011: Change heuristic regex and order to match grabber-continental. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Use bit pattern version. Created 9 years, 7 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_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
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Associates the available AutofillTypes of a FormField into 72 // Associates the available AutofillTypes of a FormField into
73 // |field_type_map|. 73 // |field_type_map|.
74 virtual bool GetFieldInfo(FieldTypeMap* field_type_map) const = 0; 74 virtual bool GetFieldInfo(FieldTypeMap* field_type_map) const = 0;
75 75
76 // Returns true if |field| contains the regexp |pattern| in the name or label. 76 // Returns true if |field| contains the regexp |pattern| in the name or label.
77 // If |match_label_only| is true, then only the field's label is considered. 77 // If |match_label_only| is true, then only the field's label is considered.
78 static bool Match(const AutofillField* field, 78 static bool Match(const AutofillField* field,
79 const string16& pattern, 79 const string16& pattern,
80 bool match_label_only); 80 bool match_label_only);
81 81
82 enum MatchType {
83 MATCH_LABEL = 1 << 0,
84 MATCH_NAME = 1 << 1,
85 MATCH_TEXT = 1 << 2,
86 MATCH_SELECT = 1 << 3,
87 };
88
82 // Parses a field using the different field views we know about. |is_ecml| 89 // Parses a field using the different field views we know about. |is_ecml|
83 // should be true when the field conforms to the ECML specification. 90 // should be true when the field conforms to the ECML specification.
84 static FormField* ParseFormField(AutofillScanner* scanner, bool is_ecml); 91 static FormField* ParseFormField(AutofillScanner* scanner, bool is_ecml);
85 92
86 // Attempts to parse a text field with the given pattern; returns true on 93 // Attempts to parse a text field with the given pattern; returns true on
87 // success, but doesn't return the actual text field itself. 94 // success, but doesn't return the actual text field itself.
88 static bool ParseText(AutofillScanner* scanner, const string16& pattern); 95 static bool ParseText(AutofillScanner* scanner,
96 const string16& pattern,
97 int match_type);
89 98
90 // Attempts to parse a text field with the given pattern. Returns true on 99 // Attempts to parse a text field with the given pattern. Returns true on
91 // success and fills |dest| with a pointer to the field. 100 // success and fills |dest| with a pointer to the field.
92 static bool ParseText(AutofillScanner* scanner, 101 static bool ParseText(AutofillScanner* scanner,
93 const string16& pattern, 102 const string16& pattern,
103 int match_type,
94 const AutofillField** dest); 104 const AutofillField** dest);
95 105
96 // Attempts to parse a text field with an empty name or label. Returns true 106 // Attempts to parse a text field with an empty name or label. Returns true
97 // on success and fills |dest| with a pointer to the field. 107 // on success and fills |dest| with a pointer to the field.
98 static bool ParseEmptyText(AutofillScanner* scanner, 108 static bool ParseEmptyText(AutofillScanner* scanner,
99 const AutofillField** dest); 109 const AutofillField** dest);
100 110
101 // Attempts to parse a text field label with the given pattern. Returns true
102 // on success and fills |dest| with a pointer to the field.
103 static bool ParseLabelText(AutofillScanner* scanner,
104 const string16& pattern,
105 const AutofillField** dest);
106
107 // Attempts to parse a control with an empty label. 111 // Attempts to parse a control with an empty label.
108 static bool ParseEmpty(AutofillScanner* scanner); 112 static bool ParseEmpty(AutofillScanner* scanner);
109 113
110 // Adds an association between a field and a type to |field_type_map|. 114 // Adds an association between a field and a type to |field_type_map|.
111 static bool Add(FieldTypeMap* field_type_map, 115 static bool Add(FieldTypeMap* field_type_map,
112 const AutofillField* field, 116 const AutofillField* field,
113 AutofillFieldType type); 117 AutofillFieldType type);
114 118
115 protected: 119 protected:
116 // Only derived classes may instantiate. 120 // Only derived classes may instantiate.
117 FormField() {} 121 FormField() {}
118 122
119 // Note: ECML compliance checking has been modified to accommodate Google 123 // Note: ECML compliance checking has been modified to accommodate Google
120 // Checkout field name limitation. All ECML compliant web forms will be 124 // Checkout field name limitation. All ECML compliant web forms will be
121 // recognized correctly as such however the restrictions on having exactly 125 // recognized correctly as such however the restrictions on having exactly
122 // ECML compliant names have been loosened to only require that field names 126 // ECML compliant names have been loosened to only require that field names
123 // be prefixed with an ECML compliant name in order to accommodate checkout. 127 // be prefixed with an ECML compliant name in order to accommodate checkout.
124 // Additionally we allow the use of '.' as a word delimiter in addition to the 128 // Additionally we allow the use of '.' as a word delimiter in addition to the
125 // ECML standard '_' (see FormField::FormField for details). 129 // ECML standard '_' (see FormField::FormField for details).
126 static string16 GetEcmlPattern(const char* ecml_name); 130 static string16 GetEcmlPattern(const char* ecml_name);
127 static string16 GetEcmlPattern(const char* ecml_name1, 131 static string16 GetEcmlPattern(const char* ecml_name1,
128 const char* ecml_name2, 132 const char* ecml_name2,
129 char pattern_operator); 133 char pattern_operator);
130 134
131 private: 135 private:
132 static bool ParseText(AutofillScanner* scanner, 136 static bool ParseText(AutofillScanner* scanner,
133 const string16& pattern, 137 const string16& pattern,
134 const AutofillField** dest, 138 const AutofillField** dest,
135 bool match_label_only); 139 int match_type);
136 140
137 // For empty strings we need to test that both label and name are empty.
138 static bool ParseLabelAndName(AutofillScanner* scanner,
139 const string16& pattern,
140 const AutofillField** dest);
141 static bool MatchName(const AutofillField* field, const string16& pattern); 141 static bool MatchName(const AutofillField* field, const string16& pattern);
142 static bool MatchLabel(const AutofillField* field, const string16& pattern); 142 static bool MatchLabel(const AutofillField* field, const string16& pattern);
143 143
144 DISALLOW_COPY_AND_ASSIGN(FormField); 144 DISALLOW_COPY_AND_ASSIGN(FormField);
145 }; 145 };
146 146
147 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ 147 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698