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

Unified Diff: chrome/browser/ui/search/instant_controller.cc

Issue 13813006: Instant: Don't allow the page to set suggestions inappropriately. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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
Index: chrome/browser/ui/search/instant_controller.cc
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc
index 2778b8cda78638862b7101889192983b583316fe..3a555d1a9b5cbc902021a97a61edcbd121eec72c 100644
--- a/chrome/browser/ui/search/instant_controller.cc
+++ b/chrome/browser/ui/search/instant_controller.cc
@@ -1144,6 +1144,7 @@ void InstantController::SetSuggestions(
// what it's showing, as the user arrows up/down through the page-provided
// suggestions). So, update these state variables here.
last_omnibox_text_ = suggestion.text;
+ last_user_text_.clear();
last_suggestion_ = InstantSuggestion();
last_match_was_search_ = suggestion.type == INSTANT_SUGGESTION_SEARCH;
LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
@@ -1556,6 +1557,11 @@ void InstantController::SendMostVisitedItems(
}
bool InstantController::FixSuggestion(InstantSuggestion* suggestion) const {
+ // We only accept suggestions if the user has typed text. If the user is
+ // arrowing up/down (|last_user_text_| is empty), we reject suggestions.
+ if (last_user_text_.empty())
+ return false;
+
// If the page is trying to set inline autocompletion in verbatim mode,
// instead try suggesting the exact omnibox text. This makes the omnibox
// interpret user text as an URL if possible while preventing unwanted
@@ -1630,4 +1636,3 @@ bool InstantController::ShouldSwitchToLocalNTP() const {
return chrome::IsAggressiveLocalNTPFallbackEnabled();
}
-
« no previous file with comments | « chrome/browser/ui/search/instant_controller.h ('k') | chrome/browser/ui/search/instant_extended_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698