| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/power/power_prefs.h" | 5 #include "chrome/browser/chromeos/power/power_prefs.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 void PowerPrefs::SetProfile(Profile* profile) { | 231 void PowerPrefs::SetProfile(Profile* profile) { |
| 232 // No need to reapply policy if profile hasn't changed, e.g. when adding a | 232 // No need to reapply policy if profile hasn't changed, e.g. when adding a |
| 233 // secondary user to an existing session. | 233 // secondary user to an existing session. |
| 234 if (profile == profile_) | 234 if (profile == profile_) |
| 235 return; | 235 return; |
| 236 | 236 |
| 237 profile_ = profile; | 237 profile_ = profile; |
| 238 pref_change_registrar_.reset(); | 238 pref_change_registrar_.reset(); |
| 239 | 239 |
| 240 if (!profile) { | 240 if (!profile) |
| 241 power_policy_controller_->ClearPrefs(); | |
| 242 return; | 241 return; |
| 243 } | |
| 244 | 242 |
| 245 base::Closure update_callback(base::Bind( | 243 base::Closure update_callback(base::Bind( |
| 246 &PowerPrefs::UpdatePowerPolicyFromPrefs, | 244 &PowerPrefs::UpdatePowerPolicyFromPrefs, |
| 247 base::Unretained(this))); | 245 base::Unretained(this))); |
| 248 pref_change_registrar_.reset(new PrefChangeRegistrar); | 246 pref_change_registrar_.reset(new PrefChangeRegistrar); |
| 249 pref_change_registrar_->Init(profile->GetPrefs()); | 247 pref_change_registrar_->Init(profile->GetPrefs()); |
| 250 pref_change_registrar_->Add(prefs::kPowerAcScreenDimDelayMs, update_callback); | 248 pref_change_registrar_->Add(prefs::kPowerAcScreenDimDelayMs, update_callback); |
| 251 pref_change_registrar_->Add(prefs::kPowerAcScreenOffDelayMs, update_callback); | 249 pref_change_registrar_->Add(prefs::kPowerAcScreenOffDelayMs, update_callback); |
| 252 pref_change_registrar_->Add(prefs::kPowerAcScreenLockDelayMs, | 250 pref_change_registrar_->Add(prefs::kPowerAcScreenLockDelayMs, |
| 253 update_callback); | 251 update_callback); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 275 update_callback); | 273 update_callback); |
| 276 pref_change_registrar_->Add(prefs::kPowerUserActivityScreenDimDelayFactor, | 274 pref_change_registrar_->Add(prefs::kPowerUserActivityScreenDimDelayFactor, |
| 277 update_callback); | 275 update_callback); |
| 278 pref_change_registrar_->Add(prefs::kPowerWaitForInitialUserActivity, | 276 pref_change_registrar_->Add(prefs::kPowerWaitForInitialUserActivity, |
| 279 update_callback); | 277 update_callback); |
| 280 | 278 |
| 281 UpdatePowerPolicyFromPrefs(); | 279 UpdatePowerPolicyFromPrefs(); |
| 282 } | 280 } |
| 283 | 281 |
| 284 } // namespace chromeos | 282 } // namespace chromeos |
| OLD | NEW |