Chromium Code Reviews| Index: components/autofill/core/browser/form_field.cc |
| diff --git a/components/autofill/core/browser/form_field.cc b/components/autofill/core/browser/form_field.cc |
| index 5ed4be60433deec6bd0dd63f201ee07d6890c971..624db9777e9d61c79e85383ab3bff1ea9da22ac8 100644 |
| --- a/components/autofill/core/browser/form_field.cc |
| +++ b/components/autofill/core/browser/form_field.cc |
| @@ -106,6 +106,40 @@ bool FormField::ParseFieldSpecifics(AutofillScanner* scanner, |
| } |
| // static |
| +FormField::ParseNameLabelResult FormField::ParseNameAndLabelSeparately( |
|
Evan Stade
2015/03/24 00:04:32
do you anticipate using this for any other form fi
Lei Zhang
2015/03/25 00:42:28
Not 100% sure, but I feel this may come in handy l
|
| + AutofillScanner* scanner, |
| + const base::string16& pattern, |
| + int match_type, |
| + AutofillField** match) { |
| + if (scanner->IsEnd()) |
| + return RESULT_MATCH_NONE; |
| + |
| + AutofillField* cur_match = nullptr; |
| + size_t saved_cursor = scanner->SaveCursor(); |
| + bool parsed_name = ParseFieldSpecifics(scanner, |
| + pattern, |
| + MatchTypeWithoutLabel(match_type), |
| + &cur_match); |
| + scanner->RewindTo(saved_cursor); |
| + bool parsed_label = ParseFieldSpecifics(scanner, |
| + pattern, |
| + MatchTypeWithoutName(match_type), |
| + &cur_match); |
| + if (parsed_name && parsed_label) { |
| + if (match) |
| + *match = cur_match; |
| + return RESULT_MATCH_NAME_LABEL; |
| + } |
| + |
| + scanner->RewindTo(saved_cursor); |
| + if (parsed_name) |
| + return RESULT_MATCH_NAME; |
| + if (parsed_label) |
| + return RESULT_MATCH_LABEL; |
| + return RESULT_MATCH_NONE; |
| +} |
| + |
| +// static |
| bool FormField::ParseEmptyLabel(AutofillScanner* scanner, |
| AutofillField** match) { |
| return ParseFieldSpecifics(scanner, |
| @@ -208,4 +242,14 @@ bool FormField::MatchesFormControlType(const std::string& type, |
| return false; |
| } |
| +// static |
| +int FormField::MatchTypeWithoutLabel(int match_type) { |
| + return match_type & ~MATCH_LABEL; |
|
Evan Stade
2015/03/24 00:04:32
just inline these two functions imo
Lei Zhang
2015/03/25 00:42:28
Done.
|
| +} |
| + |
| +// static |
| +int FormField::MatchTypeWithoutName(int match_type) { |
| + return match_type & ~MATCH_NAME; |
| +} |
| + |
| } // namespace autofill |