| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 return; | 2152 return; |
| 2153 // Decline the change if current user shouldn't be able to change metrics | 2153 // Decline the change if current user shouldn't be able to change metrics |
| 2154 // reporting. | 2154 // reporting. |
| 2155 if (!IsDeviceOwnerProfile() || IsMetricsReportingPolicyManaged()) { | 2155 if (!IsDeviceOwnerProfile() || IsMetricsReportingPolicyManaged()) { |
| 2156 NotifyUIOfMetricsReportingChange( | 2156 NotifyUIOfMetricsReportingChange( |
| 2157 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); | 2157 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); |
| 2158 return; | 2158 return; |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 // For Chrome OS updating device settings will notify an observer to update | 2161 // For Chrome OS updating device settings will notify an observer to update |
| 2162 // metrics pref, however we still need to call |InitiateMetricsReportingChange| | 2162 // metrics pref, however we still need to call |
| 2163 // with a proper callback so that UI gets updated in case of failure to update | 2163 // |ChangeMetricsReportingStateWithReply| with a proper callback so that UI gets |
| 2164 // the metrics pref. | 2164 // updated in case of failure to update the metrics pref. |
| 2165 // TODO(gayane): Don't call |InitiateMetricsReportingChange| twice so that | 2165 // TODO(gayane): Don't call |ChangeMetricsReportingStateWithReply| twice so that |
| 2166 // metrics service pref changes only as a result of device settings change for | 2166 // metrics service pref changes only as a result of device settings change for |
| 2167 // Chrome OS .crbug.com/552550. | 2167 // Chrome OS .crbug.com/552550. |
| 2168 #if defined(OS_CHROMEOS) | 2168 #if defined(OS_CHROMEOS) |
| 2169 chromeos::CrosSettings::Get()->SetBoolean(chromeos::kStatsReportingPref, | 2169 chromeos::CrosSettings::Get()->SetBoolean(chromeos::kStatsReportingPref, |
| 2170 enable); | 2170 enable); |
| 2171 #endif // defined(OS_CHROMEOS) | 2171 #endif // defined(OS_CHROMEOS) |
| 2172 InitiateMetricsReportingChange( | 2172 ChangeMetricsReportingStateWithReply( |
| 2173 enable, | 2173 enable, |
| 2174 base::Bind(&BrowserOptionsHandler::NotifyUIOfMetricsReportingChange, | 2174 base::Bind(&BrowserOptionsHandler::NotifyUIOfMetricsReportingChange, |
| 2175 weak_ptr_factory_.GetWeakPtr())); | 2175 weak_ptr_factory_.GetWeakPtr())); |
| 2176 } | 2176 } |
| 2177 | 2177 |
| 2178 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { | 2178 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { |
| 2179 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), | 2179 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), |
| 2180 !IsDeviceOwnerProfile()); | 2180 !IsDeviceOwnerProfile()); |
| 2181 } | 2181 } |
| 2182 | 2182 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2200 | 2200 |
| 2201 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { | 2201 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { |
| 2202 #if defined(OS_CHROMEOS) | 2202 #if defined(OS_CHROMEOS) |
| 2203 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | 2203 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); |
| 2204 #else | 2204 #else |
| 2205 return true; | 2205 return true; |
| 2206 #endif | 2206 #endif |
| 2207 } | 2207 } |
| 2208 | 2208 |
| 2209 } // namespace options | 2209 } // namespace options |
| OLD | NEW |