From a6fdd5eb2eb38f12d116f48c892c077bb3be852d Mon Sep 17 00:00:00 2001 From: "sreeram@chromium.org" Date: Tue, 16 Apr 2013 06:54:20 +0000 Subject: Instant: Clear autocomplete results on a "blank query onchange". BUG=231738 R=samarth@chromium.org TEST=See bug. Review URL: https://codereview.chromium.org/14265016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194313 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/searchbox/searchbox.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'chrome/renderer/searchbox') diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc index def746d..b48c383 100644 --- a/chrome/renderer/searchbox/searchbox.cc +++ b/chrome/renderer/searchbox/searchbox.cc @@ -226,6 +226,18 @@ void SearchBox::OnChange(const string16& query, verbatim_ = verbatim; selection_start_ = selection_start; selection_end_ = selection_end; + + // If |query| is empty, this is due to the user backspacing away all the text + // in the omnibox, or hitting Escape to restore the "permanent URL", or + // switching tabs, etc. In all these cases, there will be no corresponding + // OnAutocompleteResults(), so clear the autocomplete results ourselves, by + // adding an empty set. Don't notify the page using an "onnativesuggestions" + // event, though. + if (query.empty()) { + autocomplete_results_cache_.AddItems( + std::vector()); + } + if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { DVLOG(1) << render_view() << " OnChange"; extensions_v8::SearchBoxExtension::DispatchChange( -- cgit v1.1