| Index: chrome/browser/instant/instant_controller.cc
|
| diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
|
| index f0241917dd04ac53212ea1a86d935a033c692cb8..765f2112b27eff7dbe4c53a268333d7bd2f9d67b 100644
|
| --- a/chrome/browser/instant/instant_controller.cc
|
| +++ b/chrome/browser/instant/instant_controller.cc
|
| @@ -425,6 +425,10 @@ bool InstantController::IsPreviewingSearchResults() const {
|
| IsFullHeight(model_);
|
| }
|
|
|
| +bool InstantController::IsInstantExtendedSearch() const {
|
| + return extended_enabled_ && instant_enabled_ && last_match_was_search_;
|
| +}
|
| +
|
| bool InstantController::CommitIfPossible(InstantCommitType type) {
|
| if (!extended_enabled_ && !instant_enabled_)
|
| return false;
|
| @@ -455,29 +459,17 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
|
| content::WebContents* preview = loader_->ReleaseContents();
|
|
|
| if (extended_enabled_) {
|
| - // Consider what's happening:
|
| - // 1. The user has typed a query in the omnibox and committed it (either
|
| - // by pressing Enter or clicking on the preview).
|
| - // 2. We commit the preview to the tab strip, and tell the page.
|
| - // 3. The page will update the URL hash fragment with the query terms.
|
| - // After steps 1 and 3, the omnibox will show the query terms. However, if
|
| - // the URL we are committing at step 2 doesn't already have query terms, it
|
| - // will flash for a brief moment as a plain URL. So, avoid that flicker by
|
| - // pretending that the plain URL is actually the typed query terms.
|
| - // TODO(samarth,beaudoin): Instead of this hack, we should add a new field
|
| - // to NavigationEntry to keep track of what the correct query, if any, is.
|
| - content::NavigationEntry* entry =
|
| - preview->GetController().GetVisibleEntry();
|
| - std::string url = entry->GetVirtualURL().spec();
|
| - if (!google_util::IsInstantExtendedAPIGoogleSearchUrl(url) &&
|
| - google_util::IsGoogleDomainUrl(url, google_util::ALLOW_SUBDOMAIN,
|
| - google_util::ALLOW_NON_STANDARD_PORTS)) {
|
| - entry->SetVirtualURL(GURL(
|
| - url + "#q=" +
|
| - net::EscapeQueryParamValue(UTF16ToUTF8(last_omnibox_text_), true)));
|
| - chrome::search::SearchTabHelper::FromWebContents(preview)->
|
| - NavigationEntryUpdated();
|
| + string16 search_terms = last_omnibox_text_;
|
| + if (type == INSTANT_COMMIT_FOCUS_LOST &&
|
| + last_suggestion_.behavior == INSTANT_COMPLETE_NEVER) {
|
| + // User clicked on the preview, which makes a search based on the input +
|
| + // gray text (i.e. |last_suggestion_.text|). Make sure the search terms
|
| + // reflect this search.
|
| + search_terms += last_suggestion_.text;
|
| }
|
| + preview->GetController().GetActiveEntry()->SetSearchTerms(search_terms);
|
| + chrome::search::SearchTabHelper::FromWebContents(preview)->
|
| + NavigationEntryUpdated();
|
| }
|
|
|
| // If the preview page has navigated since the last Update(), we need to add
|
|
|