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

Unified Diff: components/autofill/browser/autofill_external_delegate.cc

Issue 16344003: [Autofill] Fix popup delegate to show warnings correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « no previous file | components/autofill/browser/autofill_external_delegate_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/browser/autofill_external_delegate.cc
diff --git a/components/autofill/browser/autofill_external_delegate.cc b/components/autofill/browser/autofill_external_delegate.cc
index 95fc0cfd74500192a39b715dc7eb5f65b1341a08..d68c50953e810df9495ddcc089e5de4b16687b44 100644
--- a/components/autofill/browser/autofill_external_delegate.cc
+++ b/components/autofill/browser/autofill_external_delegate.cc
@@ -91,14 +91,15 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
std::vector<base::string16> icons(autofill_icons);
std::vector<int> ids(autofill_unique_ids);
+ // Add or hide warnings as appropriate.
+ ApplyAutofillWarnings(&values, &labels, &icons, &ids);
+
// Add a separator to go between the values and menu items.
values.push_back(base::string16());
labels.push_back(base::string16());
icons.push_back(base::string16());
ids.push_back(WebAutofillClient::MenuItemIDSeparator);
- ApplyAutofillWarnings(&values, &labels, &icons, &ids);
-
// Only include "Autofill Options" special menu item if we have Autofill
// suggestions.
has_autofill_suggestion_ = false;
@@ -113,10 +114,8 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
ApplyAutofillOptions(&values, &labels, &icons, &ids);
// Remove the separator if it is the last element.
- // It is possible for ids to be empty at this point if the vectors were
- // cleared by ApplyAutofillWarnings (which can occur if we shouldn't
- // autocomplete or display warnings for this field).
- if (!ids.empty() && ids.back() == WebAutofillClient::MenuItemIDSeparator) {
+ DCHECK_GT(ids.size(), 0U);
+ if (ids.back() == WebAutofillClient::MenuItemIDSeparator) {
values.pop_back();
labels.pop_back();
icons.pop_back();
« no previous file with comments | « no previous file | components/autofill/browser/autofill_external_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698