summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authordominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 03:19:33 +0000
committerdominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-08 03:19:33 +0000
commit65d68da4806e736a53cf263cbeba8fcae6c06b87 (patch)
tree0d2ef27d05e305ed7fb8ba95d9695cfc27c2e7fd /chrome/browser/autocomplete
parentd25dd3cbcb3002055eeb48ae2e198cb1a83a37d2 (diff)
downloadchromium_src-65d68da4806e736a53cf263cbeba8fcae6c06b87.zip
chromium_src-65d68da4806e736a53cf263cbeba8fcae6c06b87.tar.gz
chromium_src-65d68da4806e736a53cf263cbeba8fcae6c06b87.tar.bz2
Fix prerender-from-omnibox/Instant issues.
When we attempt to show an Instant preview tab we return a boolean to indicate success. We then only try to prerender if this returns false and if the prerender-from-omnibox flag is set. BUG=94423 TEST=Manual: Tested combinations of no flags, --prerender-from-omnibox, and --restrict-instant-to-search. Review URL: http://codereview.chromium.org/7828057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100091 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc33
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.h7
2 files changed, 27 insertions, 13 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index 97e7d0c..b4950e8 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -217,8 +217,9 @@ void AutocompleteEditModel::OnChanged() {
network_action_predictor_.RecommendAction(user_text_, current_match);
UMA_HISTOGRAM_ENUMERATION("NetworkActionPredictor.Action", recommended_action,
NetworkActionPredictor::LAST_PREDICT_ACTION);
- if (!DoInstant(current_match, &suggested_text)) {
- // Ignore the recommended action if the flag is not set.
+ bool might_support_instant = false;
+ if (!DoInstant(current_match, &suggested_text, &might_support_instant)) {
+ // Ignore the recommended action if Omnibox prerendering is not enabled.
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kPrerenderFromOmnibox)) {
recommended_action = NetworkActionPredictor::ACTION_NONE;
@@ -237,7 +238,9 @@ void AutocompleteEditModel::OnChanged() {
NOTREACHED() << "Unexpected recommended action: " << recommended_action;
break;
}
+ }
+ if (!might_support_instant) {
// Hide any suggestions we might be showing.
view_->SetInstantSuggestion(string16(), false);
@@ -978,8 +981,12 @@ bool AutocompleteEditModel::ShouldAllowExactKeywordMatch(
}
bool AutocompleteEditModel::DoInstant(const AutocompleteMatch& match,
- string16* suggested_text) {
+ string16* suggested_text,
+ bool* might_support_instant) {
DCHECK(suggested_text);
+ DCHECK(might_support_instant);
+
+ *might_support_instant = false;
if (in_revert_)
return false;
@@ -991,6 +998,7 @@ bool AutocompleteEditModel::DoInstant(const AutocompleteMatch& match,
TabContentsWrapper* tab = controller_->GetTabContentsWrapper();
+ bool instant_is_active = false;
if (user_input_in_progress() && popup_->IsOpen()) {
if (match.destination_url == PermanentURL()) {
// The destination is the same as the current url. This typically
@@ -998,25 +1006,28 @@ bool AutocompleteEditModel::DoInstant(const AutocompleteMatch& match,
// case we don't want to load a preview.
instant->DestroyPreviewContentsAndLeaveActive();
} else {
- instant->Update(tab, match, view_->GetText(), UseVerbatimInstant(),
- suggested_text);
+ instant_is_active = instant->Update(tab, match, view_->GetText(),
+ UseVerbatimInstant(), suggested_text);
}
} else {
instant->DestroyPreviewContents();
}
- return instant->MightSupportInstant();
+ *might_support_instant = instant->MightSupportInstant();
+ return instant_is_active;
}
void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) {
// Do not prerender if the destination URL is the same as the current URL.
if (match.destination_url == PermanentURL())
return;
- TabContentsWrapper* tab = controller_->GetTabContentsWrapper();
- prerender::PrerenderManager* prerender_manager =
- tab->profile()->GetPrerenderManager();
- if (prerender_manager)
- prerender_manager->AddPrerenderFromOmnibox(match.destination_url);
+ if (user_input_in_progress() && popup_->IsOpen()) {
+ TabContentsWrapper* tab = controller_->GetTabContentsWrapper();
+ prerender::PrerenderManager* prerender_manager =
+ tab->profile()->GetPrerenderManager();
+ if (prerender_manager)
+ prerender_manager->AddPrerenderFromOmnibox(match.destination_url);
+ }
}
void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) {
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index ff92b70..b31b2a6 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -423,8 +423,11 @@ class AutocompleteEditModel : public AutocompleteControllerDelegate {
size_t caret_position);
// Tries to start an instant preview for |match|. Returns true if instant is
- // supported. |suggested_text| must be non-NULL.
- bool DoInstant(const AutocompleteMatch& match, string16* suggested_text);
+ // showing and sets |might_support_instant| to true if instant is supported.
+ // |suggested_text| and |might_support_instant| must be non-NULL.
+ bool DoInstant(const AutocompleteMatch& match,
+ string16* suggested_text,
+ bool* might_support_instant);
// Starts a prerender for the given |match|.
void DoPrerender(const AutocompleteMatch& match);