diff options
author | sreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-06 12:54:31 +0000 |
---|---|---|
committer | sreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-06 12:54:31 +0000 |
commit | 79460c34f007a3ad4b03e70c2be63855d70c683e (patch) | |
tree | 1321052519d49336efa70a6d327948976870d8d1 | |
parent | 5d98d8698226189a3ca330b43ee2afbd29b81a13 (diff) | |
download | chromium_src-79460c34f007a3ad4b03e70c2be63855d70c683e.zip chromium_src-79460c34f007a3ad4b03e70c2be63855d70c683e.tar.gz chromium_src-79460c34f007a3ad4b03e70c2be63855d70c683e.tar.bz2 |
Use a valid suggestion even if it's empty.
BUG=164424
R=jered@chromium.org
TEST=See bug.
Review URL: https://chromiumcodereview.appspot.com/11437021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171479 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 6135843..8fa633e 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -662,6 +662,8 @@ void InstantController::SetSuggestions( << " type=" << suggestion.type; browser_->SetInstantSuggestion(suggestion); } else { + bool is_valid_suggestion = true; + // Suggestion text should be a full URL for URL suggestions, or the // completion of a query for query suggestions. if (suggestion.type == INSTANT_SUGGESTION_URL) { @@ -670,7 +672,7 @@ void InstantController::SetSuggestions( if (!GURL(suggestion.text).is_valid()) { suggestion.text.insert(0, ASCIIToUTF16("http://")); if (!GURL(suggestion.text).is_valid()) - suggestion = InstantSuggestion(); + is_valid_suggestion = false; } } else if (StartsWith(suggestion.text, last_omnibox_text_, true)) { // The user typed an exact prefix of the suggestion. @@ -681,26 +683,27 @@ void InstantController::SetSuggestions( // for instance, if the user types 'i' and the suggestion is 'INSTANT', // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so // suggest nothing. - suggestion = InstantSuggestion(); + is_valid_suggestion = false; } // Don't suggest gray text if there already was inline autocompletion. // http://crbug.com/162303 if (suggestion.behavior == INSTANT_COMPLETE_NEVER && last_omnibox_text_has_inline_autocompletion_) - suggestion = InstantSuggestion(); + is_valid_suggestion = false; // Don't allow inline autocompletion if the query was verbatim. if (suggestion.behavior == INSTANT_COMPLETE_NOW && last_verbatim_) - suggestion = InstantSuggestion(); - - last_suggestion_ = suggestion; + is_valid_suggestion = false; - if (!suggestion.text.empty()) { + if (is_valid_suggestion) { + last_suggestion_ = suggestion; DVLOG(1) << "SetInstantSuggestion: text='" << suggestion.text << "'" << " behavior=" << suggestion.behavior << " type=" << suggestion.type; browser_->SetInstantSuggestion(suggestion); + } else { + last_suggestion_ = InstantSuggestion(); } } |