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

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

Issue 15718003: Add SessionStateObserver with ActiveUserChanged() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge & add SessionStateDelegateChromeos Created 7 years, 6 months 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
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.h" 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h"
6 6
7 #include "ash/session_state_observer.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "chrome/browser/chromeos/login/screen_locker.h" 9 #include "chrome/browser/chromeos/login/screen_locker.h"
10 #include "chrome/browser/chromeos/login/user.h"
9 #include "chrome/browser/chromeos/login/user_manager.h" 11 #include "chrome/browser/chromeos/login/user_manager.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 12 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "chromeos/dbus/session_manager_client.h" 13 #include "chromeos/dbus/session_manager_client.h"
12 14
13 SessionStateDelegate::SessionStateDelegate() { 15 SessionStateDelegateChromeos::SessionStateDelegateChromeos() {
16 chromeos::UserManager::Get()->AddSessionStateObserver(this);
14 } 17 }
15 18
16 SessionStateDelegate::~SessionStateDelegate() { 19 SessionStateDelegateChromeos::~SessionStateDelegateChromeos() {
17 } 20 }
18 21
19 int SessionStateDelegate::GetMaximumNumberOfLoggedInUsers() const { 22 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const {
20 return 3; 23 return 3;
21 } 24 }
22 25
23 int SessionStateDelegate::NumberOfLoggedInUsers() const { 26 int SessionStateDelegateChromeos::NumberOfLoggedInUsers() const {
24 return chromeos::UserManager::Get()->GetLoggedInUsers().size(); 27 return chromeos::UserManager::Get()->GetLoggedInUsers().size();
25 } 28 }
26 29
27 bool SessionStateDelegate::IsActiveUserSessionStarted() const { 30 bool SessionStateDelegateChromeos::IsActiveUserSessionStarted() const {
28 return chromeos::UserManager::Get()->IsSessionStarted(); 31 return chromeos::UserManager::Get()->IsSessionStarted();
29 } 32 }
30 33
31 bool SessionStateDelegate::CanLockScreen() const { 34 bool SessionStateDelegateChromeos::CanLockScreen() const {
32 return chromeos::UserManager::Get()->CanCurrentUserLock(); 35 return chromeos::UserManager::Get()->CanCurrentUserLock();
33 } 36 }
34 37
35 bool SessionStateDelegate::IsScreenLocked() const { 38 bool SessionStateDelegateChromeos::IsScreenLocked() const {
36 return chromeos::ScreenLocker::default_screen_locker() && 39 return chromeos::ScreenLocker::default_screen_locker() &&
37 chromeos::ScreenLocker::default_screen_locker()->locked(); 40 chromeos::ScreenLocker::default_screen_locker()->locked();
38 } 41 }
39 42
40 void SessionStateDelegate::LockScreen() { 43 void SessionStateDelegateChromeos::LockScreen() {
41 if (!CanLockScreen()) 44 if (!CanLockScreen())
42 return; 45 return;
43 46
44 // TODO(antrim): Additional logging for http://crbug.com/173178. 47 // TODO(antrim): Additional logging for http://crbug.com/173178.
45 LOG(WARNING) << "Requesting screen lock from SessionStateDelegate"; 48 LOG(WARNING) << "Requesting screen lock from SessionStateDelegate";
46 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 49 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
47 RequestLockScreen(); 50 RequestLockScreen();
48 } 51 }
49 52
50 void SessionStateDelegate::UnlockScreen() { 53 void SessionStateDelegateChromeos::UnlockScreen() {
51 // This is used only for testing thus far. 54 // This is used only for testing thus far.
52 NOTIMPLEMENTED(); 55 NOTIMPLEMENTED();
53 } 56 }
54 57
55 const base::string16 SessionStateDelegate::GetUserDisplayName( 58 const base::string16 SessionStateDelegateChromeos::GetUserDisplayName(
56 ash::MultiProfileIndex index) const { 59 ash::MultiProfileIndex index) const {
57 DCHECK_LT(index, NumberOfLoggedInUsers()); 60 DCHECK_LT(index, NumberOfLoggedInUsers());
58 return chromeos::UserManager::Get()-> 61 return chromeos::UserManager::Get()->
59 GetLRULoggedInUsers()[index]->display_name(); 62 GetLRULoggedInUsers()[index]->display_name();
60 } 63 }
61 64
62 const std::string SessionStateDelegate::GetUserEmail( 65 const std::string SessionStateDelegateChromeos::GetUserEmail(
63 ash::MultiProfileIndex index) const { 66 ash::MultiProfileIndex index) const {
64 DCHECK_LT(index, NumberOfLoggedInUsers()); 67 DCHECK_LT(index, NumberOfLoggedInUsers());
65 return chromeos::UserManager::Get()-> 68 return chromeos::UserManager::Get()->
66 GetLRULoggedInUsers()[index]->display_email(); 69 GetLRULoggedInUsers()[index]->display_email();
67 } 70 }
68 71
69 const gfx::ImageSkia& SessionStateDelegate::GetUserImage( 72 const gfx::ImageSkia& SessionStateDelegateChromeos::GetUserImage(
70 ash::MultiProfileIndex index) const { 73 ash::MultiProfileIndex index) const {
71 DCHECK_LT(index, NumberOfLoggedInUsers()); 74 DCHECK_LT(index, NumberOfLoggedInUsers());
72 return chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]->image(); 75 return chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]->image();
73 } 76 }
74 77
75 void SessionStateDelegate::GetLoggedInUsers( 78 void SessionStateDelegateChromeos::GetLoggedInUsers(ash::UserIdList* users) {
76 ash::UserEmailList* users) {
77 const chromeos::UserList& logged_in_users = 79 const chromeos::UserList& logged_in_users =
78 chromeos::UserManager::Get()->GetLoggedInUsers(); 80 chromeos::UserManager::Get()->GetLoggedInUsers();
79 for (chromeos::UserList::const_iterator it = logged_in_users.begin(); 81 for (chromeos::UserList::const_iterator it = logged_in_users.begin();
80 it != logged_in_users.end(); ++it) { 82 it != logged_in_users.end(); ++it) {
81 const chromeos::User* user = (*it); 83 const chromeos::User* user = (*it);
82 users->push_back(user->email()); 84 users->push_back(user->email());
83 } 85 }
84 } 86 }
85 87
86 void SessionStateDelegate::SwitchActiveUser(const std::string& email) { 88 void SessionStateDelegateChromeos::SwitchActiveUser(
87 chromeos::UserManager::Get()->SwitchActiveUser(email); 89 const std::string& user_id) {
90 chromeos::UserManager::Get()->SwitchActiveUser(user_id);
88 } 91 }
92
93 void SessionStateDelegateChromeos::AddSessionStateObserver(
94 ash::SessionStateObserver* observer) {
95 session_state_observer_list_.AddObserver(observer);
96 }
97
98 void SessionStateDelegateChromeos::RemoveSessionStateObserver(
99 ash::SessionStateObserver* observer) {
100 session_state_observer_list_.RemoveObserver(observer);
101 }
102
103 void SessionStateDelegateChromeos::ActiveUserChanged(
104 const chromeos::User* active_user) {
105 FOR_EACH_OBSERVER(ash::SessionStateObserver,
106 session_state_observer_list_,
107 ActiveUserChanged(active_user->email()));
108 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/session_state_delegate_chromeos.h ('k') | chrome/browser/ui/ash/session_state_delegate_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698