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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/form_field.h ('k') | chrome/browser/autofill/name_field.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/form_field.cc
diff --git a/chrome/browser/autofill/form_field.cc b/chrome/browser/autofill/form_field.cc
index 926d3409a746e8d02d2f319a3f2cb99da3cefb38..585a62e8a93cc62d018f3660e5e6696b9803de4c 100644
--- a/chrome/browser/autofill/form_field.cc
+++ b/chrome/browser/autofill/form_field.cc
@@ -235,40 +235,48 @@ FormField* FormField::ParseFormField(AutofillScanner* scanner, bool is_ecml) {
}
// static
-bool FormField::ParseText(AutofillScanner* scanner, const string16& pattern) {
+bool FormField::ParseText(AutofillScanner* scanner,
+ const string16& pattern,
+ int match_type) {
const AutofillField* field;
- return ParseText(scanner, pattern, &field);
+ return ParseText(scanner, pattern, match_type, &field);
}
// static
bool FormField::ParseText(AutofillScanner* scanner,
const string16& pattern,
+ int match_type,
const AutofillField** dest) {
- return ParseText(scanner, pattern, dest, false);
+ return ParseText(scanner, pattern, dest, match_type);
}
// static
bool FormField::ParseEmptyText(AutofillScanner* scanner,
const AutofillField** dest) {
- return ParseLabelText(scanner, ASCIIToUTF16("^$"), dest);
-}
-
-// static
-bool FormField::ParseLabelText(AutofillScanner* scanner,
- const string16& pattern,
- const AutofillField** dest) {
- return ParseText(scanner, pattern, dest, true);
+ return ParseText(scanner, ASCIIToUTF16("^$"),
+ MATCH_LABEL | MATCH_TEXT | MATCH_SELECT, dest);
}
// static
bool FormField::ParseText(AutofillScanner* scanner,
const string16& pattern,
const AutofillField** dest,
- bool match_label_only) {
+ int match_type) {
if (scanner->IsEnd())
return false;
const AutofillField* field = scanner->Cursor();
+
+ if (!(match_type & MATCH_SELECT) &&
+ field->form_control_type == ASCIIToUTF16("select-one"))
+ return false;
+
+ if (!(match_type & MATCH_TEXT) &&
+ field->form_control_type == ASCIIToUTF16("text"))
Ilya Sherman 2011/05/14 06:59:12 What about 'email', 'tel', and so on? Are there a
honten.org 2011/05/14 07:30:05 Yeah, you are right. I completely forgot HTML5 ta
honten.org 2011/05/14 07:41:20 As I used to did in form_manager, maybe we should
+ return false;
+
+ bool match_label_only = (match_type & MATCH_LABEL) &&
+ !(match_type & MATCH_NAME);
Ilya Sherman 2011/05/14 06:59:12 This computation doesn't seem right to me -- if MA
honten.org 2011/05/14 07:30:05 Actually, I wanted to refactor Match(), but it is
if (Match(field, pattern, match_label_only)) {
if (dest)
*dest = field;
@@ -280,13 +288,11 @@ bool FormField::ParseText(AutofillScanner* scanner,
}
// static
-bool FormField::ParseLabelAndName(AutofillScanner* scanner,
- const string16& pattern,
- const AutofillField** dest) {
+bool FormField::ParseEmpty(AutofillScanner* scanner) {
+ // TODO(jhawkins): Handle select fields.
+ const string16 pattern(ASCIIToUTF16("^$"));
const AutofillField* field = scanner->Cursor();
if (MatchLabel(field, pattern) && MatchName(field, pattern)) {
- if (dest)
- *dest = field;
scanner->Advance();
return true;
}
@@ -295,12 +301,6 @@ bool FormField::ParseLabelAndName(AutofillScanner* scanner,
}
// static
-bool FormField::ParseEmpty(AutofillScanner* scanner) {
- // TODO(jhawkins): Handle select fields.
- return ParseLabelAndName(scanner, ASCIIToUTF16("^$"), NULL);
-}
-
-// static
bool FormField::Add(FieldTypeMap* field_type_map,
const AutofillField* field,
AutofillFieldType type) {
« no previous file with comments | « chrome/browser/autofill/form_field.h ('k') | chrome/browser/autofill/name_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698