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 #include "components/autofill/core/browser/form_field.h" | 5 #include "components/autofill/core/browser/form_field.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 const AutofillField* field = scanner->Cursor(); | 100 const AutofillField* field = scanner->Cursor(); |
101 | 101 |
102 if (!MatchesFormControlType(field->form_control_type, match_type)) | 102 if (!MatchesFormControlType(field->form_control_type, match_type)) |
103 return false; | 103 return false; |
104 | 104 |
105 return MatchAndAdvance(scanner, pattern, match_type, match); | 105 return MatchAndAdvance(scanner, pattern, match_type, match); |
106 } | 106 } |
107 | 107 |
108 // static | 108 // static |
| 109 FormField::ParseNameLabelResult FormField::ParseNameAndLabelSeparately( |
| 110 AutofillScanner* scanner, |
| 111 const base::string16& pattern, |
| 112 int match_type, |
| 113 AutofillField** match) { |
| 114 if (scanner->IsEnd()) |
| 115 return RESULT_MATCH_NONE; |
| 116 |
| 117 AutofillField* cur_match = nullptr; |
| 118 size_t saved_cursor = scanner->SaveCursor(); |
| 119 bool parsed_name = ParseFieldSpecifics(scanner, |
| 120 pattern, |
| 121 match_type & ~MATCH_LABEL, |
| 122 &cur_match); |
| 123 scanner->RewindTo(saved_cursor); |
| 124 bool parsed_label = ParseFieldSpecifics(scanner, |
| 125 pattern, |
| 126 match_type & ~MATCH_NAME, |
| 127 &cur_match); |
| 128 if (parsed_name && parsed_label) { |
| 129 if (match) |
| 130 *match = cur_match; |
| 131 return RESULT_MATCH_NAME_LABEL; |
| 132 } |
| 133 |
| 134 scanner->RewindTo(saved_cursor); |
| 135 if (parsed_name) |
| 136 return RESULT_MATCH_NAME; |
| 137 if (parsed_label) |
| 138 return RESULT_MATCH_LABEL; |
| 139 return RESULT_MATCH_NONE; |
| 140 } |
| 141 |
| 142 // static |
109 bool FormField::ParseEmptyLabel(AutofillScanner* scanner, | 143 bool FormField::ParseEmptyLabel(AutofillScanner* scanner, |
110 AutofillField** match) { | 144 AutofillField** match) { |
111 return ParseFieldSpecifics(scanner, | 145 return ParseFieldSpecifics(scanner, |
112 base::ASCIIToUTF16("^$"), | 146 base::ASCIIToUTF16("^$"), |
113 MATCH_LABEL | MATCH_ALL_INPUTS, | 147 MATCH_LABEL | MATCH_ALL_INPUTS, |
114 match); | 148 match); |
115 } | 149 } |
116 | 150 |
117 // static | 151 // static |
118 bool FormField::AddClassification(const AutofillField* field, | 152 bool FormField::AddClassification(const AutofillField* field, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if ((match_type & MATCH_PASSWORD) && type == "password") | 236 if ((match_type & MATCH_PASSWORD) && type == "password") |
203 return true; | 237 return true; |
204 | 238 |
205 if ((match_type & MATCH_NUMBER) && type == "number") | 239 if ((match_type & MATCH_NUMBER) && type == "number") |
206 return true; | 240 return true; |
207 | 241 |
208 return false; | 242 return false; |
209 } | 243 } |
210 | 244 |
211 } // namespace autofill | 245 } // namespace autofill |
OLD | NEW |