| 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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 43 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 44 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 44 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
| 45 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 45 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 46 #include "chrome/browser/ui/search/search_tab_helper.h" | 46 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 47 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 47 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 48 #include "chrome/common/chrome_notification_types.h" | 48 #include "chrome/common/chrome_notification_types.h" |
| 49 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
| 50 #include "chrome/common/pref_names.h" | 50 #include "chrome/common/pref_names.h" |
| 51 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 52 #include "content/public/browser/notification_service.h" | 52 #include "content/public/browser/notification_service.h" |
| 53 #include "content/public/browser/render_process_host.h" |
| 53 #include "content/public/browser/render_view_host.h" | 54 #include "content/public/browser/render_view_host.h" |
| 54 #include "content/public/browser/user_metrics.h" | 55 #include "content/public/browser/user_metrics.h" |
| 55 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" |
| 56 #include "content/public/browser/web_contents_view.h" | 57 #include "content/public/browser/web_contents_view.h" |
| 57 #include "googleurl/src/url_util.h" | 58 #include "googleurl/src/url_util.h" |
| 58 #include "third_party/skia/include/core/SkBitmap.h" | 59 #include "third_party/skia/include/core/SkBitmap.h" |
| 59 | 60 |
| 60 using content::UserMetricsAction; | 61 using content::UserMetricsAction; |
| 61 using predictors::AutocompleteActionPredictor; | 62 using predictors::AutocompleteActionPredictor; |
| 62 using predictors::AutocompleteActionPredictorFactory; | 63 using predictors::AutocompleteActionPredictorFactory; |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 // It's possible the tab strip does not have an active tab contents, for | 1138 // It's possible the tab strip does not have an active tab contents, for |
| 1138 // instance if the tab has been closed or on return from a sleep state | 1139 // instance if the tab has been closed or on return from a sleep state |
| 1139 // (http://crbug.com/105689) | 1140 // (http://crbug.com/105689) |
| 1140 TabContents* tab = controller_->GetTabContents(); | 1141 TabContents* tab = controller_->GetTabContents(); |
| 1141 if (!tab) | 1142 if (!tab) |
| 1142 return; | 1143 return; |
| 1143 gfx::Rect container_bounds; | 1144 gfx::Rect container_bounds; |
| 1144 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); | 1145 tab->web_contents()->GetView()->GetContainerBounds(&container_bounds); |
| 1145 AutocompleteActionPredictorFactory::GetForProfile(profile_)-> | 1146 AutocompleteActionPredictorFactory::GetForProfile(profile_)-> |
| 1146 StartPrerendering(match.destination_url, | 1147 StartPrerendering(match.destination_url, |
| 1147 tab->web_contents()->GetRenderViewHost()-> | 1148 tab->web_contents()->GetController() |
| 1148 GetSessionStorageNamespace(), | 1149 .GetSessionStorageNamespaceMap(), |
| 1149 container_bounds.size()); | 1150 container_bounds.size()); |
| 1150 } | 1151 } |
| 1151 | 1152 |
| 1152 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1153 void OmniboxEditModel::DoPreconnect(const AutocompleteMatch& match) { |
| 1153 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1154 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
| 1154 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1155 // Warm up DNS Prefetch cache, or preconnect to a search service. |
| 1155 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1156 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
| 1156 AutocompleteMatch::NUM_TYPES); | 1157 AutocompleteMatch::NUM_TYPES); |
| 1157 if (profile_->GetNetworkPredictor()) { | 1158 if (profile_->GetNetworkPredictor()) { |
| 1158 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1159 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 void OmniboxEditModel::ClassifyStringForPasteAndGo( | 1194 void OmniboxEditModel::ClassifyStringForPasteAndGo( |
| 1194 const string16& text, | 1195 const string16& text, |
| 1195 AutocompleteMatch* match, | 1196 AutocompleteMatch* match, |
| 1196 GURL* alternate_nav_url) const { | 1197 GURL* alternate_nav_url) const { |
| 1197 DCHECK(match); | 1198 DCHECK(match); |
| 1198 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, | 1199 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, |
| 1199 string16(), false, false, match, alternate_nav_url); | 1200 string16(), false, false, match, alternate_nav_url); |
| 1200 } | 1201 } |
| OLD | NEW |