Chromium Code Reviews| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 16 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 18 #include "chrome/browser/autocomplete/keyword_provider.h" | 18 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 19 #include "chrome/browser/autocomplete/search_provider.h" | 19 #include "chrome/browser/autocomplete/search_provider.h" |
| 20 #include "chrome/browser/command_updater.h" | 20 #include "chrome/browser/command_updater.h" |
| 21 #include "chrome/browser/extensions/extension_omnibox_api.h" | 21 #include "chrome/browser/extensions/extension_omnibox_api.h" |
| 22 #include "chrome/browser/google/google_url_tracker.h" | 22 #include "chrome/browser/google/google_url_tracker.h" |
| 23 #include "chrome/browser/instant/instant_controller.h" | 23 #include "chrome/browser/instant/instant_controller.h" |
| 24 #include "chrome/browser/net/predictor_api.h" | 24 #include "chrome/browser/net/predictor.h" |
| 25 #include "chrome/browser/net/url_fixer_upper.h" | 25 #include "chrome/browser/net/url_fixer_upper.h" |
| 26 #include "chrome/browser/prerender/prerender_manager.h" | 26 #include "chrome/browser/prerender/prerender_manager.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
| 29 #include "chrome/browser/search_engines/template_url_service.h" | 29 #include "chrome/browser/search_engines/template_url_service.h" |
| 30 #include "chrome/browser/search_engines/template_url_service_factory.h" | 30 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
| 32 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 32 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 34 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 if (match != result.end()) { | 846 if (match != result.end()) { |
| 847 if ((match->inline_autocomplete_offset != string16::npos) && | 847 if ((match->inline_autocomplete_offset != string16::npos) && |
| 848 (match->inline_autocomplete_offset < | 848 (match->inline_autocomplete_offset < |
| 849 match->fill_into_edit.length())) { | 849 match->fill_into_edit.length())) { |
| 850 inline_autocomplete_text = | 850 inline_autocomplete_text = |
| 851 match->fill_into_edit.substr(match->inline_autocomplete_offset); | 851 match->fill_into_edit.substr(match->inline_autocomplete_offset); |
| 852 } | 852 } |
| 853 | 853 |
| 854 if (!match->destination_url.SchemeIs(chrome::kExtensionScheme)) { | 854 if (!match->destination_url.SchemeIs(chrome::kExtensionScheme)) { |
| 855 // Warm up DNS Prefetch cache, or preconnect to a search service. | 855 // Warm up DNS Prefetch cache, or preconnect to a search service. |
| 856 chrome_browser_net::AnticipateOmniboxUrl(match->destination_url, | 856 if (profile_->GetNetworkPredictor()) |
|
willchan no longer on Chromium
2011/08/12 21:51:47
Nit: please use braces for multiline if statements
rpetterson
2011/08/13 00:55:17
Done.
| |
| 857 IsPreconnectable(match->type)); | 857 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 858 match->destination_url, | |
| 859 IsPreconnectable(match->type)); | |
| 858 } | 860 } |
| 859 | 861 |
| 860 // We could prefetch the alternate nav URL, if any, but because there | 862 // We could prefetch the alternate nav URL, if any, but because there |
| 861 // can be many of these as a user types an initial series of characters, | 863 // can be many of these as a user types an initial series of characters, |
| 862 // the OS DNS cache could suffer eviction problems for minimal gain. | 864 // the OS DNS cache could suffer eviction problems for minimal gain. |
| 863 | 865 |
| 864 is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword); | 866 is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword); |
| 865 } | 867 } |
| 866 popup_->OnResultChanged(); | 868 popup_->OnResultChanged(); |
| 867 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, | 869 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 // static | 1014 // static |
| 1013 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1015 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1014 switch (c) { | 1016 switch (c) { |
| 1015 case 0x0020: // Space | 1017 case 0x0020: // Space |
| 1016 case 0x3000: // Ideographic Space | 1018 case 0x3000: // Ideographic Space |
| 1017 return true; | 1019 return true; |
| 1018 default: | 1020 default: |
| 1019 return false; | 1021 return false; |
| 1020 } | 1022 } |
| 1021 } | 1023 } |
| OLD | NEW |