| 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 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 if (match != result.end()) { | 844 if (match != result.end()) { |
| 845 if ((match->inline_autocomplete_offset != string16::npos) && | 845 if ((match->inline_autocomplete_offset != string16::npos) && |
| 846 (match->inline_autocomplete_offset < | 846 (match->inline_autocomplete_offset < |
| 847 match->fill_into_edit.length())) { | 847 match->fill_into_edit.length())) { |
| 848 inline_autocomplete_text = | 848 inline_autocomplete_text = |
| 849 match->fill_into_edit.substr(match->inline_autocomplete_offset); | 849 match->fill_into_edit.substr(match->inline_autocomplete_offset); |
| 850 } | 850 } |
| 851 | 851 |
| 852 if (!match->destination_url.SchemeIs(chrome::kExtensionScheme)) { | 852 if (!match->destination_url.SchemeIs(chrome::kExtensionScheme)) { |
| 853 // Warm up DNS Prefetch cache, or preconnect to a search service. | 853 // Warm up DNS Prefetch cache, or preconnect to a search service. |
| 854 chrome_browser_net::AnticipateOmniboxUrl(match->destination_url, | 854 if (profile_->GetNetworkPredictor()) |
| 855 IsPreconnectable(match->type)); | 855 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
| 856 match->destination_url, |
| 857 IsPreconnectable(match->type)); |
| 856 } | 858 } |
| 857 | 859 |
| 858 // We could prefetch the alternate nav URL, if any, but because there | 860 // We could prefetch the alternate nav URL, if any, but because there |
| 859 // can be many of these as a user types an initial series of characters, | 861 // can be many of these as a user types an initial series of characters, |
| 860 // the OS DNS cache could suffer eviction problems for minimal gain. | 862 // the OS DNS cache could suffer eviction problems for minimal gain. |
| 861 | 863 |
| 862 is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword); | 864 is_keyword_hint = popup_->GetKeywordForMatch(*match, &keyword); |
| 863 } | 865 } |
| 864 popup_->OnResultChanged(); | 866 popup_->OnResultChanged(); |
| 865 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, | 867 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 // static | 1012 // static |
| 1011 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1013 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1012 switch (c) { | 1014 switch (c) { |
| 1013 case 0x0020: // Space | 1015 case 0x0020: // Space |
| 1014 case 0x3000: // Ideographic Space | 1016 case 0x3000: // Ideographic Space |
| 1015 return true; | 1017 return true; |
| 1016 default: | 1018 default: |
| 1017 return false; | 1019 return false; |
| 1018 } | 1020 } |
| 1019 } | 1021 } |
| OLD | NEW |