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

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

Issue 7518012: Revert 94350 - Merge 94322 - Rewire the metrics pref to the signed settings store on chromeos. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: Created 9 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 | 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"
7 #include "base/callback.h" 8 #include "base/callback.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "chrome/browser/chromeos/user_cros_settings_provider.h" 11 #include "chrome/browser/chromeos/cros_settings_names.h"
12 #include "chrome/browser/chromeos/login/user_manager.h"
13 #include "chrome/browser/chromeos/metrics_cros_settings_provider.h"
11 #include "content/browser/user_metrics.h" 14 #include "content/browser/user_metrics.h"
12 15
13 namespace chromeos { 16 namespace chromeos {
14 17
15 StatsOptionsHandler::StatsOptionsHandler() 18 StatsOptionsHandler::StatsOptionsHandler()
16 : CrosOptionsPageUIHandler(new UserCrosSettingsProvider) { 19 : CrosOptionsPageUIHandler(new MetricsCrosSettingsProvider()) {
17 } 20 }
18 21
19 // OptionsPageUIHandler implementation. 22 // OptionsPageUIHandler implementation.
20 void StatsOptionsHandler::GetLocalizedValues( 23 void StatsOptionsHandler::GetLocalizedValues(
21 DictionaryValue* localized_strings) { 24 DictionaryValue* localized_strings) {
22 } 25 }
23
24 void StatsOptionsHandler::Initialize() { 26 void StatsOptionsHandler::Initialize() {
27 SetupMetricsReportingCheckbox(false);
25 } 28 }
26 29
27 // WebUIMessageHandler implementation. 30 // WebUIMessageHandler implementation.
28 void StatsOptionsHandler::RegisterMessages() { 31 void StatsOptionsHandler::RegisterMessages() {
29 web_ui_->RegisterMessageCallback( 32 web_ui_->RegisterMessageCallback(
30 "metricsReportingCheckboxAction", 33 "metricsReportingCheckboxAction",
31 NewCallback(this, &StatsOptionsHandler::HandleMetricsReportingCheckbox)); 34 NewCallback(this, &StatsOptionsHandler::HandleMetricsReportingCheckbox));
32 } 35 }
33 36
37 MetricsCrosSettingsProvider* StatsOptionsHandler::provider() const {
38 return static_cast<MetricsCrosSettingsProvider*>(settings_provider_.get());
39 }
40
34 void StatsOptionsHandler::HandleMetricsReportingCheckbox( 41 void StatsOptionsHandler::HandleMetricsReportingCheckbox(
35 const ListValue* args) { 42 const ListValue* args) {
36 #if defined(GOOGLE_CHROME_BUILD) 43 #if defined(GOOGLE_CHROME_BUILD)
37 const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 44 const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
38 const bool enabled = (checked_str == "true"); 45 const bool enabled = (checked_str == "true");
39 UserMetricsRecordAction( 46 UserMetricsRecordAction(
40 enabled ? 47 enabled ?
41 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : 48 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
42 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); 49 UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
50 const bool is_enabled = MetricsCrosSettingsProvider::GetMetricsStatus();
51 SetupMetricsReportingCheckbox(enabled == is_enabled);
52 #endif
53 }
54
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);
43 #endif 63 #endif
44 } 64 }
45 65
46 } // namespace chromeos 66 } // 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