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

Unified Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 338633003: Prerender Instant search base url on omnibox focus event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Active Navgiation check added Created 6 years, 6 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/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 b117ad020d24c398cc3042ed0019dc3e3e713317..3fc779bd6ef562d5fab118ed56ed5ac38648d313 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
+#include "chrome/browser/ui/search/instant_search_prerenderer.h"
#include "chrome/browser/ui/search/search_ipc_router_policy_impl.h"
#include "chrome/browser/ui/search/search_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
@@ -171,6 +172,22 @@ void SearchTabHelper::OmniboxFocusChanged(OmniboxFocusState state,
// a spurious oninputend when the user accepts a match in the omnibox.
if (web_contents_->GetController().GetPendingEntry() == NULL) {
ipc_router_.SetInputInProgress(IsInputInProgress());
+
+ InstantSearchPrerenderer* prerenderer =
+ InstantSearchPrerenderer::GetForProfile(profile());
+ if (!prerenderer || !chrome::ShouldPrerenderInstantUrlOnOmniboxFocus())
+ return;
+
+ if (state == OMNIBOX_FOCUS_NONE) {
+ prerenderer->Cancel();
+ return;
+ }
+
+ if (!IsSearchResultsPage()) {
+ prerenderer->Init(
+ web_contents_->GetController().GetSessionStorageNamespaceMap(),
+ web_contents_->GetContainerBounds().size());
+ }
}
}
@@ -214,6 +231,18 @@ void SearchTabHelper::Submit(const base::string16& text) {
void SearchTabHelper::OnTabActivated() {
ipc_router_.OnTabActivated();
+
+ OmniboxView* omnibox_view = GetOmniboxView();
+ if (chrome::ShouldPrerenderInstantUrlOnOmniboxFocus() && omnibox_view &&
+ omnibox_view->model()->has_focus()) {
+ InstantSearchPrerenderer* prerenderer =
+ InstantSearchPrerenderer::GetForProfile(profile());
+ if (prerenderer && !IsSearchResultsPage()) {
+ prerenderer->Init(
+ web_contents_->GetController().GetSessionStorageNamespaceMap(),
+ web_contents_->GetContainerBounds().size());
+ }
+ }
}
void SearchTabHelper::OnTabDeactivated() {
« 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