Index: chrome/browser/ui/search/search_tab_helper.cc |
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc |
index 5086f81134839ebe362d9dfa161dbb4a6af203d6..c8ee73af24d0e1eea8ba05dbb96310fc247c95c3 100644 |
--- a/chrome/browser/ui/search/search_tab_helper.cc |
+++ b/chrome/browser/ui/search/search_tab_helper.cc |
@@ -30,6 +30,14 @@ bool IsSearchResults(const content::WebContents* contents) { |
return !chrome::GetSearchTerms(contents).empty(); |
} |
+// TODO(kmadhusu): Move this helper from anonymous namespace to chrome |
+// namespace and remove InstantPage::IsLocal(). |
+bool IsLocal(const content::WebContents* contents) { |
+ return contents && |
+ (contents->GetURL() == GURL(chrome::kChromeSearchLocalNtpUrl) || |
+ contents->GetURL() == GURL(chrome::kChromeSearchLocalGoogleNtpUrl)); |
+} |
+ |
} // namespace |
SearchTabHelper::SearchTabHelper(content::WebContents* web_contents) |
@@ -90,11 +98,22 @@ bool SearchTabHelper::OnMessageReceived(const IPC::Message& message) { |
OnSearchBoxShowBars) |
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxHideBars, |
OnSearchBoxHideBars) |
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
+ OnInstantSupportDeterminedMsgReceived) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
} |
+void SearchTabHelper::DidFinishLoad( |
+ int64 /* frame_id */, |
+ const GURL& /* validated_url */, |
+ bool is_main_frame, |
+ content::RenderViewHost* /* render_view_host */) { |
+ if (is_main_frame) |
+ DetermineIfPageSupportsInstant(); |
+} |
+ |
void SearchTabHelper::UpdateMode() { |
SearchMode::Type type = SearchMode::MODE_DEFAULT; |
SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; |
@@ -117,12 +136,23 @@ void SearchTabHelper::UpdateMode() { |
// OmniboxEditModel::SetInputInProgress() which is called from |
// OmniboxEditModel::Revert(). |
model_.SetState(SearchModel::State(SearchMode(type, origin), |
- model_.state().top_bars_visible)); |
+ model_.state().top_bars_visible, |
+ model_.instant_support())); |
} else { |
model_.SetMode(SearchMode(type, origin)); |
} |
} |
+void SearchTabHelper::DetermineIfPageSupportsInstant() { |
+ if (IsLocal(web_contents_)) { |
+ // Local pages always support Instant. That's why we keep them around. |
+ int page_id = web_contents_->GetController().GetActiveEntry()->GetPageID(); |
+ OnInstantSupportDeterminedMsgReceived(page_id, true); |
+ } else { |
+ Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(routing_id())); |
+ } |
+} |
+ |
void SearchTabHelper::OnSearchBoxShowBars(int page_id) { |
if (web_contents()->IsActiveEntry(page_id)) |
model_.SetTopBarsVisible(true); |
@@ -134,3 +164,10 @@ void SearchTabHelper::OnSearchBoxHideBars(int page_id) { |
Send(new ChromeViewMsg_SearchBoxBarsHidden(routing_id())); |
} |
} |
+ |
+void SearchTabHelper::OnInstantSupportDeterminedMsgReceived( |
+ int page_id, |
+ bool supports_instant) { |
+ if (web_contents()->IsActiveEntry(page_id)) |
+ model_.SetSupportsInstant(supports_instant); |
+} |