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

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: more comments. using accesor class. Created 6 years, 3 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 b7bc0ff5911135a5a7df5a61a06a23ef223e4046..b3ebcc88aa4ca57e1eb72a4dbf5225a5b37298ea 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",
Alexei Svitkine (slow) 2014/09/05 15:22:48 I know the previous code was in this file, but acc
gayane -on leave until 09-2017 2014/09/05 18:30:20 That actually makes sense because other functions
+ 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)) return;
Alexei Svitkine (slow) 2014/09/05 15:22:48 Nit: Put return on the next line.
gayane -on leave until 09-2017 2014/09/05 18:30:20 Done.
+
+ InitiateMetricsReportingChange(enable, callback_fn);
+}
+
+void CoreOptionsHandler::MetricsReportingChangeCallback(bool success) {
+ base::DictionaryValue* dict = new base::DictionaryValue;
Alexei Svitkine (slow) 2014/09/05 15:22:48 I think you might be leaking this. Please double
gayane -on leave until 09-2017 2014/09/05 18:30:20 param removed. not needed anymore.
+ 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