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

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

Issue 7014011: Change heuristic regex and order to match grabber-continental. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
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 #include "chrome/browser/autofill/form_field.h" 5 #include "chrome/browser/autofill/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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 field = CreditCardField::Parse(scanner, is_ecml); 228 field = CreditCardField::Parse(scanner, is_ecml);
229 if (field) 229 if (field)
230 return field; 230 return field;
231 231
232 // We search for a |NameField| last since it matches the word "name", which is 232 // We search for a |NameField| last since it matches the word "name", which is
233 // relatively general. 233 // relatively general.
234 return NameField::Parse(scanner, is_ecml); 234 return NameField::Parse(scanner, is_ecml);
235 } 235 }
236 236
237 // static 237 // static
238 bool FormField::ParseText(AutofillScanner* scanner, const string16& pattern) { 238 bool FormField::ParseText(AutofillScanner* scanner, const Pattern& pattern) {
239 const AutofillField* field; 239 const AutofillField* field;
240 return ParseText(scanner, pattern, &field); 240 return ParseText(scanner, pattern, &field);
241 } 241 }
242 242
243 // static 243 // static
244 bool FormField::ParseText(AutofillScanner* scanner, 244 bool FormField::ParseText(AutofillScanner* scanner,
245 const string16& pattern, 245 const Pattern& pattern,
246 const AutofillField** dest) { 246 const AutofillField** dest) {
247 return ParseText(scanner, pattern, dest, false); 247 return ParseText(scanner, pattern, dest, false);
248 } 248 }
249 249
250 // static 250 // static
251 bool FormField::ParseEmptyText(AutofillScanner* scanner, 251 bool FormField::ParseEmptyText(AutofillScanner* scanner,
252 const AutofillField** dest) { 252 const AutofillField** dest) {
253 return ParseLabelText(scanner, ASCIIToUTF16("^$"), dest); 253 return ParseLabelText(scanner, Pattern(ASCIIToUTF16("^$")), dest);
254 } 254 }
255 255
256 // static 256 // static
257 bool FormField::ParseLabelText(AutofillScanner* scanner, 257 bool FormField::ParseLabelText(AutofillScanner* scanner,
258 const string16& pattern, 258 const Pattern& pattern,
259 const AutofillField** dest) { 259 const AutofillField** dest) {
260 return ParseText(scanner, pattern, dest, true); 260 return ParseText(scanner, pattern, dest, true);
261 } 261 }
262 262
263 // static 263 // static
264 bool FormField::ParseText(AutofillScanner* scanner, 264 bool FormField::ParseText(AutofillScanner* scanner,
265 const string16& pattern, 265 const Pattern& pattern,
266 const AutofillField** dest, 266 const AutofillField** dest,
267 bool match_label_only) { 267 bool match_label_only) {
268 if (scanner->IsEnd()) 268 if (scanner->IsEnd())
269 return false; 269 return false;
270 270
271 const AutofillField* field = scanner->Cursor(); 271 const AutofillField* field = scanner->Cursor();
272 if (Match(field, pattern, match_label_only)) { 272
273 if (!pattern.select_one_is_ok &&
274 field->form_control_type == ASCIIToUTF16("select-one"))
275 return false;
276
277 if (Match(field, pattern.pattern, match_label_only)) {
273 if (dest) 278 if (dest)
274 *dest = field; 279 *dest = field;
275 scanner->Advance(); 280 scanner->Advance();
276 return true; 281 return true;
277 } 282 }
278 283
279 return false; 284 return false;
280 } 285 }
281 286
282 // static 287 // static
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 string16 FormField::GetEcmlPattern(const char* ecml_name) { 320 string16 FormField::GetEcmlPattern(const char* ecml_name) {
316 return ASCIIToUTF16(std::string("^") + ecml_name); 321 return ASCIIToUTF16(std::string("^") + ecml_name);
317 } 322 }
318 323
319 string16 FormField::GetEcmlPattern(const char* ecml_name1, 324 string16 FormField::GetEcmlPattern(const char* ecml_name1,
320 const char* ecml_name2, 325 const char* ecml_name2,
321 char pattern_operator) { 326 char pattern_operator) {
322 return ASCIIToUTF16(StringPrintf("^%s%c^%s", 327 return ASCIIToUTF16(StringPrintf("^%s%c^%s",
323 ecml_name1, pattern_operator, ecml_name2)); 328 ecml_name1, pattern_operator, ecml_name2));
324 } 329 }
OLDNEW
« chrome/browser/autofill/form_field.h ('K') | « chrome/browser/autofill/form_field.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698