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/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 16 #include "chrome/browser/autocomplete/autocomplete_match.h" |
16 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
17 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 18 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
18 #include "chrome/browser/autocomplete/keyword_provider.h" | 19 #include "chrome/browser/autocomplete/keyword_provider.h" |
19 #include "chrome/browser/autocomplete/search_provider.h" | 20 #include "chrome/browser/autocomplete/search_provider.h" |
20 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
21 #include "chrome/browser/extensions/extension_omnibox_api.h" | 22 #include "chrome/browser/extensions/extension_omnibox_api.h" |
22 #include "chrome/browser/google/google_url_tracker.h" | 23 #include "chrome/browser/google/google_url_tracker.h" |
23 #include "chrome/browser/instant/instant_controller.h" | 24 #include "chrome/browser/instant/instant_controller.h" |
24 #include "chrome/browser/net/predictor_api.h" | 25 #include "chrome/browser/net/predictor_api.h" |
25 #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" | |
26 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/search_engines/template_url.h" | 29 #include "chrome/browser/search_engines/template_url.h" |
28 #include "chrome/browser/search_engines/template_url_service.h" | 30 #include "chrome/browser/search_engines/template_url_service.h" |
29 #include "chrome/browser/search_engines/template_url_service_factory.h" | 31 #include "chrome/browser/search_engines/template_url_service_factory.h" |
30 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
31 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 33 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
32 #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_switches.h" | |
33 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
34 #include "content/browser/user_metrics.h" | 37 #include "content/browser/user_metrics.h" |
35 #include "content/common/notification_service.h" | 38 #include "content/common/notification_service.h" |
36 #include "googleurl/src/gurl.h" | 39 #include "googleurl/src/gurl.h" |
37 #include "googleurl/src/url_util.h" | 40 #include "googleurl/src/url_util.h" |
38 #include "third_party/skia/include/core/SkBitmap.h" | 41 #include "third_party/skia/include/core/SkBitmap.h" |
39 | 42 |
40 /////////////////////////////////////////////////////////////////////////////// | 43 /////////////////////////////////////////////////////////////////////////////// |
41 // AutocompleteEditController | 44 // AutocompleteEditController |
42 | 45 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 bool might_support_instant = false; | 218 bool might_support_instant = false; |
216 if (update_instant_ && instant && tab) { | 219 if (update_instant_ && instant && tab) { |
217 if (user_input_in_progress() && popup_->IsOpen()) { | 220 if (user_input_in_progress() && popup_->IsOpen()) { |
218 AutocompleteMatch current_match = CurrentMatch(); | 221 AutocompleteMatch current_match = CurrentMatch(); |
219 if (current_match.destination_url == PermanentURL()) { | 222 if (current_match.destination_url == PermanentURL()) { |
220 // The destination is the same as the current url. This typically | 223 // The destination is the same as the current url. This typically |
221 // happens if the user presses the down error in the omnibox, in which | 224 // happens if the user presses the down error in the omnibox, in which |
222 // case we don't want to load a preview. | 225 // case we don't want to load a preview. |
223 instant->DestroyPreviewContentsAndLeaveActive(); | 226 instant->DestroyPreviewContentsAndLeaveActive(); |
224 } else { | 227 } else { |
225 instant->Update(tab, CurrentMatch(), view_->GetText(), | 228 instant->Update(tab, current_match, view_->GetText(), |
226 UseVerbatimInstant(), &suggested_text); | 229 UseVerbatimInstant(), &suggested_text); |
227 } | 230 } |
228 } else { | 231 } else { |
229 instant->DestroyPreviewContents(); | 232 instant->DestroyPreviewContents(); |
230 } | 233 } |
231 might_support_instant = instant->MightSupportInstant(); | 234 might_support_instant = instant->MightSupportInstant(); |
235 } else if (tab && tab->tab_contents()) { | |
236 // Start Prerender of this page instead. | |
237 CommandLine* cl = CommandLine::ForCurrentProcess(); | |
238 if (cl->HasSwitch(switches::kPrerenderFromOmnibox)) { | |
239 prerender::PrerenderManager* prerender_manager = | |
240 tab->tab_contents()->profile()->GetPrerenderManager(); | |
241 if (prerender_manager) { | |
242 prerender_manager->AddPrerenderWithNoTag( | |
sky
2011/06/20 18:15:54
Is this cumulative? Meaning might I end up preload
cbentzel
2011/06/20 18:28:59
There is throttling in the PrerenderManager code -
dominich
2011/06/20 18:40:00
There is a rate limiter that will kick in that onl
| |
243 CurrentMatch().destination_url); | |
cbentzel
2011/06/20 18:06:01
What is the likelihood that users will choose Curr
dominich
2011/06/20 18:40:00
It doesn't look like we have any statistics on how
| |
244 } | |
245 } | |
232 } | 246 } |
233 | 247 |
234 if (!might_support_instant) { | 248 if (!might_support_instant) { |
235 // Hide any suggestions we might be showing. | 249 // Hide any suggestions we might be showing. |
236 view_->SetInstantSuggestion(string16(), false); | 250 view_->SetInstantSuggestion(string16(), false); |
237 | 251 |
238 // No need to wait any longer for instant. | 252 // No need to wait any longer for instant. |
239 FinalizeInstantQuery(string16(), string16(), false); | 253 FinalizeInstantQuery(string16(), string16(), false); |
240 } else { | 254 } else { |
241 SetSuggestedText(suggested_text, instant_complete_behavior_); | 255 SetSuggestedText(suggested_text, instant_complete_behavior_); |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 // static | 1027 // static |
1014 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1028 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1015 switch (c) { | 1029 switch (c) { |
1016 case 0x0020: // Space | 1030 case 0x0020: // Space |
1017 case 0x3000: // Ideographic Space | 1031 case 0x3000: // Ideographic Space |
1018 return true; | 1032 return true; |
1019 default: | 1033 default: |
1020 return false; | 1034 return false; |
1021 } | 1035 } |
1022 } | 1036 } |
OLD | NEW |