Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/ui/ash/session_state_delegate_chromeos.cc

Issue 83543004: cros: Use first unlock user's pref for locking screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
Mr4D (OOO till 08-26) 2013/11/22 23:30:51 As long as there is at least one user, he should b
Daniel Erat 2013/11/22 23:39:41 my question was actually about whether it's possib
47 DCHECK_EQ(1u, unlock_users.size());
Daniel Erat 2013/11/22 23:14:47 is this _EQ correct, or should it be DCHECK_LE(unl
xiyuan 2013/11/22 23:46:13 Good catch. I did not realize this could be called
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_EQ(1u, unlock_users.size());
Daniel Erat 2013/11/22 23:14:47 same question here
xiyuan 2013/11/22 23:46:13 Done.
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698