OLD | NEW |
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/options2/home_page_overlay_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/home_page_overlay_handler2.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 "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
10 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 10 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 void HomePageOverlayHandler::InitializeHandler() { | 33 void HomePageOverlayHandler::InitializeHandler() { |
34 Profile* profile = Profile::FromWebUI(web_ui()); | 34 Profile* profile = Profile::FromWebUI(web_ui()); |
35 autocomplete_controller_.reset(new AutocompleteController(profile, this)); | 35 autocomplete_controller_.reset(new AutocompleteController(profile, this)); |
36 } | 36 } |
37 | 37 |
38 void HomePageOverlayHandler::GetLocalizedValues( | 38 void HomePageOverlayHandler::GetLocalizedValues( |
39 base::DictionaryValue* localized_strings) { | 39 base::DictionaryValue* localized_strings) { |
40 RegisterTitle(localized_strings, "homePageOverlay", | 40 RegisterTitle(localized_strings, "homePageOverlay", |
41 IDS_OPTIONS2_HOMEPAGE_TITLE); | 41 IDS_OPTIONS2_HOMEPAGE_TITLE); |
42 localized_strings->SetString( | |
43 "homePageDialogLabel", | |
44 l10n_util::GetStringUTF16(IDS_OPTIONS2_HOMEPAGE_DIALOG_LABEL)); | |
45 } | 42 } |
46 | 43 |
47 void HomePageOverlayHandler::RequestAutocompleteSuggestions( | 44 void HomePageOverlayHandler::RequestAutocompleteSuggestions( |
48 const ListValue* args) { | 45 const ListValue* args) { |
49 string16 input; | 46 string16 input; |
50 CHECK_EQ(args->GetSize(), 1U); | 47 CHECK_EQ(args->GetSize(), 1U); |
51 CHECK(args->GetString(0, &input)); | 48 CHECK(args->GetString(0, &input)); |
52 | 49 |
53 autocomplete_controller_->Start(input, string16(), true, false, false, | 50 autocomplete_controller_->Start(input, string16(), true, false, false, |
54 AutocompleteInput::ALL_MATCHES); | 51 AutocompleteInput::ALL_MATCHES); |
55 } | 52 } |
56 | 53 |
57 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) { | 54 void HomePageOverlayHandler::OnResultChanged(bool default_match_changed) { |
58 const AutocompleteResult& result = autocomplete_controller_->result(); | 55 const AutocompleteResult& result = autocomplete_controller_->result(); |
59 base::ListValue suggestions; | 56 base::ListValue suggestions; |
60 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 57 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
61 web_ui()->CallJavascriptFunction( | 58 web_ui()->CallJavascriptFunction( |
62 "HomePageOverlay.updateAutocompleteSuggestions", suggestions); | 59 "HomePageOverlay.updateAutocompleteSuggestions", suggestions); |
63 } | 60 } |
64 | 61 |
65 } // namespace options2 | 62 } // namespace options2 |
OLD | NEW |