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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_controller.cc

Issue 17022004: Replace --google-base-suggest-url and --instant-url with --google-base-url. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/omnibox/omnibox_controller.h" 5 #include "chrome/browser/ui/omnibox/omnibox_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 8 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
9 #include "chrome/browser/autocomplete/autocomplete_match.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "chrome/browser/autocomplete/search_provider.h" 10 #include "chrome/browser/autocomplete/search_provider.h"
11 #include "chrome/browser/net/predictor.h" 11 #include "chrome/browser/net/predictor.h"
12 #include "chrome/browser/predictors/autocomplete_action_predictor.h" 12 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
13 #include "chrome/browser/prerender/prerender_field_trial.h" 13 #include "chrome/browser/prerender/prerender_field_trial.h"
14 #include "chrome/browser/prerender/prerender_manager.h" 14 #include "chrome/browser/prerender/prerender_manager.h"
15 #include "chrome/browser/prerender/prerender_manager_factory.h" 15 #include "chrome/browser/prerender/prerender_manager_factory.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/search/search.h" 17 #include "chrome/browser/search/search.h"
18 #include "chrome/browser/search_engines/template_url_service.h" 18 #include "chrome/browser/search_engines/template_url_service.h"
19 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
20 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 20 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
21 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 21 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
23 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" 23 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
24 #include "chrome/browser/ui/search/instant_controller.h" 24 #include "chrome/browser/ui/search/instant_controller.h"
25 #include "extensions/common/constants.h" 25 #include "extensions/common/constants.h"
26 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
27 27
28 using predictors::AutocompleteActionPredictor;
29
30 namespace {
31
32 string16 GetDefaultSearchProviderKeyword(Profile* profile) {
33 TemplateURLService* template_url_service =
34 TemplateURLServiceFactory::GetForProfile(profile);
35 if (template_url_service) {
36 TemplateURL* template_url =
37 template_url_service->GetDefaultSearchProvider();
38 if (template_url)
39 return template_url->keyword();
40 }
41 return string16();
42 }
43
44 } // namespace
45 28
46 OmniboxController::OmniboxController(OmniboxEditModel* omnibox_edit_model, 29 OmniboxController::OmniboxController(OmniboxEditModel* omnibox_edit_model,
47 Profile* profile) 30 Profile* profile)
48 : omnibox_edit_model_(omnibox_edit_model), 31 : omnibox_edit_model_(omnibox_edit_model),
49 profile_(profile) { 32 profile_(profile) {
50 autocomplete_controller_.reset(new AutocompleteController(profile, this, 33 autocomplete_controller_.reset(new AutocompleteController(profile, this,
51 chrome::IsInstantExtendedAPIEnabled() ? 34 chrome::IsInstantExtendedAPIEnabled() ?
52 AutocompleteClassifier::kInstantExtendedOmniboxProviders : 35 AutocompleteClassifier::kInstantExtendedOmniboxProviders :
53 AutocompleteClassifier::kDefaultOmniboxProviders)); 36 AutocompleteClassifier::kDefaultOmniboxProviders));
54 } 37 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 244 }
262 245
263 void OmniboxController::DoPreconnect(const AutocompleteMatch& match) { 246 void OmniboxController::DoPreconnect(const AutocompleteMatch& match) {
264 if (!match.destination_url.SchemeIs(extensions::kExtensionScheme)) { 247 if (!match.destination_url.SchemeIs(extensions::kExtensionScheme)) {
265 // Warm up DNS Prefetch cache, or preconnect to a search service. 248 // Warm up DNS Prefetch cache, or preconnect to a search service.
266 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type, 249 UMA_HISTOGRAM_ENUMERATION("Autocomplete.MatchType", match.type,
267 AutocompleteMatchType::NUM_TYPES); 250 AutocompleteMatchType::NUM_TYPES);
268 if (profile_->GetNetworkPredictor()) { 251 if (profile_->GetNetworkPredictor()) {
269 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( 252 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl(
270 match.destination_url, 253 match.destination_url,
271 AutocompleteActionPredictor::IsPreconnectable(match)); 254 predictors::AutocompleteActionPredictor::IsPreconnectable(match));
272 } 255 }
273 // We could prefetch the alternate nav URL, if any, but because there 256 // We could prefetch the alternate nav URL, if any, but because there
274 // can be many of these as a user types an initial series of characters, 257 // can be many of these as a user types an initial series of characters,
275 // the OS DNS cache could suffer eviction problems for minimal gain. 258 // the OS DNS cache could suffer eviction problems for minimal gain.
276 } 259 }
277 } 260 }
278 261
279 void OmniboxController::OnPopupBoundsChanged(const gfx::Rect& bounds) { 262 void OmniboxController::OnPopupBoundsChanged(const gfx::Rect& bounds) {
280 InstantController* instant_controller = GetInstantController(); 263 InstantController* instant_controller = GetInstantController();
281 if (instant_controller) 264 if (instant_controller)
(...skipping 21 matching lines...) Expand all
303 } 286 }
304 287
305 InstantController* OmniboxController::GetInstantController() const { 288 InstantController* OmniboxController::GetInstantController() const {
306 return omnibox_edit_model_->GetInstantController(); 289 return omnibox_edit_model_->GetInstantController();
307 } 290 }
308 291
309 void OmniboxController::CreateAndSetInstantMatch( 292 void OmniboxController::CreateAndSetInstantMatch(
310 string16 query_string, 293 string16 query_string,
311 string16 input_text, 294 string16 input_text,
312 AutocompleteMatchType::Type match_type) { 295 AutocompleteMatchType::Type match_type) {
313 string16 keyword = GetDefaultSearchProviderKeyword(profile_); 296 TemplateURLService* template_url_service =
314 if (keyword.empty()) 297 TemplateURLServiceFactory::GetForProfile(profile_);
315 return; // CreateSearchSuggestion needs a keyword. 298 if (!template_url_service)
299 return;
300
301 TemplateURL* template_url =
302 template_url_service->GetDefaultSearchProvider();
303 if (!template_url)
304 return;
316 305
317 current_match_ = SearchProvider::CreateSearchSuggestion( 306 current_match_ = SearchProvider::CreateSearchSuggestion(
318 profile_, NULL, AutocompleteInput(), query_string, input_text, 0, 307 NULL, 0, match_type, template_url, query_string, input_text,
319 match_type, 0, false, keyword, -1); 308 AutocompleteInput(), false, 0, -1, true);
320 } 309 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698