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

Unified Diff: components/autofill/core/browser/form_field.cc

Issue 1028633004: Autofill: Improve heuristics for city/state/zip fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 5 years, 9 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 | « components/autofill/core/browser/form_field.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7ea3ce4311ad4d409f71abbb872b0a801b2fbe44 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(
+ 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,
+ match_type & ~MATCH_LABEL,
+ &cur_match);
+ scanner->RewindTo(saved_cursor);
+ bool parsed_label = ParseFieldSpecifics(scanner,
+ pattern,
+ match_type & ~MATCH_NAME,
+ &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,
« no previous file with comments | « components/autofill/core/browser/form_field.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698