Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2443)

Unified Diff: chrome/browser/ui/webui/options/core_options_handler.cc

Issue 506663003: Consolidates accessing and setting the UMA pref to be within metrics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698