OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
16 #include "chrome/browser/autocomplete/autocomplete_match.h" | 16 #include "chrome/browser/autocomplete/autocomplete_match.h" |
17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
18 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 18 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
19 #include "chrome/browser/autocomplete/keyword_provider.h" | 19 #include "chrome/browser/autocomplete/keyword_provider.h" |
20 #include "chrome/browser/autocomplete/search_provider.h" | 20 #include "chrome/browser/autocomplete/search_provider.h" |
21 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
22 #include "chrome/browser/extensions/extension_omnibox_api.h" | 22 #include "chrome/browser/extensions/extension_omnibox_api.h" |
23 #include "chrome/browser/google/google_url_tracker.h" | 23 #include "chrome/browser/google/google_url_tracker.h" |
24 #include "chrome/browser/instant/instant_controller.h" | 24 #include "chrome/browser/instant/instant_controller.h" |
25 #include "chrome/browser/net/predictor_api.h" | 25 #include "chrome/browser/net/predictor.h" |
26 #include "chrome/browser/net/url_fixer_upper.h" | 26 #include "chrome/browser/net/url_fixer_upper.h" |
27 #include "chrome/browser/prerender/prerender_manager.h" | 27 #include "chrome/browser/prerender/prerender_manager.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/search_engines/template_url.h" | 29 #include "chrome/browser/search_engines/template_url.h" |
30 #include "chrome/browser/search_engines/template_url_service.h" | 30 #include "chrome/browser/search_engines/template_url_service.h" |
31 #include "chrome/browser/search_engines/template_url_service_factory.h" | 31 #include "chrome/browser/search_engines/template_url_service_factory.h" |
32 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 33 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
34 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 34 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
35 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1076 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
1077 prerender::PrerenderManager* prerender_manager = | 1077 prerender::PrerenderManager* prerender_manager = |
1078 tab->profile()->GetPrerenderManager(); | 1078 tab->profile()->GetPrerenderManager(); |
1079 if (prerender_manager) | 1079 if (prerender_manager) |
1080 prerender_manager->AddPrerenderFromOmnibox(match.destination_url); | 1080 prerender_manager->AddPrerenderFromOmnibox(match.destination_url); |
1081 } | 1081 } |
1082 | 1082 |
1083 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1083 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { |
1084 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1084 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
1085 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1085 // Warm up DNS Prefetch cache, or preconnect to a search service. |
1086 chrome_browser_net::AnticipateOmniboxUrl(match.destination_url, | 1086 if (profile_->GetNetworkPredictor()) { |
1087 IsPreconnectable(match.type)); | 1087 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 1088 match.destination_url, |
| 1089 IsPreconnectable(match.type)); |
| 1090 } |
1088 // We could prefetch the alternate nav URL, if any, but because there | 1091 // We could prefetch the alternate nav URL, if any, but because there |
1089 // can be many of these as a user types an initial series of characters, | 1092 // can be many of these as a user types an initial series of characters, |
1090 // the OS DNS cache could suffer eviction problems for minimal gain. | 1093 // the OS DNS cache could suffer eviction problems for minimal gain. |
1091 } | 1094 } |
1092 } | 1095 } |
1093 | 1096 |
1094 // static | 1097 // static |
1095 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1098 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1096 switch (c) { | 1099 switch (c) { |
1097 case 0x0020: // Space | 1100 case 0x0020: // Space |
1098 case 0x3000: // Ideographic Space | 1101 case 0x3000: // Ideographic Space |
1099 return true; | 1102 return true; |
1100 default: | 1103 default: |
1101 return false; | 1104 return false; |
1102 } | 1105 } |
1103 } | 1106 } |
OLD | NEW |