| 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 21 matching lines...) Expand all Loading... |
| 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 } | 38 } |
| 39 | 39 |
| 40 CoreOptionsHandler::~CoreOptionsHandler() {} | 40 CoreOptionsHandler::~CoreOptionsHandler() {} |
| 41 | 41 |
| 42 void CoreOptionsHandler::InitializeHandler() { | 42 void CoreOptionsHandler::InitializePage() { |
| 43 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, | 43 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, |
| 44 Profile::FromWebUI(web_ui()), | 44 Profile::FromWebUI(web_ui()), |
| 45 this); | 45 this); |
| 46 } | |
| 47 | |
| 48 void CoreOptionsHandler::InitializePage() { | |
| 49 UpdateClearPluginLSOData(); | 46 UpdateClearPluginLSOData(); |
| 50 } | 47 } |
| 51 | 48 |
| 52 void CoreOptionsHandler::GetLocalizedValues( | 49 void CoreOptionsHandler::GetLocalizedValues( |
| 53 DictionaryValue* localized_strings) { | 50 DictionaryValue* localized_strings) { |
| 54 GetStaticLocalizedValues(localized_strings); | 51 GetStaticLocalizedValues(localized_strings); |
| 55 } | 52 } |
| 56 | 53 |
| 57 void CoreOptionsHandler::GetStaticLocalizedValues( | 54 void CoreOptionsHandler::GetStaticLocalizedValues( |
| 58 base::DictionaryValue* localized_strings) { | 55 base::DictionaryValue* localized_strings) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 UpdateClearPluginLSOData(); | 124 UpdateClearPluginLSOData(); |
| 128 return; | 125 return; |
| 129 } | 126 } |
| 130 NotifyPrefChanged(*pref_name, std::string()); | 127 NotifyPrefChanged(*pref_name, std::string()); |
| 131 } | 128 } |
| 132 } | 129 } |
| 133 | 130 |
| 134 void CoreOptionsHandler::RegisterMessages() { | 131 void CoreOptionsHandler::RegisterMessages() { |
| 135 registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); | 132 registrar_.Init(Profile::FromWebUI(web_ui())->GetPrefs()); |
| 136 | 133 |
| 137 web_ui()->RegisterMessageCallback("coreOptionsInitialize", | 134 web_ui()->RegisterMessageCallback("coreOptionsInitializePages", |
| 138 base::Bind(&CoreOptionsHandler::HandleInitialize, | 135 base::Bind(&CoreOptionsHandler::HandleInitializePages, |
| 139 base::Unretained(this))); | 136 base::Unretained(this))); |
| 140 web_ui()->RegisterMessageCallback("fetchPrefs", | 137 web_ui()->RegisterMessageCallback("fetchPrefs", |
| 141 base::Bind(&CoreOptionsHandler::HandleFetchPrefs, | 138 base::Bind(&CoreOptionsHandler::HandleFetchPrefs, |
| 142 base::Unretained(this))); | 139 base::Unretained(this))); |
| 143 web_ui()->RegisterMessageCallback("observePrefs", | 140 web_ui()->RegisterMessageCallback("observePrefs", |
| 144 base::Bind(&CoreOptionsHandler::HandleObservePrefs, | 141 base::Bind(&CoreOptionsHandler::HandleObservePrefs, |
| 145 base::Unretained(this))); | 142 base::Unretained(this))); |
| 146 web_ui()->RegisterMessageCallback("setBooleanPref", | 143 web_ui()->RegisterMessageCallback("setBooleanPref", |
| 147 base::Bind(&CoreOptionsHandler::HandleSetBooleanPref, | 144 base::Bind(&CoreOptionsHandler::HandleSetBooleanPref, |
| 148 base::Unretained(this))); | 145 base::Unretained(this))); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 162 base::Bind(&CoreOptionsHandler::HandleSetListPref, | 159 base::Bind(&CoreOptionsHandler::HandleSetListPref, |
| 163 base::Unretained(this))); | 160 base::Unretained(this))); |
| 164 web_ui()->RegisterMessageCallback("clearPref", | 161 web_ui()->RegisterMessageCallback("clearPref", |
| 165 base::Bind(&CoreOptionsHandler::HandleClearPref, | 162 base::Bind(&CoreOptionsHandler::HandleClearPref, |
| 166 base::Unretained(this))); | 163 base::Unretained(this))); |
| 167 web_ui()->RegisterMessageCallback("coreOptionsUserMetricsAction", | 164 web_ui()->RegisterMessageCallback("coreOptionsUserMetricsAction", |
| 168 base::Bind(&CoreOptionsHandler::HandleUserMetricsAction, | 165 base::Bind(&CoreOptionsHandler::HandleUserMetricsAction, |
| 169 base::Unretained(this))); | 166 base::Unretained(this))); |
| 170 } | 167 } |
| 171 | 168 |
| 172 void CoreOptionsHandler::HandleInitialize(const ListValue* args) { | 169 void CoreOptionsHandler::HandleInitializePages(const ListValue* args) { |
| 173 DCHECK(handlers_host_); | 170 DCHECK(handlers_host_); |
| 174 handlers_host_->InitializeHandlers(); | 171 handlers_host_->InitializePages(); |
| 175 } | 172 } |
| 176 | 173 |
| 177 base::Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { | 174 base::Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { |
| 178 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 175 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 179 | 176 |
| 180 const PrefService::Preference* pref = | 177 const PrefService::Preference* pref = |
| 181 pref_service->FindPreference(pref_name.c_str()); | 178 pref_service->FindPreference(pref_name.c_str()); |
| 182 if (!pref) | 179 if (!pref) |
| 183 return base::Value::CreateNullValue(); | 180 return base::Value::CreateNullValue(); |
| 184 | 181 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 454 |
| 458 void CoreOptionsHandler::UpdateClearPluginLSOData() { | 455 void CoreOptionsHandler::UpdateClearPluginLSOData() { |
| 459 scoped_ptr<base::Value> enabled( | 456 scoped_ptr<base::Value> enabled( |
| 460 base::Value::CreateBooleanValue( | 457 base::Value::CreateBooleanValue( |
| 461 clear_plugin_lso_data_enabled_.GetValue())); | 458 clear_plugin_lso_data_enabled_.GetValue())); |
| 462 web_ui()->CallJavascriptFunction( | 459 web_ui()->CallJavascriptFunction( |
| 463 "OptionsPage.setClearPluginLSODataEnabled", *enabled); | 460 "OptionsPage.setClearPluginLSODataEnabled", *enabled); |
| 464 } | 461 } |
| 465 | 462 |
| 466 } // namespace options2 | 463 } // namespace options2 |
| OLD | NEW |