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

Unified Diff: chrome/browser/autofill/autofill_manager.cc

Issue 7978048: Don't ask the browser for Autofill suggestions for non-autofillable form fields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 9 years, 3 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 | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/renderer/autofill/autofill_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_manager.cc
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 79d379e71c9f881bb4a16dbd75ba51135791f9e9..b7eafaf88e1ff63b484a03eb882ef843d30deed4 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -818,7 +818,13 @@ bool AutofillManager::FindCachedForm(const FormData& form,
iter != form_structures_.rend(); ++iter) {
if (**iter == form) {
*form_structure = *iter;
- break;
+
+ // The same form might be cached with multiple field counts: in some
+ // cases, non-autofillable fields are filtered out, whereas in other cases
+ // they are not. To avoid thrashing the cache, keep scanning until we
+ // find a cached version with the same number of fields, if there is one.
+ if ((*iter)->field_count() == form.fields.size())
+ break;
}
}
@@ -836,14 +842,14 @@ bool AutofillManager::GetCachedFormAndField(const FormData& form,
// If we do not have this form in our cache but it is parseable, we'll add it
// in the call to |UpdateCachedForm()|.
if (!FindCachedForm(form, form_structure) &&
- (form_structures_.size() >= kMaxFormCacheSize ||
- !FormStructure(form).ShouldBeParsed(false))) {
+ !FormStructure(form).ShouldBeParsed(false)) {
return false;
}
// Update the cached form to reflect any dynamic changes to the form data, if
// necessary.
- UpdateCachedForm(form, *form_structure, form_structure);
+ if (!UpdateCachedForm(form, *form_structure, form_structure))
+ return false;
// No data to return if there are no auto-fillable fields.
if (!(*form_structure)->autofill_count())
@@ -865,7 +871,7 @@ bool AutofillManager::GetCachedFormAndField(const FormData& form,
return true;
}
-void AutofillManager::UpdateCachedForm(const FormData& live_form,
+bool AutofillManager::UpdateCachedForm(const FormData& live_form,
const FormStructure* cached_form,
FormStructure** updated_form) {
bool needs_update =
@@ -876,10 +882,12 @@ void AutofillManager::UpdateCachedForm(const FormData& live_form,
}
if (!needs_update)
- return;
+ return true;
+
+ if (form_structures_.size() >= kMaxFormCacheSize)
+ return false;
// Add the new or updated form to our cache.
- DCHECK(form_structures_.size() < kMaxFormCacheSize);
form_structures_.push_back(new FormStructure(live_form));
*updated_form = *form_structures_.rbegin();
(*updated_form)->DetermineHeuristicTypes();
@@ -910,6 +918,8 @@ void AutofillManager::UpdateCachedForm(const FormData& live_form,
// Annotate the updated form with its predicted types.
std::vector<FormStructure*> forms(1, *updated_form);
SendAutofillTypePredictions(forms);
+
+ return true;
}
void AutofillManager::GetProfileSuggestions(
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/renderer/autofill/autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698