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/core_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/core_options_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/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 CoreOptionsHandler::CoreOptionsHandler() | 53 CoreOptionsHandler::CoreOptionsHandler() |
54 : handlers_host_(NULL) { | 54 : handlers_host_(NULL) { |
55 } | 55 } |
56 | 56 |
57 CoreOptionsHandler::~CoreOptionsHandler() {} | 57 CoreOptionsHandler::~CoreOptionsHandler() {} |
58 | 58 |
59 void CoreOptionsHandler::InitializeHandler() { | 59 void CoreOptionsHandler::InitializeHandler() { |
60 plugin_status_pref_setter_.Init(Profile::FromWebUI(web_ui()), this); | 60 Profile* profile = Profile::FromWebUI(web_ui()); |
| 61 |
| 62 plugin_status_pref_setter_.Init( |
| 63 profile, |
| 64 base::Bind(&CoreOptionsHandler::OnPreferenceChanged, |
| 65 base::Unretained(this), |
| 66 profile->GetPrefs())); |
61 | 67 |
62 pref_change_filters_[prefs::kMetricsReportingEnabled] = | 68 pref_change_filters_[prefs::kMetricsReportingEnabled] = |
63 base::Bind(&AllowMetricsReportingChange); | 69 base::Bind(&AllowMetricsReportingChange); |
64 } | 70 } |
65 | 71 |
66 void CoreOptionsHandler::InitializePage() { | 72 void CoreOptionsHandler::InitializePage() { |
67 UpdateClearPluginLSOData(); | 73 UpdateClearPluginLSOData(); |
68 UpdatePepperFlashSettingsEnabled(); | 74 UpdatePepperFlashSettingsEnabled(); |
69 } | 75 } |
70 | 76 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void CoreOptionsHandler::HandleInitialize(const ListValue* args) { | 199 void CoreOptionsHandler::HandleInitialize(const ListValue* args) { |
194 DCHECK(handlers_host_); | 200 DCHECK(handlers_host_); |
195 handlers_host_->InitializeHandlers(); | 201 handlers_host_->InitializeHandlers(); |
196 } | 202 } |
197 | 203 |
198 base::Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { | 204 base::Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { |
199 return CreateValueForPref(pref_name, std::string()); | 205 return CreateValueForPref(pref_name, std::string()); |
200 } | 206 } |
201 | 207 |
202 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { | 208 void CoreOptionsHandler::ObservePref(const std::string& pref_name) { |
203 if (g_browser_process->local_state()->FindPreference(pref_name.c_str())) | 209 if (g_browser_process->local_state()->FindPreference(pref_name.c_str())) { |
204 local_state_registrar_.Add(pref_name.c_str(), this); | 210 local_state_registrar_.Add( |
205 else | 211 pref_name.c_str(), |
206 registrar_.Add(pref_name.c_str(), this); | 212 base::Bind(&CoreOptionsHandler::OnPreferenceChanged, |
| 213 base::Unretained(this), |
| 214 local_state_registrar_.prefs())); |
| 215 } else { |
| 216 registrar_.Add( |
| 217 pref_name.c_str(), |
| 218 base::Bind(&CoreOptionsHandler::OnPreferenceChanged, |
| 219 base::Unretained(this), |
| 220 registrar_.prefs())); |
| 221 } |
207 } | 222 } |
208 | 223 |
209 void CoreOptionsHandler::StopObservingPref(const std::string& pref_name) { | 224 void CoreOptionsHandler::StopObservingPref(const std::string& pref_name) { |
210 if (g_browser_process->local_state()->FindPreference(pref_name.c_str())) | 225 if (g_browser_process->local_state()->FindPreference(pref_name.c_str())) |
211 local_state_registrar_.Remove(pref_name.c_str()); | 226 local_state_registrar_.Remove(pref_name.c_str()); |
212 else | 227 else |
213 registrar_.Remove(pref_name.c_str()); | 228 registrar_.Remove(pref_name.c_str()); |
214 } | 229 } |
215 | 230 |
216 void CoreOptionsHandler::SetPref(const std::string& pref_name, | 231 void CoreOptionsHandler::SetPref(const std::string& pref_name, |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 548 |
534 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { | 549 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { |
535 scoped_ptr<base::Value> enabled( | 550 scoped_ptr<base::Value> enabled( |
536 base::Value::CreateBooleanValue( | 551 base::Value::CreateBooleanValue( |
537 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled())); | 552 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled())); |
538 web_ui()->CallJavascriptFunction( | 553 web_ui()->CallJavascriptFunction( |
539 "OptionsPage.setPepperFlashSettingsEnabled", *enabled); | 554 "OptionsPage.setPepperFlashSettingsEnabled", *enabled); |
540 } | 555 } |
541 | 556 |
542 } // namespace options | 557 } // namespace options |
OLD | NEW |