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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 10553029: Handle interface to prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate to final reviews! Created 8 years, 5 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
« no previous file with comments | « chrome/browser/prerender/prerender_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/omnibox/omnibox_edit_model.h" 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 return false; 1103 return false;
1104 } 1104 }
1105 1105
1106 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { 1106 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) {
1107 // Do not prerender if the destination URL is the same as the current URL. 1107 // Do not prerender if the destination URL is the same as the current URL.
1108 if (match.destination_url == PermanentURL()) 1108 if (match.destination_url == PermanentURL())
1109 return; 1109 return;
1110 // It's possible the tab strip does not have an active tab contents, for 1110 // It's possible the tab strip does not have an active tab contents, for
1111 // instance if the tab has been closed or on return from a sleep state 1111 // instance if the tab has been closed or on return from a sleep state
1112 // (http://crbug.com/105689) 1112 // (http://crbug.com/105689)
1113 TabContents* tab = controller_->GetTabContents();
1114 if (!tab)
1115 return;
1116 prerender::PrerenderManager* prerender_manager =
1117 prerender::PrerenderManagerFactory::GetForProfile(tab->profile());
1118 if (!prerender_manager)
1119 return;
1120 1113
1121 content::RenderViewHost* current_host = 1114 if (TabContents* tab = controller_->GetTabContents()) {
Peter Kasting 2012/07/13 19:35:09 Nit: Don't combine set + test like this. The old
gavinp 2012/07/13 19:59:10 I can definitely change this if there's consensus,
Peter Kasting 2012/07/13 20:56:41 I haven't seen this used in Chromium code and I re
1122 tab->web_contents()->GetRenderViewHost(); 1115 gfx::Rect container_bounds;
1123 gfx::Rect container_bounds; 1116 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds);
1124 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); 1117 content::RenderViewHost* current_host =
Peter Kasting 2012/07/13 19:35:09 Nit: Could just inline these next two temps into t
gavinp 2012/07/13 19:59:10 Done.
1125 prerender_manager->AddPrerenderFromOmnibox( 1118 tab->web_contents()->GetRenderViewHost();
1126 match.destination_url, current_host->GetSessionStorageNamespace(), 1119 AutocompleteActionPredictor* action_predictor =
1127 container_bounds.size()); 1120 AutocompleteActionPredictorFactory::GetForProfile(profile_);
1121
Peter Kasting 2012/07/13 19:35:09 Nit: Unnecessary blank line
gavinp 2012/07/13 19:59:10 Done.
1122 action_predictor->StartPrerendering(
1123 match.destination_url, current_host->GetSessionStorageNamespace(),
1124 container_bounds.size());
1125 }
1128 } 1126 }
1129 1127
1130 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { 1128 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) {
1131 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { 1129 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) {
1132 // Warm up DNS Prefetch cache, or preconnect to a search service. 1130 // Warm up DNS Prefetch cache, or preconnect to a search service.
1133 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, 1131 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type,
1134 AutocompleteMatch::NUM_TYPES); 1132 AutocompleteMatch::NUM_TYPES);
1135 if (profile_->GetNetworkPredictor()) { 1133 if (profile_->GetNetworkPredictor()) {
1136 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( 1134 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl(
1137 match.destination_url, 1135 match.destination_url,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 } 1167 }
1170 1168
1171 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1169 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1172 const string16& text, 1170 const string16& text,
1173 AutocompleteMatch* match, 1171 AutocompleteMatch* match,
1174 GURL* alternate_nav_url) const { 1172 GURL* alternate_nav_url) const {
1175 DCHECK(match); 1173 DCHECK(match);
1176 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1174 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1177 string16(), false, false, match, alternate_nav_url); 1175 string16(), false, false, match, alternate_nav_url);
1178 } 1176 }
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698