| 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 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 // instance if the tab has been closed or on return from a sleep state | 1074 // instance if the tab has been closed or on return from a sleep state |
| 1075 // (http://crbug.com/105689) | 1075 // (http://crbug.com/105689) |
| 1076 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1076 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
| 1077 if (!tab) | 1077 if (!tab) |
| 1078 return; | 1078 return; |
| 1079 prerender::PrerenderManager* prerender_manager = | 1079 prerender::PrerenderManager* prerender_manager = |
| 1080 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | 1080 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); |
| 1081 if (prerender_manager) { | 1081 if (prerender_manager) { |
| 1082 RenderViewHost* current_host = tab->web_contents()->GetRenderViewHost(); | 1082 RenderViewHost* current_host = tab->web_contents()->GetRenderViewHost(); |
| 1083 prerender_manager->AddPrerenderFromOmnibox( | 1083 prerender_manager->AddPrerenderFromOmnibox( |
| 1084 match.destination_url, current_host->session_storage_namespace()); | 1084 match.destination_url, current_host->GetSessionStorageNamespace()); |
| 1085 } | 1085 } |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1088 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { |
| 1089 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1089 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
| 1090 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1090 // Warm up DNS Prefetch cache, or preconnect to a search service. |
| 1091 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1091 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
| 1092 AutocompleteMatch::NUM_TYPES); | 1092 AutocompleteMatch::NUM_TYPES); |
| 1093 if (profile_->GetNetworkPredictor()) { | 1093 if (profile_->GetNetworkPredictor()) { |
| 1094 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1094 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 1095 match.destination_url, | 1095 match.destination_url, |
| 1096 NetworkActionPredictor::IsPreconnectable(match)); | 1096 NetworkActionPredictor::IsPreconnectable(match)); |
| 1097 } | 1097 } |
| 1098 // We could prefetch the alternate nav URL, if any, but because there | 1098 // We could prefetch the alternate nav URL, if any, but because there |
| 1099 // can be many of these as a user types an initial series of characters, | 1099 // can be many of these as a user types an initial series of characters, |
| 1100 // the OS DNS cache could suffer eviction problems for minimal gain. | 1100 // the OS DNS cache could suffer eviction problems for minimal gain. |
| 1101 } | 1101 } |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 // static | 1104 // static |
| 1105 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1105 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1106 switch (c) { | 1106 switch (c) { |
| 1107 case 0x0020: // Space | 1107 case 0x0020: // Space |
| 1108 case 0x3000: // Ideographic Space | 1108 case 0x3000: // Ideographic Space |
| 1109 return true; | 1109 return true; |
| 1110 default: | 1110 default: |
| 1111 return false; | 1111 return false; |
| 1112 } | 1112 } |
| 1113 } | 1113 } |
| OLD | NEW |