Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 7210020: Added prerendering to omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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()) {
sky 2011/06/20 19:29:24 Combine your ifs. Also, I believe you only want to
dominich 2011/06/20 20:48:40 Done.
236 if (user_input_in_progress() && popup_->IsOpen()) {
237 // Start Prerender of this page instead.
238 CommandLine* cl = CommandLine::ForCurrentProcess();
239 if (cl->HasSwitch(switches::kPrerenderFromOmnibox)) {
240 prerender::PrerenderManager* prerender_manager =
241 tab->tab_contents()->profile()->GetPrerenderManager();
242 if (prerender_manager) {
243 prerender_manager->AddPrerenderWithNoTag(
244 CurrentMatch().destination_url);
245 }
246 }
247 }
232 } 248 }
233 249
234 if (!might_support_instant) { 250 if (!might_support_instant) {
235 // Hide any suggestions we might be showing. 251 // Hide any suggestions we might be showing.
236 view_->SetInstantSuggestion(string16(), false); 252 view_->SetInstantSuggestion(string16(), false);
237 253
238 // No need to wait any longer for instant. 254 // No need to wait any longer for instant.
239 FinalizeInstantQuery(string16(), string16(), false); 255 FinalizeInstantQuery(string16(), string16(), false);
240 } else { 256 } else {
241 SetSuggestedText(suggested_text, instant_complete_behavior_); 257 SetSuggestedText(suggested_text, instant_complete_behavior_);
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 // static 1029 // static
1014 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { 1030 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
1015 switch (c) { 1031 switch (c) {
1016 case 0x0020: // Space 1032 case 0x0020: // Space
1017 case 0x3000: // Ideographic Space 1033 case 0x3000: // Ideographic Space
1018 return true; 1034 return true;
1019 default: 1035 default:
1020 return false; 1036 return false;
1021 } 1037 }
1022 } 1038 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698