diff options
author | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-18 08:05:37 +0000 |
---|---|---|
committer | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-18 08:05:37 +0000 |
commit | fc3dbd9016cfa343a1b03eb0c78e98da6e6968eb (patch) | |
tree | 331d959dfe15ea973b1444931c70dbe4374af20a /chrome/renderer/render_view.cc | |
parent | d139a130adb6b17921e1a71da21fcc8fc5c73722 (diff) | |
download | chromium_src-fc3dbd9016cfa343a1b03eb0c78e98da6e6968eb.zip chromium_src-fc3dbd9016cfa343a1b03eb0c78e98da6e6968eb.tar.gz chromium_src-fc3dbd9016cfa343a1b03eb0c78e98da6e6968eb.tar.bz2 |
The autocomplete popup is now closed when no suggestions are available.
BUG=49012
TEST=See bug.
Original review:
http://codereview.chromium.org/2819051
Review URL: http://codereview.chromium.org/3040007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view.cc')
-rw-r--r-- | chrome/renderer/render_view.cc | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index f737994..ffba7e6 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1515,44 +1515,48 @@ void RenderView::OnAutoFillSuggestionsReturned( 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; - - // 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(); - } - - size_t labeled_item_count = 0; - for (size_t i = 0; i < l.size(); ++i) { - if (!l[i].empty()) - labeled_item_count++; - } + if (!webview() || query_id != autofill_query_id_) + return; - // 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(); - } + // Any popup currently showing is now obsolete. + webview()->hidePopups(); - // Send to WebKit for display. - if (!v.empty()) - webview()->applyAutoFillSuggestions( - autofill_query_node_, v, l, ids, separator_index); - } + std::vector<string16> v(values); + std::vector<string16> l(labels); + std::vector<int> ids(unique_ids); + 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()); + ids.push_back(0); + 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()); + 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, |