| 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/autocomplete/autocomplete_edit.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 // instance if the tab has been closed or on return from a sleep state | 1108 // instance if the tab has been closed or on return from a sleep state |
| 1109 // (http://crbug.com/105689) | 1109 // (http://crbug.com/105689) |
| 1110 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1110 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
| 1111 if (!tab) | 1111 if (!tab) |
| 1112 return; | 1112 return; |
| 1113 prerender::PrerenderManager* prerender_manager = | 1113 prerender::PrerenderManager* prerender_manager = |
| 1114 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | 1114 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); |
| 1115 if (prerender_manager) { | 1115 if (prerender_manager) { |
| 1116 RenderViewHost* current_host = tab->web_contents()->GetRenderViewHost(); | 1116 RenderViewHost* current_host = tab->web_contents()->GetRenderViewHost(); |
| 1117 prerender_manager->AddPrerenderFromOmnibox( | 1117 prerender_manager->AddPrerenderFromOmnibox( |
| 1118 match.destination_url, current_host->session_storage_namespace()); | 1118 match.destination_url, current_host->GetSessionStorageNamespace()); |
| 1119 } | 1119 } |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1122 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { |
| 1123 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1123 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
| 1124 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1124 // Warm up DNS Prefetch cache, or preconnect to a search service. |
| 1125 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1125 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
| 1126 AutocompleteMatch::NUM_TYPES); | 1126 AutocompleteMatch::NUM_TYPES); |
| 1127 if (profile_->GetNetworkPredictor()) { | 1127 if (profile_->GetNetworkPredictor()) { |
| 1128 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1128 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 1129 match.destination_url, | 1129 match.destination_url, |
| 1130 NetworkActionPredictor::IsPreconnectable(match)); | 1130 NetworkActionPredictor::IsPreconnectable(match)); |
| 1131 } | 1131 } |
| 1132 // We could prefetch the alternate nav URL, if any, but because there | 1132 // We could prefetch the alternate nav URL, if any, but because there |
| 1133 // can be many of these as a user types an initial series of characters, | 1133 // can be many of these as a user types an initial series of characters, |
| 1134 // the OS DNS cache could suffer eviction problems for minimal gain. | 1134 // the OS DNS cache could suffer eviction problems for minimal gain. |
| 1135 } | 1135 } |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 // static | 1138 // static |
| 1139 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1139 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1140 switch (c) { | 1140 switch (c) { |
| 1141 case 0x0020: // Space | 1141 case 0x0020: // Space |
| 1142 case 0x3000: // Ideographic Space | 1142 case 0x3000: // Ideographic Space |
| 1143 return true; | 1143 return true; |
| 1144 default: | 1144 default: |
| 1145 return false; | 1145 return false; |
| 1146 } | 1146 } |
| 1147 } | 1147 } |
| OLD | NEW |