OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/ui/ash/session_state_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" |
6 | 6 |
7 #include "ash/multi_profile_uma.h" | 7 #include "ash/multi_profile_uma.h" |
8 #include "ash/session_state_observer.h" | 8 #include "ash/session_state_observer.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 int SessionStateDelegateChromeos::NumberOfLoggedInUsers() const { | 36 int SessionStateDelegateChromeos::NumberOfLoggedInUsers() const { |
37 return chromeos::UserManager::Get()->GetLoggedInUsers().size(); | 37 return chromeos::UserManager::Get()->GetLoggedInUsers().size(); |
38 } | 38 } |
39 | 39 |
40 bool SessionStateDelegateChromeos::IsActiveUserSessionStarted() const { | 40 bool SessionStateDelegateChromeos::IsActiveUserSessionStarted() const { |
41 return chromeos::UserManager::Get()->IsSessionStarted(); | 41 return chromeos::UserManager::Get()->IsSessionStarted(); |
42 } | 42 } |
43 | 43 |
44 bool SessionStateDelegateChromeos::CanLockScreen() const { | 44 bool SessionStateDelegateChromeos::CanLockScreen() const { |
45 return chromeos::UserManager::Get()->CanCurrentUserLock(); | 45 const chromeos::UserList unlock_users = |
| 46 chromeos::UserManager::Get()->GetUnlockUsers(); |
| 47 DCHECK_LE(unlock_users.size(), 1u); |
| 48 return !unlock_users.empty() && unlock_users[0]->can_lock(); |
46 } | 49 } |
47 | 50 |
48 bool SessionStateDelegateChromeos::IsScreenLocked() const { | 51 bool SessionStateDelegateChromeos::IsScreenLocked() const { |
49 return chromeos::ScreenLocker::default_screen_locker() && | 52 return chromeos::ScreenLocker::default_screen_locker() && |
50 chromeos::ScreenLocker::default_screen_locker()->locked(); | 53 chromeos::ScreenLocker::default_screen_locker()->locked(); |
51 } | 54 } |
52 | 55 |
53 bool SessionStateDelegateChromeos::ShouldLockScreenBeforeSuspending() const { | 56 bool SessionStateDelegateChromeos::ShouldLockScreenBeforeSuspending() const { |
54 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 57 const chromeos::UserList unlock_users = |
| 58 chromeos::UserManager::Get()->GetUnlockUsers(); |
| 59 DCHECK_LE(unlock_users.size(), 1u); |
| 60 Profile* profile = |
| 61 !unlock_users.empty() |
| 62 ? chromeos::UserManager::Get()->GetProfileByUser(unlock_users[0]) |
| 63 : NULL; |
55 return profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock); | 64 return profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock); |
56 } | 65 } |
57 | 66 |
58 void SessionStateDelegateChromeos::LockScreen() { | 67 void SessionStateDelegateChromeos::LockScreen() { |
59 if (!CanLockScreen()) | 68 if (!CanLockScreen()) |
60 return; | 69 return; |
61 | 70 |
62 VLOG(1) << "Requesting screen lock from SessionStateDelegate"; | 71 VLOG(1) << "Requesting screen lock from SessionStateDelegate"; |
63 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 72 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
64 RequestLockScreen(); | 73 RequestLockScreen(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 session_state_observer_list_, | 203 session_state_observer_list_, |
195 ActiveUserChanged(active_user->email())); | 204 ActiveUserChanged(active_user->email())); |
196 } | 205 } |
197 | 206 |
198 void SessionStateDelegateChromeos::UserAddedToSession( | 207 void SessionStateDelegateChromeos::UserAddedToSession( |
199 const chromeos::User* added_user) { | 208 const chromeos::User* added_user) { |
200 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 209 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
201 session_state_observer_list_, | 210 session_state_observer_list_, |
202 UserAddedToSession(added_user->email())); | 211 UserAddedToSession(added_user->email())); |
203 } | 212 } |
OLD | NEW |