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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1087 | 1087 |
1088 // It's possible DoInstant() was called due to an OnChanged() event from the | 1088 // It's possible DoInstant() was called due to an OnChanged() event from the |
1089 // omnibox view if the user clicked the renderer while IME composition was | 1089 // omnibox view if the user clicked the renderer while IME composition was |
1090 // active. In that case we still want to commit on mouse up, so don't call | 1090 // active. In that case we still want to commit on mouse up, so don't call |
1091 // Hide(). | 1091 // Hide(). |
1092 if (!instant->commit_on_mouse_up()) | 1092 if (!instant->commit_on_mouse_up()) |
1093 instant->Hide(); | 1093 instant->Hide(); |
1094 return false; | 1094 return false; |
1095 } | 1095 } |
1096 | 1096 |
1097 void OmniboxEditModel::DoPrerender(const AutocompleteMatch& match) { | 1097 void OmniboxEditModel::DoPrerender( |
dominich
2012/07/02 20:43:03
this should still fit on one line.
gavinp
2012/07/03 16:41:02
Done.
| |
1098 const AutocompleteMatch& match) { | |
1098 // Do not prerender if the destination URL is the same as the current URL. | 1099 // Do not prerender if the destination URL is the same as the current URL. |
1099 if (match.destination_url == PermanentURL()) | 1100 if (match.destination_url == PermanentURL()) |
1100 return; | 1101 return; |
1101 // It's possible the tab strip does not have an active tab contents, for | 1102 // 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 | 1103 // instance if the tab has been closed or on return from a sleep state |
1103 // (http://crbug.com/105689) | 1104 // (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 | 1105 |
1112 content::RenderViewHost* current_host = | 1106 if (TabContents* tab = controller_->GetTabContents()) { |
1113 tab->web_contents()->GetRenderViewHost(); | 1107 gfx::Rect container_bounds; |
1114 gfx::Rect container_bounds; | 1108 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); |
1115 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); | 1109 content::RenderViewHost* current_host = |
1116 prerender_manager->AddPrerenderFromOmnibox( | 1110 tab->web_contents()->GetRenderViewHost(); |
1117 match.destination_url, current_host->GetSessionStorageNamespace(), | 1111 AutocompleteActionPredictor* action_predictor = |
1118 container_bounds.size()); | 1112 AutocompleteActionPredictorFactory::GetForProfile(profile_); |
1113 | |
1114 action_predictor->StartPrerendering( | |
1115 match.destination_url, | |
1116 current_host->GetSessionStorageNamespace(), container_bounds.size()); | |
1117 } | |
1119 } | 1118 } |
1120 | 1119 |
1121 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1120 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { |
1122 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1121 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
1123 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1122 // Warm up DNS Prefetch cache, or preconnect to a search service. |
1124 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1123 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
1125 AutocompleteMatch::NUM_TYPES); | 1124 AutocompleteMatch::NUM_TYPES); |
1126 if (profile_->GetNetworkPredictor()) { | 1125 if (profile_->GetNetworkPredictor()) { |
1127 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1126 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
1128 match.destination_url, | 1127 match.destination_url, |
(...skipping 22 matching lines...) Expand all Loading... | |
1151 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; | 1150 return metrics::OmniboxEventProto_PageClassification_INVALID_SPEC; |
1152 const std::string& url = gurl.spec(); | 1151 const std::string& url = gurl.spec(); |
1153 if (url == chrome::kChromeUINewTabURL) | 1152 if (url == chrome::kChromeUINewTabURL) |
1154 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; | 1153 return metrics::OmniboxEventProto_PageClassification_NEW_TAB_PAGE; |
1155 if (url == chrome::kAboutBlankURL) | 1154 if (url == chrome::kAboutBlankURL) |
1156 return metrics::OmniboxEventProto_PageClassification_BLANK; | 1155 return metrics::OmniboxEventProto_PageClassification_BLANK; |
1157 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) | 1156 if (url == profile()->GetPrefs()->GetString(prefs::kHomePage)) |
1158 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; | 1157 return metrics::OmniboxEventProto_PageClassification_HOMEPAGE; |
1159 return metrics::OmniboxEventProto_PageClassification_OTHER; | 1158 return metrics::OmniboxEventProto_PageClassification_OTHER; |
1160 } | 1159 } |
OLD | NEW |