Chromium Code Reviews| Index: chrome/browser/ui/webui/options/core_options_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/core_options_handler.cc b/chrome/browser/ui/webui/options/core_options_handler.cc |
| index b7bc0ff5911135a5a7df5a61a06a23ef223e4046..8bb4572bdfaa31c38eafda25f62fb0195bac7af3 100644 |
| --- a/chrome/browser/ui/webui/options/core_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options/core_options_handler.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| +#include "base/callback.h" |
| #include "base/json/json_reader.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/strings/string16.h" |
| @@ -43,18 +44,6 @@ namespace options { |
| namespace { |
| -// Only allow changes to the metrics reporting checkbox if we were succesfully |
| -// able to change the service. |
| -bool AllowMetricsReportingChange(const base::Value* to_value) { |
| - bool enable; |
| - if (!to_value->GetAsBoolean(&enable)) { |
| - NOTREACHED(); |
| - return false; |
| - } |
| - |
| - return enable == ResolveMetricsReportingEnabled(enable); |
| -} |
| - |
| // Whether "controlledBy" property of pref value sent to options web UI needs to |
| // be set to "extension" when the preference is controlled by an extension. |
| bool CanSetExtensionControlledPrefValue( |
| @@ -89,9 +78,6 @@ void CoreOptionsHandler::InitializeHandler() { |
| base::Bind(&CoreOptionsHandler::OnPreferenceChanged, |
| base::Unretained(this), |
| profile->GetPrefs())); |
| - |
| - pref_change_filters_[prefs::kMetricsReportingEnabled] = |
| - base::Bind(&AllowMetricsReportingChange); |
| } |
| void CoreOptionsHandler::InitializePage() { |
| @@ -238,6 +224,9 @@ void CoreOptionsHandler::RegisterMessages() { |
| web_ui()->RegisterMessageCallback("disableExtension", |
| base::Bind(&CoreOptionsHandler::HandleDisableExtension, |
| base::Unretained(this))); |
| + web_ui()->RegisterMessageCallback("coreOptionsMetricsReportingChange", |
| + base::Bind(&CoreOptionsHandler::HandleMetricsReportingChange, |
| + base::Unretained(this))); |
| } |
| void CoreOptionsHandler::HandleInitialize(const base::ListValue* args) { |
| @@ -643,6 +632,24 @@ void CoreOptionsHandler::HandleDisableExtension(const base::ListValue* args) { |
| } |
| } |
| +void CoreOptionsHandler::HandleMetricsReportingChange( |
| + const base::ListValue* args) { |
| + base::Callback<void(bool)> callback_fn = base::Bind( |
| + &CoreOptionsHandler::MetricsReportingChangeCallback, |
| + base::Unretained(this)); |
| + bool enable; |
| + if (args->GetBoolean(0, &enable)) { |
|
Alexei Svitkine (slow)
2014/09/04 18:45:26
Nit: prefer an early return.
gayane -on leave until 09-2017
2014/09/04 21:30:13
Done.
|
| + InitiateMetricsReportingChange(enable, callback_fn); |
| + } |
| +} |
| + |
| +void CoreOptionsHandler::MetricsReportingChangeCallback(bool success) { |
| + base::DictionaryValue* dict = new base::DictionaryValue; |
| + dict->SetBoolean("success", success); |
| + web_ui()->CallJavascriptFunction( |
| + "BrowserOptions.setMetricsReportingJSCallback", *dict); |
| +} |
| + |
| void CoreOptionsHandler::UpdateClearPluginLSOData() { |
| base::FundamentalValue enabled( |
| plugin_status_pref_setter_.IsClearPluginLSODataEnabled()); |