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

Side by Side Diff: chrome/browser/ui/webui/settings/metrics_reporting_handler.h

Issue 2233443002: MD Settings: implement metrics reporting checkbox on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@desktop-uma
Patch Set: merge + closure Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_
7
8 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
9 #error This handler should only be included on Google Chrome for Mac/Win/Linux
10 #endif
11
12 #include <memory>
13
14 #include "base/macros.h"
15 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
16 #include "components/policy/core/common/policy_service.h"
17 #include "components/prefs/pref_member.h"
18
19 namespace base {
20 class DictionaryValue;
21 }
22
23 namespace settings {
24
25 class MetricsReportingHandler : public SettingsPageUIHandler {
26 public:
27 MetricsReportingHandler();
28 ~MetricsReportingHandler() override;
29
30 // SettingsPageUIHandler:
31 void RegisterMessages() override;
32 void OnJavascriptAllowed() override;
33 void OnJavascriptDisallowed() override;
34
35 protected:
36 // Handler for "getMetricsReporting" message. No arguments. Protected for
37 // testing.
38 void HandleGetMetricsReporting(const base::ListValue* args);
39
40 private:
41 // Describes the state of metrics reporting in a base::DictionaryValue.
42 // Friends with ChromeMetricsServiceAccessor.
43 std::unique_ptr<base::DictionaryValue> CreateMetricsReportingDict();
44
45 // Handler for "setMetricsReportingEnabled" message. Passed a single,
46 // |enabled| boolean argument.
47 void HandleSetMetricsReportingEnabled(const base::ListValue* args);
48
49 // Called when the policies that affect whether metrics reporting is managed
50 // change.
51 void OnPolicyChanged(const base::Value* current_policy,
52 const base::Value* previous_policy);
53
54 // Called when the local state pref controlling metrics reporting changes.
55 void OnPrefChanged(const std::string& pref_name);
56
57 // Sends a "metrics-reporting-change" WebUI listener event to the page.
58 void SendMetricsReportingChange();
59
60 // Used to track pref changes that affect whether metrics reporting is
61 // enabled.
62 std::unique_ptr<BooleanPrefMember> pref_member_;
63
64 // Used to track policy changes that affect whether metrics reporting is
65 // enabled or managed.
66 std::unique_ptr<policy::PolicyChangeRegistrar> policy_registrar_;
67
68 DISALLOW_COPY_AND_ASSIGN(MetricsReportingHandler);
69 };
70
71 } // namespace settings
72
73 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698