| OLD | NEW |
| 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/basictypes.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 MetricsCrosSettingsProvider* StatsOptionsHandler::provider() const { | 37 MetricsCrosSettingsProvider* StatsOptionsHandler::provider() const { |
| 38 return static_cast<MetricsCrosSettingsProvider*>(settings_provider_.get()); | 38 return static_cast<MetricsCrosSettingsProvider*>(settings_provider_.get()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void StatsOptionsHandler::HandleMetricsReportingCheckbox( | 41 void StatsOptionsHandler::HandleMetricsReportingCheckbox( |
| 42 const ListValue* args) { | 42 const ListValue* args) { |
| 43 #if defined(GOOGLE_CHROME_BUILD) | 43 #if defined(GOOGLE_CHROME_BUILD) |
| 44 const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 44 const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 45 const bool enabled = (checked_str == "true"); | 45 const bool enabled = (checked_str == "true"); |
| 46 UserMetricsRecordAction( | 46 UserMetrics::RecordAction( |
| 47 enabled ? | 47 enabled ? |
| 48 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : | 48 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : |
| 49 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); | 49 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); |
| 50 const bool is_enabled = MetricsCrosSettingsProvider::GetMetricsStatus(); | 50 const bool is_enabled = MetricsCrosSettingsProvider::GetMetricsStatus(); |
| 51 SetupMetricsReportingCheckbox(enabled == is_enabled); | 51 SetupMetricsReportingCheckbox(enabled == is_enabled); |
| 52 #endif | 52 #endif |
| 53 } | 53 } |
| 54 | 54 |
| 55 void StatsOptionsHandler::SetupMetricsReportingCheckbox(bool user_changed) { | 55 void StatsOptionsHandler::SetupMetricsReportingCheckbox(bool user_changed) { |
| 56 #if defined(GOOGLE_CHROME_BUILD) | 56 #if defined(GOOGLE_CHROME_BUILD) |
| 57 FundamentalValue checked(MetricsCrosSettingsProvider::GetMetricsStatus()); | 57 FundamentalValue checked(MetricsCrosSettingsProvider::GetMetricsStatus()); |
| 58 FundamentalValue disabled(!UserManager::Get()->current_user_is_owner()); | 58 FundamentalValue disabled(!UserManager::Get()->current_user_is_owner()); |
| 59 FundamentalValue user_has_changed(user_changed); | 59 FundamentalValue user_has_changed(user_changed); |
| 60 web_ui_->CallJavascriptFunction( | 60 web_ui_->CallJavascriptFunction( |
| 61 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, | 61 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, |
| 62 disabled, user_has_changed); | 62 disabled, user_has_changed); |
| 63 #endif | 63 #endif |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace chromeos | 66 } // namespace chromeos |
| OLD | NEW |