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" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "chrome/browser/search_engines/template_url.h" | 31 #include "chrome/browser/search_engines/template_url.h" |
32 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 32 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
33 #include "chrome/browser/search_engines/template_url_service.h" | 33 #include "chrome/browser/search_engines/template_url_service.h" |
34 #include "chrome/browser/search_engines/template_url_service_factory.h" | 34 #include "chrome/browser/search_engines/template_url_service_factory.h" |
35 #include "chrome/browser/ui/browser_list.h" | 35 #include "chrome/browser/ui/browser_list.h" |
36 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 36 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
38 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
39 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
40 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
41 #include "content/browser/renderer_host/render_view_host.h" | |
41 #include "content/browser/user_metrics.h" | 42 #include "content/browser/user_metrics.h" |
42 #include "content/public/browser/notification_service.h" | 43 #include "content/public/browser/notification_service.h" |
43 #include "googleurl/src/gurl.h" | 44 #include "googleurl/src/gurl.h" |
44 #include "googleurl/src/url_util.h" | 45 #include "googleurl/src/url_util.h" |
45 #include "third_party/skia/include/core/SkBitmap.h" | 46 #include "third_party/skia/include/core/SkBitmap.h" |
46 | 47 |
47 /////////////////////////////////////////////////////////////////////////////// | 48 /////////////////////////////////////////////////////////////////////////////// |
48 // AutocompleteEditController | 49 // AutocompleteEditController |
49 | 50 |
50 AutocompleteEditController::~AutocompleteEditController() { | 51 AutocompleteEditController::~AutocompleteEditController() { |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1030 } | 1031 } |
1031 | 1032 |
1032 void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) { | 1033 void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) { |
1033 // Do not prerender if the destination URL is the same as the current URL. | 1034 // Do not prerender if the destination URL is the same as the current URL. |
1034 if (match.destination_url == PermanentURL()) | 1035 if (match.destination_url == PermanentURL()) |
1035 return; | 1036 return; |
1036 if (user_input_in_progress() && popup_->IsOpen()) { | 1037 if (user_input_in_progress() && popup_->IsOpen()) { |
1037 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1038 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
1038 prerender::PrerenderManager* prerender_manager = | 1039 prerender::PrerenderManager* prerender_manager = |
1039 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | 1040 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); |
1040 if (prerender_manager) | 1041 if (prerender_manager) { |
1041 prerender_manager->AddPrerenderFromOmnibox(match.destination_url); | 1042 RenderViewHost* current_host = tab->tab_contents()->render_view_host(); |
1043 if (current_host) { | |
Peter Kasting
2011/11/02 17:53:56
Can this actually be NULL (maybe for about:blank)?
cbentzel
2011/11/02 18:14:14
There's two periods during the TabContents constru
| |
1044 prerender_manager->AddPrerenderFromOmnibox( | |
1045 match.destination_url, current_host->session_storage_namespace()); | |
1046 } | |
1047 } | |
1042 } | 1048 } |
1043 } | 1049 } |
1044 | 1050 |
1045 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1051 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { |
1046 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { | 1052 if (!match.destination_url.SchemeIs(chrome::kExtensionScheme)) { |
1047 // Warm up DNS Prefetch cache, or preconnect to a search service. | 1053 // Warm up DNS Prefetch cache, or preconnect to a search service. |
1048 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, | 1054 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, |
1049 AutocompleteMatch::NUM_TYPES); | 1055 AutocompleteMatch::NUM_TYPES); |
1050 if (profile_->GetNetworkPredictor()) { | 1056 if (profile_->GetNetworkPredictor()) { |
1051 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( | 1057 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( |
1052 match.destination_url, | 1058 match.destination_url, |
1053 NetworkActionPredictor::IsPreconnectable(match)); | 1059 NetworkActionPredictor::IsPreconnectable(match)); |
1054 } | 1060 } |
1055 // We could prefetch the alternate nav URL, if any, but because there | 1061 // We could prefetch the alternate nav URL, if any, but because there |
1056 // can be many of these as a user types an initial series of characters, | 1062 // can be many of these as a user types an initial series of characters, |
1057 // the OS DNS cache could suffer eviction problems for minimal gain. | 1063 // the OS DNS cache could suffer eviction problems for minimal gain. |
1058 } | 1064 } |
1059 } | 1065 } |
1060 | 1066 |
1061 // static | 1067 // static |
1062 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1068 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1063 switch (c) { | 1069 switch (c) { |
1064 case 0x0020: // Space | 1070 case 0x0020: // Space |
1065 case 0x3000: // Ideographic Space | 1071 case 0x3000: // Ideographic Space |
1066 return true; | 1072 return true; |
1067 default: | 1073 default: |
1068 return false; | 1074 return false; |
1069 } | 1075 } |
1070 } | 1076 } |
OLD | NEW |