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

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

Issue 1671753004: [Autofill] Fill fields that have an autocomplete attributes even if not in a form. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added IPC Trait for new attribute Created 4 years, 10 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
Index: components/autofill/content/renderer/form_autofill_util.cc
diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc
index cb250901cebf9981ecdf844b0dbaade93acb50b4..9db4b76cceb7bf3b55db5cebce8288691189b2b5 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -1520,6 +1520,7 @@ bool UnownedCheckoutFormElementsAndFieldSetsToFormData(
keyword, keyword + strlen(keyword));
if (title_pos != title.end() ||
path.find(keyword) != std::string::npos) {
+ form->is_formless_checkout = true;
// Found a keyword: treat this as an unowned form.
return UnownedFormElementsAndFieldSetsToFormData(
fieldsets, control_elements, element, document, extract_mask, form,
@@ -1527,7 +1528,22 @@ bool UnownedCheckoutFormElementsAndFieldSetsToFormData(
}
}
- return false;
+ // Since it's not a checkout flow, only add fields that have a non-"off"
+ // autocomplete attribute to the formless autofill.
+ CR_DEFINE_STATIC_LOCAL(WebString, kOffAttribute, ("off"));
+ std::vector<WebFormControlElement> elements_with_autocomplete;
+ for (const WebFormControlElement& element : control_elements) {
+ blink::WebString autocomplete = element.getAttribute("autocomplete");
+ if (autocomplete.length() && autocomplete != kOffAttribute)
+ elements_with_autocomplete.push_back(element);
+ }
+
+ if (elements_with_autocomplete.empty())
+ return false;
+
+ return UnownedFormElementsAndFieldSetsToFormData(
+ fieldsets, elements_with_autocomplete, element, document, extract_mask,
+ form, field);
}
bool UnownedPasswordFormElementsAndFieldSetsToFormData(
« no previous file with comments | « components/autofill/content/common/autofill_param_traits_macros.h ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698