Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { | 1115 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { |
| 1116 // Do not prerender if the destination URL is the same as the current URL. | 1116 // Do not prerender if the destination URL is the same as the current URL. |
| 1117 if (match.destination_url == PermanentURL()) | 1117 if (match.destination_url == PermanentURL()) |
| 1118 return; | 1118 return; |
| 1119 // It's possible the tab strip does not have an active tab contents, for | 1119 // It's possible the tab strip does not have an active tab contents, for |
| 1120 // instance if the tab has been closed or on return from a sleep state | 1120 // instance if the tab has been closed or on return from a sleep state |
| 1121 // (http://crbug.com/105689) | 1121 // (http://crbug.com/105689) |
| 1122 TabContents* tab = controller_->GetTabContents(); | 1122 TabContents* tab = controller_->GetTabContents(); |
| 1123 if (!tab) | 1123 if (!tab) |
| 1124 return; | 1124 return; |
| 1125 prerender::PrerenderManager* prerender_manager = | |
| 1126 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | |
| 1127 if (!prerender_manager) | |
| 1128 return; | |
| 1129 | |
| 1130 content::RenderViewHost* current_host = | |
| 1131 tab->web_contents()->GetRenderViewHost(); | |
| 1132 gfx::Rect container_bounds; | 1125 gfx::Rect container_bounds; |
| 1133 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); | 1126 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); |
| 1134 prerender_manager->AddPrerenderFromOmnibox( | 1127 AutocompleteActionPredictorFactory::GetForProfile(profile_)-> |
| 1135 match.destination_url, current_host->GetSessionStorageNamespace(), | 1128 StartPrerendering(match.destination_url, |
|
gavinp
2012/07/14 14:04:52
I think this did end up looking a lot better after
| |
| 1136 container_bounds.size()); | 1129 tab->web_contents()->GetRenderViewHost()-> |
| 1130 GetSessionStorageNamespace(), | |
| 1131 container_bounds.size()); | |
| 1137 } | 1132 } |
| 1138 | 1133 |
| 1139 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1134 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { |
| 1140 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1135 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
| 1141 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1136 // Warm up DNS Prefetch cache, or preconnect to a search service. |
| 1142 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1137 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
| 1143 AutocompleteMatch::NUM_TYPES); | 1138 AutocompleteMatch::NUM_TYPES); |
| 1144 if (profile_->GetNetworkPredictor()) { | 1139 if (profile_->GetNetworkPredictor()) { |
| 1145 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1140 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 1146 match.destination_url, | 1141 match.destination_url, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1178 } | 1173 } |
| 1179 | 1174 |
| 1180 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1175 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1181 const string16& text, | 1176 const string16& text, |
| 1182 AutocompleteMatch* match, | 1177 AutocompleteMatch* match, |
| 1183 GURL* alternate_nav_url) const { | 1178 GURL* alternate_nav_url) const { |
| 1184 DCHECK(match); | 1179 DCHECK(match); |
| 1185 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1180 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1186 string16(), false, false, match, alternate_nav_url); | 1181 string16(), false, false, match, alternate_nav_url); |
| 1187 } | 1182 } |
| OLD | NEW |