| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 switch (type) { | 77 switch (type) { |
| 78 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { | 78 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { |
| 79 // Update |profile_| when entering the login screen. | 79 // Update |profile_| when entering the login screen. |
| 80 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 80 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 81 if (!profile_manager || !profile_manager->IsLoggedIn()) | 81 if (!profile_manager || !profile_manager->IsLoggedIn()) |
| 82 SetProfile(ProfileHelper::GetSigninProfile()); | 82 SetProfile(ProfileHelper::GetSigninProfile()); |
| 83 break; | 83 break; |
| 84 } | 84 } |
| 85 case chrome::NOTIFICATION_SESSION_STARTED: | 85 case chrome::NOTIFICATION_SESSION_STARTED: |
| 86 // Update |profile_| when entering a session. | 86 // Update |profile_| when entering a session. |
| 87 SetProfile(ProfileManager::GetDefaultProfile()); | 87 SetProfile(ProfileManager::GetPrimaryUserProfile()); |
| 88 break; | 88 break; |
| 89 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 89 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 90 // Update |profile_| when exiting a session or shutting down. | 90 // Update |profile_| when exiting a session or shutting down. |
| 91 Profile* profile = content::Source<Profile>(source).ptr(); | 91 Profile* profile = content::Source<Profile>(source).ptr(); |
| 92 if (profile_ == profile) | 92 if (profile_ == profile) |
| 93 SetProfile(NULL); | 93 SetProfile(NULL); |
| 94 break; | 94 break; |
| 95 } | 95 } |
| 96 default: | 96 default: |
| 97 NOTREACHED(); | 97 NOTREACHED(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 prefs::kPowerUserActivityScreenDimDelayFactor, | 222 prefs::kPowerUserActivityScreenDimDelayFactor, |
| 223 2.0, | 223 2.0, |
| 224 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 224 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 225 registry->RegisterBooleanPref( | 225 registry->RegisterBooleanPref( |
| 226 prefs::kPowerWaitForInitialUserActivity, | 226 prefs::kPowerWaitForInitialUserActivity, |
| 227 false, | 227 false, |
| 228 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 228 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 229 } | 229 } |
| 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 |
| 233 // secondary user to an existing session. |
| 234 if (profile == profile_) |
| 235 return; |
| 236 |
| 232 profile_ = profile; | 237 profile_ = profile; |
| 233 pref_change_registrar_.reset(); | 238 pref_change_registrar_.reset(); |
| 234 | 239 |
| 235 if (!profile) { | 240 if (!profile) { |
| 236 power_policy_controller_->ClearPrefs(); | 241 power_policy_controller_->ClearPrefs(); |
| 237 return; | 242 return; |
| 238 } | 243 } |
| 239 | 244 |
| 240 base::Closure update_callback(base::Bind( | 245 base::Closure update_callback(base::Bind( |
| 241 &PowerPrefs::UpdatePowerPolicyFromPrefs, | 246 &PowerPrefs::UpdatePowerPolicyFromPrefs, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 270 update_callback); | 275 update_callback); |
| 271 pref_change_registrar_->Add(prefs::kPowerUserActivityScreenDimDelayFactor, | 276 pref_change_registrar_->Add(prefs::kPowerUserActivityScreenDimDelayFactor, |
| 272 update_callback); | 277 update_callback); |
| 273 pref_change_registrar_->Add(prefs::kPowerWaitForInitialUserActivity, | 278 pref_change_registrar_->Add(prefs::kPowerWaitForInitialUserActivity, |
| 274 update_callback); | 279 update_callback); |
| 275 | 280 |
| 276 UpdatePowerPolicyFromPrefs(); | 281 UpdatePowerPolicyFromPrefs(); |
| 277 } | 282 } |
| 278 | 283 |
| 279 } // namespace chromeos | 284 } // namespace chromeos |
| OLD | NEW |