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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 if (prerender_manager) | 1028 if (prerender_manager) |
1029 prerender_manager->AddPrerenderFromOmnibox(match.destination_url); | 1029 prerender_manager->AddPrerenderFromOmnibox(match.destination_url); |
1030 } | 1030 } |
1031 } | 1031 } |
1032 | 1032 |
1033 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1033 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { |
1034 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1034 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
1035 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1035 // Warm up DNS Prefetch cache, or preconnect to a search service. |
1036 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1036 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
1037 AutocompleteMatch::NUM_TYPES); | 1037 AutocompleteMatch::NUM_TYPES); |
1038 chrome_browser_net::AnticipateOmniboxUrl(match.destination_url, | 1038 if (profile_->GetNetworkPredictor()) { |
1039 NetworkActionPredictor::IsPreconnectable(match)); | 1039 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 1040 match.destination_url, |
| 1041 NetworkActionPredictor::IsPreconnectable(match)); |
| 1042 } |
1040 // We could prefetch the alternate nav URL, if any, but because there | 1043 // We could prefetch the alternate nav URL, if any, but because there |
1041 // can be many of these as a user types an initial series of characters, | 1044 // can be many of these as a user types an initial series of characters, |
1042 // the OS DNS cache could suffer eviction problems for minimal gain. | 1045 // the OS DNS cache could suffer eviction problems for minimal gain. |
1043 } | 1046 } |
1044 } | 1047 } |
1045 | 1048 |
1046 // static | 1049 // static |
1047 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1050 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1048 switch (c) { | 1051 switch (c) { |
1049 case 0x0020: // Space | 1052 case 0x0020: // Space |
1050 case 0x3000: // Ideographic Space | 1053 case 0x3000: // Ideographic Space |
1051 return true; | 1054 return true; |
1052 default: | 1055 default: |
1053 return false; | 1056 return false; |
1054 } | 1057 } |
1055 } | 1058 } |
OLD | NEW |