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

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

Issue 7063031: Heuristics for grabber-continental.com.out (select-one) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 14 matching lines...) Expand all
25 25
26 // Classifies each field in |fields| with its heuristically detected type. 26 // Classifies each field in |fields| with its heuristically detected type.
27 // The association is stored into |map|. Each field has a derived unique name 27 // The association is stored into |map|. Each field has a derived unique name
28 // that is used as the key into the |map|. 28 // that is used as the key into the |map|.
29 static void ParseFormFields(const std::vector<AutofillField*>& fields, 29 static void ParseFormFields(const std::vector<AutofillField*>& fields,
30 FieldTypeMap* map); 30 FieldTypeMap* map);
31 31
32 protected: 32 protected:
33 // A bit-field used for matching specific parts of a field in question. 33 // A bit-field used for matching specific parts of a field in question.
34 enum MatchType { 34 enum MatchType {
35 MATCH_LABEL = 1 << 0, 35 // Attributes.
36 MATCH_NAME = 1 << 1, 36 MATCH_LABEL = 1 << 0,
37 MATCH_ALL = MATCH_LABEL | MATCH_NAME 37 MATCH_NAME = 1 << 1,
38
39 // Input types.
40 MATCH_TEXT = 1 << 2,
41 MATCH_EMAIL = 1 << 3,
42 MATCH_MONTH = 1 << 4,
43 MATCH_TELEPHONE = 1 << 5,
44 MATCH_SELECT = 1 << 6,
45 MATCH_ALL_INPUTS = MATCH_TEXT | MATCH_EMAIL | MATCH_MONTH |
46 MATCH_TELEPHONE | MATCH_SELECT,
Ilya Sherman 2011/05/25 03:52:02 nit: This alignment looks off.
dhollowa 2011/05/25 15:29:47 Done.
47
48 // By default match label, name, for input/text types.
49 MATCH_DEFAULT = MATCH_LABEL | MATCH_NAME | MATCH_TEXT,
38 }; 50 };
39 51
40 // Only derived classes may instantiate. 52 // Only derived classes may instantiate.
41 FormField() {} 53 FormField() {}
42 54
43 // Attempts to parse a form field with the given pattern. Returns true on 55 // Attempts to parse a form field with the given pattern. Returns true on
44 // success and fills |match| with a pointer to the field. 56 // success and fills |match| with a pointer to the field.
45 static bool ParseField(AutofillScanner* scanner, 57 static bool ParseField(AutofillScanner* scanner,
46 const string16& pattern, 58 const string16& pattern,
47 const AutofillField** match); 59 const AutofillField** match);
(...skipping 20 matching lines...) Expand all
68 80
69 // Derived classes must implement this interface to supply field type 81 // Derived classes must implement this interface to supply field type
70 // information. |ParseFormFields| coordinates the parsing and extraction 82 // information. |ParseFormFields| coordinates the parsing and extraction
71 // of types from an input vector of |AutofillField| objects and delegates 83 // of types from an input vector of |AutofillField| objects and delegates
72 // the type extraction via this method. 84 // the type extraction via this method.
73 virtual bool ClassifyField(FieldTypeMap* map) const = 0; 85 virtual bool ClassifyField(FieldTypeMap* map) const = 0;
74 86
75 private: 87 private:
76 FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match); 88 FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match);
77 89
90 // Matches |pattern| to the contents of the field at the head of the
91 // |scanner|.
92 // Returns |true| if a match is found according to |match_type|, and |false|
93 // otherwise.
94 static bool MatchAndAdvance(AutofillScanner* scanner,
95 const string16& pattern,
96 int match_type,
97 const AutofillField** match);
Ilya Sherman 2011/05/25 03:52:02 nit: Can this be moved to the implementation file?
dhollowa 2011/05/25 15:29:47 This needs to call private method |Match| (which i
Ilya Sherman 2011/05/25 19:17:28 Ah, ok.
98
78 // Matches the regular expression |pattern| against the components of |field| 99 // Matches the regular expression |pattern| against the components of |field|
79 // as specified in the |match_type| bit field (see |MatchType|). 100 // as specified in the |match_type| bit field (see |MatchType|).
80 static bool Match(const AutofillField* field, 101 static bool Match(const AutofillField* field,
81 const string16& pattern, 102 const string16& pattern,
82 int match_type); 103 int match_type);
83 104
84 DISALLOW_COPY_AND_ASSIGN(FormField); 105 DISALLOW_COPY_AND_ASSIGN(FormField);
85 }; 106 };
86 107
87 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_ 108 #endif // CHROME_BROWSER_AUTOFILL_FORM_FIELD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698