| 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 f4c359b1ab5d1b89cbffe3a277d57915b17c0810..a844dd0343cd30d507e01253f74a832eac277d4f 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)) {
|
| + InitiateMetricsReportingChange(callback_fn, enable);
|
| + }
|
| +}
|
| +
|
| +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());
|
|
|