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

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

Issue 974613002: Revert of Autofill: Disable autofill for fields outside of forms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « components/autofill/content/renderer/form_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/renderer/form_cache.cc
diff --git a/components/autofill/content/renderer/form_cache.cc b/components/autofill/content/renderer/form_cache.cc
index 3f27c39b89cd19dd98c3f66bd1197072227e55cf..9bc97e2f5505c598566d3a66b4995d9839aa2dd4 100644
--- a/components/autofill/content/renderer/form_cache.cc
+++ b/components/autofill/content/renderer/form_cache.cc
@@ -119,10 +119,41 @@
parsed_forms_.insert(form);
}
}
+
+ // Look for more parseable fields outside of forms.
+ std::vector<WebElement> fieldsets;
+ std::vector<WebFormControlElement> control_elements =
+ GetUnownedAutofillableFormFieldElements(document.all(), &fieldsets);
+
+ size_t num_editable_elements =
+ ScanFormControlElements(control_elements, log_deprecation_messages);
+
+ if (ShouldIgnoreForm(num_editable_elements, control_elements.size()))
+ return forms;
+
+ FormData synthetic_form;
+ if (!UnownedFormElementsAndFieldSetsToFormData(fieldsets, control_elements,
+ nullptr, document.url(),
+ REQUIRE_NONE, extract_mask,
+ &synthetic_form, nullptr)) {
+ return forms;
+ }
+
+ num_fields_seen += synthetic_form.fields.size();
+ if (num_fields_seen > kMaxParseableFields)
+ return forms;
+
+ if (synthetic_form.fields.size() >= kRequiredAutofillFields &&
+ !parsed_forms_.count(synthetic_form)) {
+ forms.push_back(synthetic_form);
+ parsed_forms_.insert(synthetic_form);
+ synthetic_form_ = synthetic_form;
+ }
return forms;
}
void FormCache::Reset() {
+ synthetic_form_ = FormData();
parsed_forms_.clear();
initial_select_values_.clear();
initial_checked_state_.clear();
@@ -191,7 +222,15 @@
std::vector<WebFormControlElement> control_elements;
+ // First check the synthetic form.
bool found_synthetic_form = false;
+ if (form.data.SameFormAs(synthetic_form_)) {
+ found_synthetic_form = true;
+ WebDocument document = frame_.document();
+ control_elements =
+ GetUnownedAutofillableFormFieldElements(document.all(), nullptr);
+ }
+
if (!found_synthetic_form) {
// Find the real form by searching through the WebDocuments.
bool found_form = false;
« no previous file with comments | « components/autofill/content/renderer/form_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698