Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / home_page_overlay_handler.cc
blob4496648f6a374c1869a0bcad8bec5bb623812c28
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.
5 #include "chrome/browser/ui/webui/options/home_page_overlay_handler.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/values.h"
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
11 #include "chrome/browser/autocomplete/autocomplete_controller.h"
12 #include "chrome/browser/autocomplete/autocomplete_input.h"
13 #include "chrome/browser/autocomplete/autocomplete_result.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/web_ui.h"
16 #include "grit/generated_resources.h"
17 #include "ui/base/l10n/l10n_util.h"
19 namespace options {
21 HomePageOverlayHandler::HomePageOverlayHandler() {
24 HomePageOverlayHandler::~HomePageOverlayHandler() {
27 void HomePageOverlayHandler::RegisterMessages() {
28 web_ui()->RegisterMessageCallback(
29 "requestAutocompleteSuggestionsForHomePage",
30 base::Bind(&HomePageOverlayHandler::RequestAutocompleteSuggestions,
31 base::Unretained(this)));
34 void HomePageOverlayHandler::InitializeHandler() {
35 Profile* profile = Profile::FromWebUI(web_ui());
36 autocomplete_controller_.reset(new AutocompleteController(profile, this,
37 AutocompleteClassifier::kDefaultOmniboxProviders));
40 void HomePageOverlayHandler::GetLocalizedValues(
41 base::DictionaryValue* localized_strings) {
42 RegisterTitle(localized_strings, "homePageOverlay",
43 IDS_OPTIONS_HOMEPAGE_TITLE);
46 void HomePageOverlayHandler::RequestAutocompleteSuggestions(
47 const base::ListValue* args) {
48 base::string16 input;
49 CHECK_EQ(args->GetSize(), 1U);
50 CHECK(args->GetString(0, &input));
52 autocomplete_controller_->Start(AutocompleteInput(
53 input, base::string16::npos, base::string16(), GURL(),
54 AutocompleteInput::INVALID_SPEC, true,
55 false, false, AutocompleteInput::ALL_MATCHES));
58 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) {
59 const AutocompleteResult& result = autocomplete_controller_->result();
60 base::ListValue suggestions;
61 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
62 web_ui()->CallJavascriptFunction(
63 "HomePageOverlay.updateAutocompleteSuggestions", suggestions);
66 } // namespace options