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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/stats_options_handler.cc

Issue 7480040: Rewire the metrics pref to the signed settings store on chromeos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT. Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/chromeos/stats_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/stats_options_handler.h"
6 6
7 #include "base/basictypes.h"
8 #include "base/callback.h" 7 #include "base/callback.h"
9 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 9 #include "base/values.h"
11 #include "chrome/browser/chromeos/cros_settings_names.h" 10 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
12 #include "chrome/browser/chromeos/login/user_manager.h"
13 #include "chrome/browser/chromeos/metrics_cros_settings_provider.h"
14 #include "content/browser/user_metrics.h" 11 #include "content/browser/user_metrics.h"
15 12
16 namespace chromeos { 13 namespace chromeos {
17 14
18 StatsOptionsHandler::StatsOptionsHandler() 15 StatsOptionsHandler::StatsOptionsHandler()
19 : CrosOptionsPageUIHandler(new MetricsCrosSettingsProvider()) { 16 : CrosOptionsPageUIHandler(new UserCrosSettingsProvider) {
20 } 17 }
21 18
22 // OptionsPageUIHandler implementation. 19 // OptionsPageUIHandler implementation.
23 void StatsOptionsHandler::GetLocalizedValues( 20 void StatsOptionsHandler::GetLocalizedValues(
24 DictionaryValue* localized_strings) { 21 DictionaryValue* localized_strings) {
25 } 22 }
23
26 void StatsOptionsHandler::Initialize() { 24 void StatsOptionsHandler::Initialize() {
27 SetupMetricsReportingCheckbox(false);
28 } 25 }
29 26
30 // WebUIMessageHandler implementation. 27 // WebUIMessageHandler implementation.
31 void StatsOptionsHandler::RegisterMessages() { 28 void StatsOptionsHandler::RegisterMessages() {
32 web_ui_->RegisterMessageCallback( 29 web_ui_->RegisterMessageCallback(
33 "metricsReportingCheckboxAction", 30 "metricsReportingCheckboxAction",
34 NewCallback(this, &StatsOptionsHandler::HandleMetricsReportingCheckbox)); 31 NewCallback(this, &StatsOptionsHandler::HandleMetricsReportingCheckbox));
35 } 32 }
36 33
37 MetricsCrosSettingsProvider* StatsOptionsHandler::provider() const {
38 return static_cast<MetricsCrosSettingsProvider*>(settings_provider_.get());
39 }
40
41 void StatsOptionsHandler::HandleMetricsReportingCheckbox( 34 void StatsOptionsHandler::HandleMetricsReportingCheckbox(
42 const ListValue* args) { 35 const ListValue* args) {
43 #if defined(GOOGLE_CHROME_BUILD) 36 #if defined(GOOGLE_CHROME_BUILD)
44 const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 37 const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
45 const bool enabled = (checked_str == "true"); 38 const bool enabled = (checked_str == "true");
46 UserMetricsRecordAction( 39 UserMetricsRecordAction(
47 enabled ? 40 enabled ?
48 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : 41 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
49 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); 42 UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
50 const bool is_enabled = MetricsCrosSettingsProvider::GetMetricsStatus();
51 SetupMetricsReportingCheckbox(enabled == is_enabled);
52 #endif 43 #endif
53 } 44 }
54 45
55 void StatsOptionsHandler::SetupMetricsReportingCheckbox(bool user_changed) {
56 #if defined(GOOGLE_CHROME_BUILD)
57 FundamentalValue checked(MetricsCrosSettingsProvider::GetMetricsStatus());
58 FundamentalValue disabled(!UserManager::Get()->current_user_is_owner());
59 FundamentalValue user_has_changed(user_changed);
60 web_ui_->CallJavascriptFunction(
61 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked,
62 disabled, user_has_changed);
63 #endif
64 }
65
66 } // namespace chromeos 46 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/stats_options_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698