Prerender Instant search base url on omnibox focus event.

                                                                                
Prerenders the Instant search base page URL on omnibox focus event provided the 
underlying page is not a search results page and not in incognito profile.      
Prerender request for the current tab is cancelled when a navigation entry is   
committed or when the current tab is deactivated.                               
                                                                                
BUG=384106                                                                      
TEST=Run canary chrome with the following flags:                                
--prefetch-search-results --prerender=enabled --force-fieldtrials="EmbeddedSearch/Group1 prerender_instant_url_on_omnibox_focus:1"

Review URL: https://codereview.chromium.org/338633003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278731 0039d316-1c4b-4281-b951-d872f2087c98
parent 543489d6
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "chrome/browser/ui/omnibox/omnibox_edit_model.h" #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h" #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "chrome/browser/ui/omnibox/omnibox_view.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_ipc_router_policy_impl.h"
#include "chrome/browser/ui/search/search_tab_helper_delegate.h" #include "chrome/browser/ui/search/search_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
...@@ -183,6 +184,22 @@ void SearchTabHelper::OmniboxFocusChanged(OmniboxFocusState state, ...@@ -183,6 +184,22 @@ void SearchTabHelper::OmniboxFocusChanged(OmniboxFocusState state,
// a spurious oninputend when the user accepts a match in the omnibox. // a spurious oninputend when the user accepts a match in the omnibox.
if (web_contents_->GetController().GetPendingEntry() == NULL) { if (web_contents_->GetController().GetPendingEntry() == NULL) {
ipc_router_.SetInputInProgress(IsInputInProgress()); 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());
}
} }
} }
...@@ -226,6 +243,18 @@ void SearchTabHelper::Submit(const base::string16& text) { ...@@ -226,6 +243,18 @@ void SearchTabHelper::Submit(const base::string16& text) {
void SearchTabHelper::OnTabActivated() { void SearchTabHelper::OnTabActivated() {
ipc_router_.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() { void SearchTabHelper::OnTabDeactivated() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment