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

Unified Diff: chrome/browser/instant/instant_controller.cc

Issue 12035083: [Instant] Update InstantController state to ensure valid subsequent queries (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: tweak Created 7 years, 11 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/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 087a4526ffcb7de4c0e114e44c527c22a24c7cb5..7c8880b463866b88e49db040a9b0efa54134dc33 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -559,8 +559,12 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
// last_omnibox_text_. Clicking on the overlay commits what is currently
// showing, so add in the gray text in that case.
std::string query(UTF16ToUTF8(last_omnibox_text_));
- if (type != INSTANT_COMMIT_PRESSED_ENTER)
+ if (type != INSTANT_COMMIT_PRESSED_ENTER) {
query += UTF16ToUTF8(last_suggestion_.text);
+ // Update |last_omnibox_text_| so that the controller commits the proper
+ // query if the user focuses the omnibox and presses Enter.
+ last_omnibox_text_ += last_suggestion_.text;
+ }
entry->SetVirtualURL(GURL(
url + "#q=" +
net::EscapeQueryParamValue(query, true)));
@@ -760,11 +764,14 @@ void InstantController::SetSuggestions(
if (instant_tab_ && search_mode_.is_search_results() &&
suggestion.behavior == INSTANT_COMPLETE_REPLACE) {
+ // Update |last_omnibox_text_| so that the controller commits the proper
+ // query if the user focuses the omnibox and presses Enter.
+ last_omnibox_text_ = suggestion.text;
+ last_suggestion_ = InstantSuggestion();
+ last_match_was_search_ = suggestion.type == INSTANT_SUGGESTION_SEARCH;
// This means a committed page in state search called setValue(). We should
// update the omnibox to reflect what the search page says.
browser_->SetInstantSuggestion(suggestion);
- // Don't update last_omnibox_text_ or last_suggestion_ since the user is not
- // currently editing text in the omnibox.
return;
}
« 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