Index: chrome/browser/ui/toolbar/toolbar_model_impl.cc |
diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc |
index 1d20fa01495539b225dd6be8e8abb57730a8a069..e36b1af4a404d6e9bfac1f836a48c69a0d24d3c4 100644 |
--- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc |
+++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc |
@@ -8,6 +8,7 @@ |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/autocomplete/autocomplete_input.h" |
#include "chrome/browser/google/google_util.h" |
+#include "chrome/browser/instant/instant_controller.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/search_engines/template_url.h" |
@@ -72,6 +73,10 @@ ToolbarModelImpl::~ToolbarModelImpl() { |
string16 ToolbarModelImpl::GetText( |
bool display_search_urls_as_search_terms) const { |
if (display_search_urls_as_search_terms) { |
+ // If search terms were set explicitly on the NavigationEntry, use those. |
+ string16 entry_search_terms = GetSearchTermsFromNavigationEntry(); |
+ if (!entry_search_terms.empty()) |
+ return entry_search_terms; |
string16 search_terms = TryToExtractSearchTermsFromURL(); |
if (!search_terms.empty()) |
return search_terms; |
@@ -107,6 +112,21 @@ bool ToolbarModelImpl::WouldReplaceSearchURLWithSearchTerms() const { |
return !TryToExtractSearchTermsFromURL().empty(); |
} |
+string16 ToolbarModelImpl::GetSearchTermsFromNavigationEntry() const { |
+ NavigationController* controller = GetNavigationController(); |
+ if (controller) { |
+ NavigationEntry* entry = controller->GetVisibleEntry(); |
+ if (entry) { |
+ string16 out_value; |
+ if (entry->GetExtraData( |
+ std::string(InstantController::kInstantExtendedSearchTermsKey), |
+ &out_value)) |
+ return out_value; |
+ } |
+ } |
+ return string16(); |
+} |
+ |
bool ToolbarModelImpl::ShouldDisplayURL() const { |
// Note: The order here is important. |
// - The WebUI test must come before the extension scheme test because there |