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

Side by Side 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: Remove TODO 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/instant/instant_controller.h" 5 #include "chrome/browser/instant/instant_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/autocomplete/autocomplete_match.h" 11 #include "chrome/browser/autocomplete/autocomplete_match.h"
12 #include "chrome/browser/instant/instant_delegate.h" 12 #include "chrome/browser/instant/instant_delegate.h"
13 #include "chrome/browser/instant/instant_loader.h" 13 #include "chrome/browser/instant/instant_loader.h"
14 #include "chrome/browser/instant/instant_loader_manager.h" 14 #include "chrome/browser/instant/instant_loader_manager.h"
15 #include "chrome/browser/instant/promo_counter.h" 15 #include "chrome/browser/instant/promo_counter.h"
16 #include "chrome/browser/platform_util.h" 16 #include "chrome/browser/platform_util.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prerender/prerender_manager.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/search_engines/template_url.h" 20 #include "chrome/browser/search_engines/template_url.h"
20 #include "chrome/browser/search_engines/template_url_service.h" 21 #include "chrome/browser/search_engines/template_url_service.h"
21 #include "chrome/browser/search_engines/template_url_service_factory.h" 22 #include "chrome/browser/search_engines/template_url_service_factory.h"
22 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 23 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "content/browser/renderer_host/render_widget_host_view.h" 28 #include "content/browser/renderer_host/render_widget_host_view.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 const TemplateURL* template_url = NULL; 163 const TemplateURL* template_url = NULL;
163 164
164 if (url.is_empty() || !url.is_valid()) { 165 if (url.is_empty() || !url.is_valid()) {
165 // Assume we were invoked with GURL() and should destroy all. 166 // Assume we were invoked with GURL() and should destroy all.
166 DestroyPreviewContents(); 167 DestroyPreviewContents();
167 return; 168 return;
168 } 169 }
169 170
170 if (!ShouldShowPreviewFor(match, &template_url)) { 171 if (!ShouldShowPreviewFor(match, &template_url)) {
171 DestroyPreviewContentsAndLeaveActive(); 172 DestroyPreviewContentsAndLeaveActive();
173 // Start Prerender of this page instead.
174 CommandLine* cl = CommandLine::ForCurrentProcess();
sky 2011/06/20 18:15:54 Seems like you only want to do this if you hit the
dominich 2011/06/20 18:40:00 You're right. I didn't think it would matter that
175 if (cl->HasSwitch(switches::kPrerenderFromOmnibox)) {
176 prerender::PrerenderManager* prerender_manager =
177 tab_contents_->profile()->GetPrerenderManager();
178 if (prerender_manager)
179 prerender_manager->AddPrerenderWithNoTag(match.destination_url);
180 }
172 return; 181 return;
173 } 182 }
174 183
175 if (!loader_manager_.get()) 184 if (!loader_manager_.get())
176 loader_manager_.reset(new InstantLoaderManager(this)); 185 loader_manager_.reset(new InstantLoaderManager(this));
177 186
178 if (!is_active_) { 187 if (!is_active_) {
179 is_active_ = true; 188 is_active_ = true;
180 delegate_->PrepareForInstant(); 189 delegate_->PrepareForInstant();
181 } 190 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 const TemplateURL* template_url = match.template_url; 738 const TemplateURL* template_url = match.template_url;
730 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || 739 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED ||
731 match.type == AutocompleteMatch::SEARCH_HISTORY || 740 match.type == AutocompleteMatch::SEARCH_HISTORY ||
732 match.type == AutocompleteMatch::SEARCH_SUGGEST) { 741 match.type == AutocompleteMatch::SEARCH_SUGGEST) {
733 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( 742 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile(
734 tab_contents_->profile()); 743 tab_contents_->profile());
735 template_url = model ? model->GetDefaultSearchProvider() : NULL; 744 template_url = model ? model->GetDefaultSearchProvider() : NULL;
736 } 745 }
737 return template_url; 746 return template_url;
738 } 747 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698