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

Unified Diff: chrome/renderer/render_view.cc

Issue 2819051: Hide the autocomplete popup when no suggestions are available (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 1931d098af365ace51dc65cc302fa01885eacb69..4d5613298d623d7e495ed04951515c03d008bcee 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1514,41 +1514,45 @@ void RenderView::OnAutoFillSuggestionsReturned(
int query_id,
const std::vector<string16>& values,
const std::vector<string16>& labels) {
- if (webview() && query_id == autofill_query_id_) {
- std::vector<string16> v(values);
- std::vector<string16> l(labels);
- int separator_index = -1;
-
- // The form has been auto-filled, so give the user the chance to clear the
- // form. Append the 'Clear form' menu item.
- if (form_manager_.FormWithNodeIsAutoFilled(autofill_query_node_)) {
- v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM));
- l.push_back(string16());
- suggestions_clear_index_ = v.size() - 1;
- separator_index = values.size();
- }
-
- size_t labeled_item_count = 0;
- for (size_t i = 0; i < l.size(); ++i) {
- if (!l[i].empty())
- labeled_item_count++;
- }
-
- // Only include "AutoFill Options" special menu item if we have labeled
- // items.
- if (labeled_item_count > 0) {
- // Append the 'AutoFill Options...' menu item.
- v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS));
- l.push_back(string16());
- suggestions_options_index_ = v.size() - 1;
- separator_index = values.size();
- }
+ if (!webview() || query_id != autofill_query_id_)
+ return;
- // Send to WebKit for display.
- if (!v.empty())
- webview()->applyAutoFillSuggestions(
- autofill_query_node_, v, l, separator_index);
- }
+ // Any popup currently showing is now obsolete.
+ webview()->hidePopups();
+
+ std::vector<string16> v(values);
+ std::vector<string16> l(labels);
+ int separator_index = -1;
+
+ // The form has been auto-filled, so give the user the chance to clear the
+ // form. Append the 'Clear form' menu item.
+ if (form_manager_.FormWithNodeIsAutoFilled(autofill_query_node_)) {
+ v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM));
+ l.push_back(string16());
+ suggestions_clear_index_ = v.size() - 1;
+ separator_index = values.size();
+ }
+
+ size_t labeled_item_count = 0;
+ for (size_t i = 0; i < l.size(); ++i) {
+ if (!l[i].empty())
+ labeled_item_count++;
+ }
+
+ // Only include "AutoFill Options" special menu item if we have labeled
+ // items.
+ if (labeled_item_count > 0) {
+ // Append the 'AutoFill Options...' menu item.
+ v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS));
+ l.push_back(string16());
+ suggestions_options_index_ = v.size() - 1;
+ separator_index = values.size();
+ }
+
+ // Send to WebKit for display.
+ if (!v.empty())
+ webview()->applyAutoFillSuggestions(
+ autofill_query_node_, v, l, separator_index);
}
void RenderView::OnAutoFillFormDataFilled(int query_id,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698