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

Side by Side Diff: components/autofill/core/browser/form_field.h

Issue 381613005: [Autofill] Autofill fails to fill credit card number when split across fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review inputs. Created 6 years, 3 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
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 MATCH_DEFAULT = MATCH_LABEL | MATCH_NAME | MATCH_VALUE | MATCH_TEXT, 52 MATCH_DEFAULT = MATCH_LABEL | MATCH_NAME | MATCH_VALUE | MATCH_TEXT,
53 }; 53 };
54 54
55 // Only derived classes may instantiate. 55 // Only derived classes may instantiate.
56 FormField() {} 56 FormField() {}
57 57
58 // Attempts to parse a form field with the given pattern. Returns true on 58 // Attempts to parse a form field with the given pattern. Returns true on
59 // success and fills |match| with a pointer to the field. 59 // success and fills |match| with a pointer to the field.
60 static bool ParseField(AutofillScanner* scanner, 60 static bool ParseField(AutofillScanner* scanner,
61 const base::string16& pattern, 61 const base::string16& pattern,
62 const AutofillField** match); 62 AutofillField** match);
63 63
64 // Parses the stream of fields in |scanner| with regular expression |pattern| 64 // Parses the stream of fields in |scanner| with regular expression |pattern|
65 // as specified in the |match_type| bit field (see |MatchType|). If |match| 65 // as specified in the |match_type| bit field (see |MatchType|). If |match|
66 // is non-NULL and the pattern matches, the matched field is returned. 66 // is non-NULL and the pattern matches, the matched field is returned.
67 // A |true| result is returned in the case of a successful match, false 67 // A |true| result is returned in the case of a successful match, false
68 // otherwise. 68 // otherwise.
69 static bool ParseFieldSpecifics(AutofillScanner* scanner, 69 static bool ParseFieldSpecifics(AutofillScanner* scanner,
70 const base::string16& pattern, 70 const base::string16& pattern,
71 int match_type, 71 int match_type,
72 const AutofillField** match); 72 AutofillField** match);
73 73
74 // Attempts to parse a field with an empty label. Returns true 74 // Attempts to parse a field with an empty label. Returns true
75 // on success and fills |match| with a pointer to the field. 75 // on success and fills |match| with a pointer to the field.
76 static bool ParseEmptyLabel(AutofillScanner* scanner, 76 static bool ParseEmptyLabel(AutofillScanner* scanner, AutofillField** match);
77 const AutofillField** match);
78 77
79 // Adds an association between a field and a type to |map|. 78 // Adds an association between a field and a type to |map|.
80 static bool AddClassification(const AutofillField* field, 79 static bool AddClassification(const AutofillField* field,
81 ServerFieldType type, 80 ServerFieldType type,
82 ServerFieldTypeMap* map); 81 ServerFieldTypeMap* map);
83 82
84 // Derived classes must implement this interface to supply field type 83 // Derived classes must implement this interface to supply field type
85 // information. |ParseFormFields| coordinates the parsing and extraction 84 // information. |ParseFormFields| coordinates the parsing and extraction
86 // of types from an input vector of |AutofillField| objects and delegates 85 // of types from an input vector of |AutofillField| objects and delegates
87 // the type extraction via this method. 86 // the type extraction via this method.
88 virtual bool ClassifyField(ServerFieldTypeMap* map) const = 0; 87 virtual bool ClassifyField(ServerFieldTypeMap* map) const = 0;
89 88
90 private: 89 private:
91 FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match); 90 FRIEND_TEST_ALL_PREFIXES(FormFieldTest, Match);
92 91
93 // Function pointer type for the parsing function that should be passed to the 92 // Function pointer type for the parsing function that should be passed to the
94 // ParseFormFieldsPass() helper function. 93 // ParseFormFieldsPass() helper function.
95 typedef FormField* ParseFunction(AutofillScanner* scanner); 94 typedef FormField* ParseFunction(AutofillScanner* scanner);
96 95
97 // Matches |pattern| to the contents of the field at the head of the 96 // Matches |pattern| to the contents of the field at the head of the
98 // |scanner|. 97 // |scanner|.
99 // Returns |true| if a match is found according to |match_type|, and |false| 98 // Returns |true| if a match is found according to |match_type|, and |false|
100 // otherwise. 99 // otherwise.
101 static bool MatchAndAdvance(AutofillScanner* scanner, 100 static bool MatchAndAdvance(AutofillScanner* scanner,
102 const base::string16& pattern, 101 const base::string16& pattern,
103 int match_type, 102 int match_type,
104 const AutofillField** match); 103 AutofillField** match);
105 104
106 // Matches the regular expression |pattern| against the components of |field| 105 // Matches the regular expression |pattern| against the components of |field|
107 // as specified in the |match_type| bit field (see |MatchType|). 106 // as specified in the |match_type| bit field (see |MatchType|).
108 static bool Match(const AutofillField* field, 107 static bool Match(const AutofillField* field,
109 const base::string16& pattern, 108 const base::string16& pattern,
110 int match_type); 109 int match_type);
111 110
112 // Perform a "pass" over the |fields| where each pass uses the supplied 111 // Perform a "pass" over the |fields| where each pass uses the supplied
113 // |parse| method to match content to a given field type. 112 // |parse| method to match content to a given field type.
114 // |fields| is both an input and an output parameter. Upon exit |fields| 113 // |fields| is both an input and an output parameter. Upon exit |fields|
115 // holds any remaining unclassified fields for further processing. 114 // holds any remaining unclassified fields for further processing.
116 // Classification results of the processed fields are stored in |map|. 115 // Classification results of the processed fields are stored in |map|.
117 static void ParseFormFieldsPass(ParseFunction parse, 116 static void ParseFormFieldsPass(ParseFunction parse,
118 std::vector<const AutofillField*>* fields, 117 std::vector<AutofillField*>* fields,
119 ServerFieldTypeMap* map); 118 ServerFieldTypeMap* map);
120 119
121 // Returns true iff |type| matches |match_type|. 120 // Returns true iff |type| matches |match_type|.
122 static bool MatchesFormControlType(const std::string& type, int match_type); 121 static bool MatchesFormControlType(const std::string& type, int match_type);
123 122
124 DISALLOW_COPY_AND_ASSIGN(FormField); 123 DISALLOW_COPY_AND_ASSIGN(FormField);
125 }; 124 };
126 125
127 } // namespace autofill 126 } // namespace autofill
128 127
129 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_ 128 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_FIELD_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/email_field.cc ('k') | components/autofill/core/browser/form_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698