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

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

Issue 10837331: Options: s/options2/options/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wut Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/options2/home_page_overlay_handler.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/values.h"
10 #include "chrome/browser/autocomplete/autocomplete_controller.h"
11 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/autocomplete/autocomplete_result.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/web_ui.h"
15 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h"
17
18 namespace options {
19
20 HomePageOverlayHandler::HomePageOverlayHandler() {
21 }
22
23 HomePageOverlayHandler::~HomePageOverlayHandler() {
24 }
25
26 void HomePageOverlayHandler::RegisterMessages() {
27 web_ui()->RegisterMessageCallback(
28 "requestAutocompleteSuggestionsForHomePage",
29 base::Bind(&HomePageOverlayHandler::RequestAutocompleteSuggestions,
30 base::Unretained(this)));
31 }
32
33 void HomePageOverlayHandler::InitializeHandler() {
34 Profile* profile = Profile::FromWebUI(web_ui());
35 autocomplete_controller_.reset(new AutocompleteController(profile, this));
36 }
37
38 void HomePageOverlayHandler::GetLocalizedValues(
39 base::DictionaryValue* localized_strings) {
40 RegisterTitle(localized_strings, "homePageOverlay",
41 IDS_OPTIONS2_HOMEPAGE_TITLE);
42 }
43
44 void HomePageOverlayHandler::RequestAutocompleteSuggestions(
45 const base::ListValue* args) {
46 string16 input;
47 CHECK_EQ(args->GetSize(), 1U);
48 CHECK(args->GetString(0, &input));
49
50 autocomplete_controller_->Start(input, string16(), true, false, false,
51 AutocompleteInput::ALL_MATCHES);
52 }
53
54 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) {
55 const AutocompleteResult& result = autocomplete_controller_->result();
56 base::ListValue suggestions;
57 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
58 web_ui()->CallJavascriptFunction(
59 "HomePageOverlay.updateAutocompleteSuggestions", suggestions);
60 }
61
62 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/home_page_overlay_handler.h ('k') | chrome/browser/ui/webui/options2/import_data_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698