diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-12 20:52:16 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-12 20:52:16 +0000 |
commit | a155899b7ec708e7affd25bfa6f87940a7490b2c (patch) | |
tree | a74938bb05aaa76025ec2974f9935937b16c4a33 /chrome/browser/ui/omnibox/omnibox_edit_model.cc | |
parent | 7f08375a52884609b72510d5c662ffdda6330afe (diff) | |
download | chromium_src-a155899b7ec708e7affd25bfa6f87940a7490b2c.zip chromium_src-a155899b7ec708e7affd25bfa6f87940a7490b2c.tar.gz chromium_src-a155899b7ec708e7affd25bfa6f87940a7490b2c.tar.bz2 |
Enable Instant Support - Part 2
Follow up of crrev.com/51813002 to:
(1) Prerender the high confidence search suggestions using InstantSearchPrerenderer.
(2) Swap the current tab contents with the prerendered contents when the query is committed.
BUG=269186
TEST=none
Review URL: https://codereview.chromium.org/48113025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/omnibox/omnibox_edit_model.cc')
-rw-r--r-- | chrome/browser/ui/omnibox/omnibox_edit_model.cc | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc index 9ce8881..20bca00 100644 --- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc +++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc @@ -50,6 +50,7 @@ #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" #include "chrome/browser/ui/omnibox/omnibox_view.h" #include "chrome/browser/ui/search/instant_controller.h" +#include "chrome/browser/ui/search/instant_search_prerenderer.h" #include "chrome/browser/ui/search/search_tab_helper.h" #include "chrome/browser/ui/toolbar/toolbar_model.h" #include "chrome/common/chrome_switches.h" @@ -332,19 +333,27 @@ void OmniboxEditModel::OnChanged() { AutocompleteActionPredictor::Action recommended_action = AutocompleteActionPredictor::ACTION_NONE; - AutocompleteActionPredictor* action_predictor = user_input_in_progress_ ? - predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_) : - NULL; - if (action_predictor) { - action_predictor->RegisterTransitionalMatches(user_text_, result()); - // Confer with the AutocompleteActionPredictor to determine what action, if - // any, we should take. Get the recommended action here even if we don't - // need it so we can get stats for anyone who is opted in to UMA, but only - // get it if the user has actually typed something to avoid constructing it - // before it's needed. Note: This event is triggered as part of startup when - // the initial tab transitions to the start page. - recommended_action = - action_predictor->RecommendAction(user_text_, current_match); + if (user_input_in_progress_) { + InstantSearchPrerenderer* prerenderer = + InstantSearchPrerenderer::GetForProfile(profile_); + if (prerenderer && + prerenderer->IsAllowed(current_match, controller_->GetWebContents()) && + popup_model()->IsOpen() && has_focus()) { + recommended_action = AutocompleteActionPredictor::ACTION_PRERENDER; + } else { + AutocompleteActionPredictor* action_predictor = + predictors::AutocompleteActionPredictorFactory::GetForProfile( + profile_); + action_predictor->RegisterTransitionalMatches(user_text_, result()); + // Confer with the AutocompleteActionPredictor to determine what action, + // if any, we should take. Get the recommended action here even if we + // don't need it so we can get stats for anyone who is opted in to UMA, + // but only get it if the user has actually typed something to avoid + // constructing it before it's needed. Note: This event is triggered as + // part of startup when the initial tab transitions to the start page. + recommended_action = + action_predictor->RecommendAction(user_text_, current_match); + } } UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action", @@ -494,8 +503,7 @@ void OmniboxEditModel::Revert() { false, true); AutocompleteActionPredictor* action_predictor = predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_); - if (action_predictor) - action_predictor->ClearTransitionalMatches(); + action_predictor->ClearTransitionalMatches(); } void OmniboxEditModel::StartAutocomplete( |