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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 return false; | 1094 return false; |
1095 } | 1095 } |
1096 | 1096 |
1097 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { | 1097 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { |
1098 // Do not prerender if the destination URL is the same as the current URL. | 1098 // Do not prerender if the destination URL is the same as the current URL. |
1099 if (match.destination_url == PermanentURL()) | 1099 if (match.destination_url == PermanentURL()) |
1100 return; | 1100 return; |
1101 // It's possible the tab strip does not have an active tab contents, for | 1101 // It's possible the tab strip does not have an active tab contents, for |
1102 // instance if the tab has been closed or on return from a sleep state | 1102 // instance if the tab has been closed or on return from a sleep state |
1103 // (http://crbug.com/105689) | 1103 // (http://crbug.com/105689) |
1104 TabContents* tab = controller_->GetTabContents(); | |
1105 if (!tab) | |
1106 return; | |
1107 prerender::PrerenderManager* prerender_manager = | |
1108 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | |
1109 if (!prerender_manager) | |
1110 return; | |
1111 | 1104 |
1112 content::RenderViewHost* current_host = | 1105 if (TabContents* tab = controller_->GetTabContents()) { |
1113 tab->web_contents()->GetRenderViewHost(); | 1106 gfx::Rect container_bounds; |
1114 gfx::Rect container_bounds; | 1107 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); |
1115 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); | 1108 content::RenderViewHost* current_host = |
1116 prerender_manager->AddPrerenderFromOmnibox( | 1109 tab->web_contents()->GetRenderViewHost(); |
1117 match.destination_url, current_host->GetSessionStorageNamespace(), | 1110 AutocompleteActionPredictor* action_predictor = |
1118 container_bounds.size()); | 1111 AutocompleteActionPredictorFactory::GetForProfile(profile_); |
1112 | |
1113 action_predictor->StartPrerendering( | |
1114 match.destination_url, | |
1115 current_host->GetSessionStorageNamespace(), container_bounds.size()); | |
mmenke
2012/07/09 18:06:57
nit: Any reason current_host->GetSessionStorageNa
mmenke
2012/07/09 18:06:57
I'll defer to Dominich on whether it makes sense t
dominich
2012/07/09 18:25:43
This makes sense and was written after discussion
mmenke
2012/07/10 18:01:13
Thanks for the explanation, sounds reasonable. Ju
gavinp
2012/07/11 17:04:00
Done.
| |
1116 } | |
1119 } | 1117 } |
1120 | 1118 |
1121 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1119 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { |
1122 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1120 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
1123 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1121 // Warm up DNS Prefetch cache, or preconnect to a search service. |
1124 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1122 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
1125 AutocompleteMatch::NUM_TYPES); | 1123 AutocompleteMatch::NUM_TYPES); |
1126 if (profile_->GetNetworkPredictor()) { | 1124 if (profile_->GetNetworkPredictor()) { |
1127 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1125 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
1128 match.destination_url, | 1126 match.destination_url, |
(...skipping 22 matching lines...) Expand all Loading... | |
1151 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; | 1149 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; |
1152 const std::string& url = gurl.spec(); | 1150 const std::string& url = gurl.spec(); |
1153 if (url == chrome::kChromeUINewTabURL) | 1151 if (url == chrome::kChromeUINewTabURL) |
1154 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; | 1152 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; |
1155 if (url == chrome::kAboutBlankURL) | 1153 if (url == chrome::kAboutBlankURL) |
1156 return metrics::OmniboxEventProto_PageClassification_BLANK; | 1154 return metrics::OmniboxEventProto_PageClassification_BLANK; |
1157 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) | 1155 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) |
1158 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; | 1156 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; |
1159 return metrics::OmniboxEventProto_PageClassification_OTHER; | 1157 return metrics::OmniboxEventProto_PageClassification_OTHER; |
1160 } | 1158 } |
OLD | NEW |