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

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

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comments Created 8 years, 3 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) 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_controller.h" 11 #include "chrome/browser/autocomplete/autocomplete_controller.h"
11 #include "chrome/browser/autocomplete/autocomplete_input.h" 12 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/autocomplete/autocomplete_result.h" 13 #include "chrome/browser/autocomplete/autocomplete_result.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/web_ui.h" 15 #include "content/public/browser/web_ui.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 18
18 namespace options { 19 namespace options {
19 20
20 HomePageOverlayHandler::HomePageOverlayHandler() { 21 HomePageOverlayHandler::HomePageOverlayHandler() {
21 } 22 }
22 23
23 HomePageOverlayHandler::~HomePageOverlayHandler() { 24 HomePageOverlayHandler::~HomePageOverlayHandler() {
24 } 25 }
25 26
26 void HomePageOverlayHandler::RegisterMessages() { 27 void HomePageOverlayHandler::RegisterMessages() {
27 web_ui()->RegisterMessageCallback( 28 web_ui()->RegisterMessageCallback(
28 "requestAutocompleteSuggestionsForHomePage", 29 "requestAutocompleteSuggestionsForHomePage",
29 base::Bind(&HomePageOverlayHandler::RequestAutocompleteSuggestions, 30 base::Bind(&HomePageOverlayHandler::RequestAutocompleteSuggestions,
30 base::Unretained(this))); 31 base::Unretained(this)));
31 } 32 }
32 33
33 void HomePageOverlayHandler::InitializeHandler() { 34 void HomePageOverlayHandler::InitializeHandler() {
34 Profile* profile = Profile::FromWebUI(web_ui()); 35 Profile* profile = Profile::FromWebUI(web_ui());
35 autocomplete_controller_.reset(new AutocompleteController(profile, this)); 36 autocomplete_controller_.reset(
37 new AutocompleteController(
38 profile,
39 this,
40 AutocompleteClassifier::kDefaultOmniboxProviders));
Peter Kasting 2012/09/07 23:23:02 This file and the other webui/options file probabl
Daniel Erat 2012/09/08 16:37:36 I chatted with tbreisacher@google.com about this y
36 } 41 }
37 42
38 void HomePageOverlayHandler::GetLocalizedValues( 43 void HomePageOverlayHandler::GetLocalizedValues(
39 base::DictionaryValue* localized_strings) { 44 base::DictionaryValue* localized_strings) {
40 RegisterTitle(localized_strings, "homePageOverlay", 45 RegisterTitle(localized_strings, "homePageOverlay",
41 IDS_OPTIONS_HOMEPAGE_TITLE); 46 IDS_OPTIONS_HOMEPAGE_TITLE);
42 } 47 }
43 48
44 void HomePageOverlayHandler::RequestAutocompleteSuggestions( 49 void HomePageOverlayHandler::RequestAutocompleteSuggestions(
45 const base::ListValue* args) { 50 const base::ListValue* args) {
46 string16 input; 51 string16 input;
47 CHECK_EQ(args->GetSize(), 1U); 52 CHECK_EQ(args->GetSize(), 1U);
48 CHECK(args->GetString(0, &input)); 53 CHECK(args->GetString(0, &input));
49 54
50 autocomplete_controller_->Start(input, string16(), true, false, false, 55 autocomplete_controller_->Start(input, string16(), true, false, false,
51 AutocompleteInput::ALL_MATCHES); 56 AutocompleteInput::ALL_MATCHES);
52 } 57 }
53 58
54 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) { 59 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) {
55 const AutocompleteResult& result = autocomplete_controller_->result(); 60 const AutocompleteResult& result = autocomplete_controller_->result();
56 base::ListValue suggestions; 61 base::ListValue suggestions;
57 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); 62 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
58 web_ui()->CallJavascriptFunction( 63 web_ui()->CallJavascriptFunction(
59 "HomePageOverlay.updateAutocompleteSuggestions", suggestions); 64 "HomePageOverlay.updateAutocompleteSuggestions", suggestions);
60 } 65 }
61 66
62 } // namespace options 67 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698