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

Unified Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 804443002: Autofill: Modify various utility function to deal with unowned form fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more tests Created 6 years 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
Index: components/autofill/content/renderer/autofill_agent.cc
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 8a9350e9304bc369045479377850335096a0421e..7e31aecef4012dc200de1eac93f93e3758fc3ee5 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -663,7 +663,8 @@ void AutofillAgent::QueryAutofillSuggestions(
const WebFormControlElement& element,
bool display_warning_if_disabled,
bool datalist_only) {
- if (!element.document().frame())
+ blink::WebDocument document = element.document();
+ if (!document.frame())
return;
DCHECK(toWebInputElement(&element) || IsTextAreaElement(element));
@@ -690,9 +691,26 @@ void AutofillAgent::QueryAutofillSuggestions(
FormFieldData field;
if (!FindFormAndFieldForFormControlElement(element, &form, &field,
Evan Stade 2014/12/12 19:59:35 hmmm, why doesn't the unowned form just go in the
Lei Zhang 2014/12/12 22:06:23 FindFormAndFieldForFormControlElement() works on t
requirements)) {
- // If we didn't find the cached form, at least let autocomplete have a shot
- // at providing suggestions.
- WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
+ // No associated form element, try the form for unowned form elements.
Evan Stade 2014/12/12 19:59:35 nit: s/form for/synthetic form for/
Lei Zhang 2014/12/12 22:06:23 Done.
+ FormData unowned_form;
+ FormFieldData unowned_field;
+ std::vector<WebElement> fieldsets;
+ std::vector<WebFormControlElement> control_elements =
+ GetUnownedAutofillableFormFieldElements(document.all(), &fieldsets);
+ const ExtractMask extract_mask =
Evan Stade 2014/12/12 19:59:35 nit: dislike this variable because it makes it see
Lei Zhang 2014/12/12 22:06:23 Done.
+ static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS);
+ if (UnownedFormElementsAndFieldSetsToFormData(fieldsets, control_elements,
+ &element, document.url(),
+ requirements, extract_mask,
+ &unowned_form,
+ &unowned_field)) {
+ form = unowned_form;
+ field = unowned_field;
+ } else {
+ // If we didn't find the cached form, at least let autocomplete have a
+ // shot at providing suggestions.
+ WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
+ }
}
if (datalist_only)
field.should_autocomplete = false;
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | components/autofill/content/renderer/form_autofill_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698