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

Unified Diff: chrome/browser/instant/instant_controller.cc

Issue 7210020: Added prerendering to omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 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 | « chrome/browser/instant/instant_controller.h ('k') | chrome/browser/prerender/prerender_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 592c0e3c1004ce28ab3e541f076ece07c9befd02..7269522a7910fa34a8cf3adeabfa6bf378522b88 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/instant/promo_counter.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
@@ -167,7 +168,23 @@ void InstantController::Update(TabContentsWrapper* tab_contents,
return;
}
- if (!ShouldShowPreviewFor(match, &template_url)) {
+ PreviewCondition preview_condition = GetPreviewConditionFor(match,
+ &template_url);
+ if (preview_condition == PREVIEW_CONDITION_SUCCESS) {
+ // Do nothing if we should show it.
+ } else if (preview_condition == PREVIEW_CONDITION_INSTANT_SEARCH_ONLY) {
+ // Start Prerender of this page instead.
+ prerender::PrerenderManager* prerender_manager =
+ tab_contents_->profile()->GetPrerenderManager();
+ if (prerender_manager) {
+ prerender_manager->AddPrerender(prerender::ORIGIN_OMNIBOX,
+ match.destination_url);
+ }
+
+ DestroyPreviewContentsAndLeaveActive();
+ return;
+ } else {
+ // Just destroy the preview and cancel the update.
DestroyPreviewContentsAndLeaveActive();
return;
}
@@ -661,8 +678,8 @@ void InstantController::UpdateLoader(const TemplateURL* template_url,
UpdateDisplayableLoader();
}
-bool InstantController::ShouldShowPreviewFor(const AutocompleteMatch& match,
- const TemplateURL** template_url) {
+InstantController::PreviewCondition InstantController::GetPreviewConditionFor(
+ const AutocompleteMatch& match, const TemplateURL** template_url) {
const TemplateURL* t_url = GetTemplateURL(match);
if (t_url) {
if (!t_url->id() ||
@@ -671,21 +688,21 @@ bool InstantController::ShouldShowPreviewFor(const AutocompleteMatch& match,
!t_url->instant_url()->SupportsReplacement()) {
// To avoid extra load on other search engines we only enable previews if
// they support the instant API.
- return false;
+ return PREVIEW_CONDITION_INVALID_TEMPLATE_URL;
}
}
*template_url = t_url;
if (match.destination_url.SchemeIs(chrome::kJavaScriptScheme))
- return false;
+ return PREVIEW_CONDITION_JAVASCRIPT_SCHEME;
- // Extension keywords don't have a real destionation URL.
+ // Extension keywords don't have a real destination URL.
if (match.template_url && match.template_url->IsExtensionKeyword())
- return false;
+ return PREVIEW_CONDITION_EXTENSION_KEYWORD;
// Was the host blacklisted?
if (host_blacklist_ && host_blacklist_->count(match.destination_url.host()))
- return false;
+ return PREVIEW_CONDITION_BLACKLISTED;
const CommandLine* cl = CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kRestrictInstantToSearch) &&
@@ -693,10 +710,10 @@ bool InstantController::ShouldShowPreviewFor(const AutocompleteMatch& match,
match.type != AutocompleteMatch::SEARCH_HISTORY &&
match.type != AutocompleteMatch::SEARCH_SUGGEST &&
match.type != AutocompleteMatch::SEARCH_OTHER_ENGINE) {
- return false;
+ return PREVIEW_CONDITION_INSTANT_SEARCH_ONLY;
}
- return true;
+ return PREVIEW_CONDITION_SUCCESS;
}
void InstantController::BlacklistFromInstant(TemplateURLID id) {
« no previous file with comments | « chrome/browser/instant/instant_controller.h ('k') | chrome/browser/prerender/prerender_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698