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

Side by Side Diff: chrome/browser/ui/webui/options/home_page_overlay_handler.cc

Issue 1192373002: Prepare AutocompleteController for componentization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@componentize_zero_suggest_provider
Patch Set: Remove stale include Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/webui/options/home_page_overlay_handler.h" 5 #include "chrome/browser/ui/webui/options/home_page_overlay_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
11 #include "chrome/browser/autocomplete/autocomplete_controller.h" 11 #include "chrome/browser/autocomplete/autocomplete_controller.h"
12 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
12 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 13 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
16 #include "components/metrics/proto/omnibox_event.pb.h" 17 #include "components/metrics/proto/omnibox_event.pb.h"
17 #include "components/omnibox/autocomplete_input.h" 18 #include "components/omnibox/autocomplete_input.h"
18 #include "components/omnibox/autocomplete_result.h" 19 #include "components/omnibox/autocomplete_result.h"
19 #include "content/public/browser/web_ui.h" 20 #include "content/public/browser/web_ui.h"
20 21
21 namespace options { 22 namespace options {
22 23
23 HomePageOverlayHandler::HomePageOverlayHandler() { 24 HomePageOverlayHandler::HomePageOverlayHandler() {
24 } 25 }
25 26
26 HomePageOverlayHandler::~HomePageOverlayHandler() { 27 HomePageOverlayHandler::~HomePageOverlayHandler() {
27 } 28 }
28 29
29 void HomePageOverlayHandler::RegisterMessages() { 30 void HomePageOverlayHandler::RegisterMessages() {
30 web_ui()->RegisterMessageCallback( 31 web_ui()->RegisterMessageCallback(
31 "requestAutocompleteSuggestionsForHomePage", 32 "requestAutocompleteSuggestionsForHomePage",
32 base::Bind(&HomePageOverlayHandler::RequestAutocompleteSuggestions, 33 base::Bind(&HomePageOverlayHandler::RequestAutocompleteSuggestions,
33 base::Unretained(this))); 34 base::Unretained(this)));
34 } 35 }
35 36
36 void HomePageOverlayHandler::InitializeHandler() { 37 void HomePageOverlayHandler::InitializeHandler() {
37 Profile* profile = Profile::FromWebUI(web_ui()); 38 Profile* profile = Profile::FromWebUI(web_ui());
38 autocomplete_controller_.reset(new AutocompleteController(profile, 39 autocomplete_controller_.reset(new AutocompleteController(
39 TemplateURLServiceFactory::GetForProfile(profile), this, 40 make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)), this,
40 AutocompleteClassifier::kDefaultOmniboxProviders)); 41 AutocompleteClassifier::kDefaultOmniboxProviders));
41 } 42 }
42 43
43 void HomePageOverlayHandler::GetLocalizedValues( 44 void HomePageOverlayHandler::GetLocalizedValues(
44 base::DictionaryValue* localized_strings) { 45 base::DictionaryValue* localized_strings) {
45 RegisterTitle(localized_strings, "homePageOverlay", 46 RegisterTitle(localized_strings, "homePageOverlay",
46 IDS_OPTIONS_HOMEPAGE_TITLE); 47 IDS_OPTIONS_HOMEPAGE_TITLE);
47 } 48 }
48 49
49 void HomePageOverlayHandler::RequestAutocompleteSuggestions( 50 void HomePageOverlayHandler::RequestAutocompleteSuggestions(
(...skipping 10 matching lines...) Expand all
60 61
61 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) { 62 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) {
62 const AutocompleteResult& result = autocomplete_controller_->result(); 63 const AutocompleteResult& result = autocomplete_controller_->result();
63 base::ListValue suggestions; 64 base::ListValue suggestions;
64 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); 65 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
65 web_ui()->CallJavascriptFunction( 66 web_ui()->CallJavascriptFunction(
66 "HomePageOverlay.updateAutocompleteSuggestions", suggestions); 67 "HomePageOverlay.updateAutocompleteSuggestions", suggestions);
67 } 68 }
68 69
69 } // namespace options 70 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698