| 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/core_options_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/core_options_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 "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 16 matching lines...) Expand all Loading... |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "grit/locale_settings.h" | 28 #include "grit/locale_settings.h" |
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 31 | 31 |
| 32 using content::UserMetricsAction; | 32 using content::UserMetricsAction; |
| 33 | 33 |
| 34 namespace options2 { | 34 namespace options2 { |
| 35 | 35 |
| 36 CoreOptionsHandler::CoreOptionsHandler() | 36 CoreOptionsHandler::CoreOptionsHandler() |
| 37 : handlers_host_(NULL) { | 37 : handlers_host_(NULL), |
| 38 clear_plugin_lso_data_enabled_(prefs::kClearPluginLSODataEnabled), |
| 39 pepper_flash_settings_enabled_(prefs::kPepperFlashSettingsEnabled) { |
| 38 } | 40 } |
| 39 | 41 |
| 40 CoreOptionsHandler::~CoreOptionsHandler() {} | 42 CoreOptionsHandler::~CoreOptionsHandler() {} |
| 41 | 43 |
| 42 void CoreOptionsHandler::InitializeHandler() { | 44 void CoreOptionsHandler::InitializeHandler() { |
| 43 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, | 45 std::vector<PluginStatusPrefSetter::Client*> clients; |
| 44 Profile::FromWebUI(web_ui()), | 46 clients.push_back(&clear_plugin_lso_data_enabled_); |
| 45 this); | 47 clients.push_back(&pepper_flash_settings_enabled_); |
| 48 plugin_status_pref_setter_.Init(clients, Profile::FromWebUI(web_ui()), this); |
| 46 } | 49 } |
| 47 | 50 |
| 48 void CoreOptionsHandler::InitializePage() { | 51 void CoreOptionsHandler::InitializePage() { |
| 49 UpdateClearPluginLSOData(); | 52 UpdateClearPluginLSOData(); |
| 53 UpdatePepperFlashSettingsEnabled(); |
| 50 } | 54 } |
| 51 | 55 |
| 52 void CoreOptionsHandler::GetLocalizedValues( | 56 void CoreOptionsHandler::GetLocalizedValues( |
| 53 DictionaryValue* localized_strings) { | 57 DictionaryValue* localized_strings) { |
| 54 GetStaticLocalizedValues(localized_strings); | 58 GetStaticLocalizedValues(localized_strings); |
| 55 } | 59 } |
| 56 | 60 |
| 57 void CoreOptionsHandler::GetStaticLocalizedValues( | 61 void CoreOptionsHandler::GetStaticLocalizedValues( |
| 58 base::DictionaryValue* localized_strings) { | 62 base::DictionaryValue* localized_strings) { |
| 59 DCHECK(localized_strings); | 63 DCHECK(localized_strings); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void CoreOptionsHandler::Observe(int type, | 124 void CoreOptionsHandler::Observe(int type, |
| 121 const content::NotificationSource& source, | 125 const content::NotificationSource& source, |
| 122 const content::NotificationDetails& details) { | 126 const content::NotificationDetails& details) { |
| 123 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 127 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 124 std::string* pref_name = content::Details<std::string>(details).ptr(); | 128 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 125 if (*pref_name == prefs::kClearPluginLSODataEnabled) { | 129 if (*pref_name == prefs::kClearPluginLSODataEnabled) { |
| 126 // This preference is stored in Local State, not in the user preferences. | 130 // This preference is stored in Local State, not in the user preferences. |
| 127 UpdateClearPluginLSOData(); | 131 UpdateClearPluginLSOData(); |
| 128 return; | 132 return; |
| 129 } | 133 } |
| 134 if (*pref_name == prefs::kPepperFlashSettingsEnabled) { |
| 135 UpdatePepperFlashSettingsEnabled(); |
| 136 return; |
| 137 } |
| 130 NotifyPrefChanged(*pref_name, std::string()); | 138 NotifyPrefChanged(*pref_name, std::string()); |
| 131 } | 139 } |
| 132 } | 140 } |
| 133 | 141 |
| 134 void CoreOptionsHandler::RegisterMessages() { | 142 void CoreOptionsHandler::RegisterMessages() { |
| 135 registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); | 143 registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); |
| 136 | 144 |
| 137 web_ui()->RegisterMessageCallback("coreOptionsInitialize", | 145 web_ui()->RegisterMessageCallback("coreOptionsInitialize", |
| 138 base::Bind(&CoreOptionsHandler::HandleInitialize, | 146 base::Bind(&CoreOptionsHandler::HandleInitialize, |
| 139 base::Unretained(this))); | 147 base::Unretained(this))); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 470 } |
| 463 | 471 |
| 464 void CoreOptionsHandler::UpdateClearPluginLSOData() { | 472 void CoreOptionsHandler::UpdateClearPluginLSOData() { |
| 465 scoped_ptr<base::Value> enabled( | 473 scoped_ptr<base::Value> enabled( |
| 466 base::Value::CreateBooleanValue( | 474 base::Value::CreateBooleanValue( |
| 467 clear_plugin_lso_data_enabled_.GetValue())); | 475 clear_plugin_lso_data_enabled_.GetValue())); |
| 468 web_ui()->CallJavascriptFunction( | 476 web_ui()->CallJavascriptFunction( |
| 469 "OptionsPage.setClearPluginLSODataEnabled", *enabled); | 477 "OptionsPage.setClearPluginLSODataEnabled", *enabled); |
| 470 } | 478 } |
| 471 | 479 |
| 480 void CoreOptionsHandler::UpdatePepperFlashSettingsEnabled() { |
| 481 scoped_ptr<base::Value> enabled( |
| 482 base::Value::CreateBooleanValue( |
| 483 pepper_flash_settings_enabled_.GetValue())); |
| 484 web_ui()->CallJavascriptFunction( |
| 485 "OptionsPage.setPepperFlashSettingsEnabled", *enabled); |
| 486 } |
| 487 |
| 472 } // namespace options2 | 488 } // namespace options2 |
| OLD | NEW |