| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin(); | 128 for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin(); |
| 129 iter != pref_callback_map_.end(); | 129 iter != pref_callback_map_.end(); |
| 130 ++iter) { | 130 ++iter) { |
| 131 if (last_pref != iter->first) { | 131 if (last_pref != iter->first) { |
| 132 StopObservingPref(iter->first); | 132 StopObservingPref(iter->first); |
| 133 last_pref = iter->first; | 133 last_pref = iter->first; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 void CoreOptionsHandler::Observe(int type, | 138 void CoreOptionsHandler::OnPreferenceChanged(PrefServiceBase* service, |
| 139 const content::NotificationSource& source, | 139 const std::string& pref_name) { |
| 140 const content::NotificationDetails& details) { | 140 if (pref_name == prefs::kClearPluginLSODataEnabled) { |
| 141 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 141 // This preference is stored in Local State, not in the user preferences. |
| 142 std::string* pref_name = content::Details<std::string>(details).ptr(); | 142 UpdateClearPluginLSOData(); |
| 143 if (*pref_name == prefs::kClearPluginLSODataEnabled) { | 143 return; |
| 144 // This preference is stored in Local State, not in the user preferences. | |
| 145 UpdateClearPluginLSOData(); | |
| 146 return; | |
| 147 } | |
| 148 if (*pref_name == prefs::kPepperFlashSettingsEnabled) { | |
| 149 UpdatePepperFlashSettingsEnabled(); | |
| 150 return; | |
| 151 } | |
| 152 NotifyPrefChanged(*pref_name, std::string()); | |
| 153 } | 144 } |
| 145 if (pref_name == prefs::kPepperFlashSettingsEnabled) { |
| 146 UpdatePepperFlashSettingsEnabled(); |
| 147 return; |
| 148 } |
| 149 NotifyPrefChanged(pref_name, std::string()); |
| 154 } | 150 } |
| 155 | 151 |
| 156 void CoreOptionsHandler::RegisterMessages() { | 152 void CoreOptionsHandler::RegisterMessages() { |
| 157 registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); | 153 registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); |
| 158 local_state_registrar_.Init(g_browser_process->local_state()); | 154 local_state_registrar_.Init(g_browser_process->local_state()); |
| 159 | 155 |
| 160 web_ui()->RegisterMessageCallback("coreOptionsInitialize", | 156 web_ui()->RegisterMessageCallback("coreOptionsInitialize", |
| 161 base::Bind(&CoreOptionsHandler::HandleInitialize, | 157 base::Bind(&CoreOptionsHandler::HandleInitialize, |
| 162 base::Unretained(this))); | 158 base::Unretained(this))); |
| 163 web_ui()->RegisterMessageCallback("fetchPrefs", | 159 web_ui()->RegisterMessageCallback("fetchPrefs", |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 531 |
| 536 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { | 532 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { |
| 537 scoped_ptr<base::Value> enabled( | 533 scoped_ptr<base::Value> enabled( |
| 538 base::Value::CreateBooleanValue( | 534 base::Value::CreateBooleanValue( |
| 539 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled())); | 535 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled())); |
| 540 web_ui()->CallJavascriptFunction( | 536 web_ui()->CallJavascriptFunction( |
| 541 "OptionsPage.setPepperFlashSettingsEnabled", *enabled); | 537 "OptionsPage.setPepperFlashSettingsEnabled", *enabled); |
| 542 } | 538 } |
| 543 | 539 |
| 544 } // namespace options | 540 } // namespace options |
| OLD | NEW |