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

Unified Diff: chrome/renderer/render_view.cc

Issue 3040007: The autocomplete popup is now closed when no suggestions are available.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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
===================================================================
--- chrome/renderer/render_view.cc (revision 52842)
+++ chrome/renderer/render_view.cc (working copy)
@@ -1515,44 +1515,48 @@
const std::vector<string16>& values,
const std::vector<string16>& labels,
const std::vector<int>& unique_ids) {
- if (webview() && query_id == autofill_query_id_) {
- std::vector<string16> v(values);
- std::vector<string16> l(labels);
- std::vector<int> ids(unique_ids);
- int separator_index = -1;
+ if (!webview() || query_id != autofill_query_id_)
+ return;
- // 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());
- ids.push_back(0);
- suggestions_clear_index_ = v.size() - 1;
- separator_index = values.size();
- }
+ // Any popup currently showing is now obsolete.
+ webview()->hidePopups();
- size_t labeled_item_count = 0;
- for (size_t i = 0; i < l.size(); ++i) {
- if (!l[i].empty())
- labeled_item_count++;
- }
+ std::vector<string16> v(values);
+ std::vector<string16> l(labels);
+ std::vector<int> ids(unique_ids);
+ int separator_index = -1;
- // 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());
- ids.push_back(0);
- suggestions_options_index_ = v.size() - 1;
- separator_index = values.size();
- }
+ // 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());
+ ids.push_back(0);
+ suggestions_clear_index_ = v.size() - 1;
+ separator_index = values.size();
+ }
- // Send to WebKit for display.
- if (!v.empty())
- webview()->applyAutoFillSuggestions(
- autofill_query_node_, v, l, ids, separator_index);
+ 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());
+ ids.push_back(0);
+ 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, ids, 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