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/options/startup_pages_handler.h" | 5 #include "chrome/browser/ui/webui/options/startup_pages_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 14 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/custom_home_pages_table_model.h" | 17 #include "chrome/browser/custom_home_pages_table_model.h" |
17 #include "chrome/browser/prefs/session_startup_pref.h" | 18 #include "chrome/browser/prefs/session_startup_pref.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 20 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/browser/ui/webui/settings_utils.h" | 21 #include "chrome/browser/ui/webui/settings_utils.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 new CustomHomePagesTableModel(profile)); | 101 new CustomHomePagesTableModel(profile)); |
101 startup_custom_pages_table_model_->SetObserver(this); | 102 startup_custom_pages_table_model_->SetObserver(this); |
102 | 103 |
103 pref_change_registrar_.Init(profile->GetPrefs()); | 104 pref_change_registrar_.Init(profile->GetPrefs()); |
104 pref_change_registrar_.Add( | 105 pref_change_registrar_.Add( |
105 prefs::kURLsToRestoreOnStartup, | 106 prefs::kURLsToRestoreOnStartup, |
106 base::Bind(&StartupPagesHandler::UpdateStartupPages, | 107 base::Bind(&StartupPagesHandler::UpdateStartupPages, |
107 base::Unretained(this))); | 108 base::Unretained(this))); |
108 | 109 |
109 autocomplete_controller_.reset(new AutocompleteController( | 110 autocomplete_controller_.reset(new AutocompleteController( |
110 make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)), this, | 111 base::WrapUnique(new ChromeAutocompleteProviderClient(profile)), this, |
111 AutocompleteClassifier::kDefaultOmniboxProviders)); | 112 AutocompleteClassifier::kDefaultOmniboxProviders)); |
112 } | 113 } |
113 | 114 |
114 void StartupPagesHandler::InitializePage() { | 115 void StartupPagesHandler::InitializePage() { |
115 UpdateStartupPages(); | 116 UpdateStartupPages(); |
116 } | 117 } |
117 | 118 |
118 void StartupPagesHandler::OnModelChanged() { | 119 void StartupPagesHandler::OnModelChanged() { |
119 base::ListValue startup_pages; | 120 base::ListValue startup_pages; |
120 int page_count = startup_custom_pages_table_model_->RowCount(); | 121 int page_count = startup_custom_pages_table_model_->RowCount(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 260 |
260 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 261 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
261 const AutocompleteResult& result = autocomplete_controller_->result(); | 262 const AutocompleteResult& result = autocomplete_controller_->result(); |
262 base::ListValue suggestions; | 263 base::ListValue suggestions; |
263 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 264 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
264 web_ui()->CallJavascriptFunction( | 265 web_ui()->CallJavascriptFunction( |
265 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 266 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
266 } | 267 } |
267 | 268 |
268 } // namespace options | 269 } // namespace options |
OLD | NEW |