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

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

Issue 11570020: Fix search terms handling on commit (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 8 years 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 50a394e99f0ddd137104d7da50172f7415ee8ffe..50da5b39c0be6523c30c20674dcbaa64fb887489 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -503,9 +503,15 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
if (!google_util::IsInstantExtendedAPIGoogleSearchUrl(url) &&
google_util::IsGoogleDomainUrl(url, google_util::ALLOW_SUBDOMAIN,
google_util::ALLOW_NON_STANDARD_PORTS)) {
+ // Hitting ENTER searches for what the user typed, so use
+ // 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)
+ query += UTF16ToUTF8(last_suggestion_.text);
entry->SetVirtualURL(GURL(
url + "#q=" +
- net::EscapeQueryParamValue(UTF16ToUTF8(last_omnibox_text_), true)));
+ net::EscapeQueryParamValue(query, true)));
chrome::search::SearchTabHelper::FromWebContents(preview)->
NavigationEntryUpdated();
}
@@ -684,10 +690,6 @@ void InstantController::SetSuggestions(
const std::vector<InstantSuggestion>& suggestions) {
DVLOG(1) << "SetSuggestions";
- // Ignore if we are not currently accepting search suggestions.
- if (!search_mode_.is_search_suggestions() || last_omnibox_text_.empty())
- return;
-
// Ignore if the message is from an unexpected source.
if (instant_tab_) {
if (instant_tab_->contents() != contents)
@@ -701,6 +703,20 @@ void InstantController::SetSuggestions(
if (!suggestions.empty())
suggestion = suggestions[0];
+ if (instant_tab_ && search_mode_.is_search_results() &&
+ suggestion.behavior == INSTANT_COMPLETE_REPLACE) {
+ // 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;
+ }
+
+ // Ignore if we are not currently accepting search suggestions.
+ if (!search_mode_.is_search_suggestions() || last_omnibox_text_.empty())
+ return;
+
if (suggestion.behavior == INSTANT_COMPLETE_REPLACE) {
// We don't get an Update() when changing the omnibox due to a REPLACE
// suggestion (so that we don't inadvertently cause the preview to change
« 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