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

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: Rename update_instant_ and refactor conditionals. 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
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..96c1ffc74cb330de2cf54ec846ecf201b1c84da4 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,22 @@ void InstantController::Update(TabContentsWrapper* tab_contents,
return;
}
- if (!ShouldShowPreviewFor(match, &template_url)) {
+ PreviewCondition preview_condition = ShouldShowPreviewFor(match,
+ &template_url);
+ if (preview_condition == PREVIEW_CONDITION_SUCCESS) {
+ // Do nothing if we should show it.
+ } else {
sky 2011/06/20 20:53:49 combine else and if, eg: else if (previw_condition
dominich 2011/06/20 21:02:36 Done.
+ if (preview_condition == PREVIEW_CONDITION_INSTANT_SEARCH_ONLY) {
+ // Start Prerender of this page instead.
+ CommandLine* cl = CommandLine::ForCurrentProcess();
+ if (cl->HasSwitch(switches::kPrerenderFromOmnibox)) {
+ prerender::PrerenderManager* prerender_manager =
+ tab_contents_->profile()->GetPrerenderManager();
+ if (prerender_manager)
+ prerender_manager->AddPrerenderWithNoTag(match.destination_url);
+ }
+ }
+
DestroyPreviewContentsAndLeaveActive();
return;
}
@@ -661,8 +677,8 @@ void InstantController::UpdateLoader(const TemplateURL* template_url,
UpdateDisplayableLoader();
}
-bool InstantController::ShouldShowPreviewFor(const AutocompleteMatch& match,
- const TemplateURL** template_url) {
+InstantController::PreviewCondition InstantController::ShouldShowPreviewFor(
+ const AutocompleteMatch& match, const TemplateURL** template_url) {
const TemplateURL* t_url = GetTemplateURL(match);
if (t_url) {
if (!t_url->id() ||
@@ -671,21 +687,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 +709,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) {

Powered by Google App Engine
This is Rietveld 408576698