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

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: UserIdList > UserEmailList 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.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 SessionStateDelegate::SessionStateDelegate() {
16 chromeos::UserManager::Get()->AddSessionStateObserver(this);
14 } 17 }
15 18
16 SessionStateDelegate::~SessionStateDelegate() { 19 SessionStateDelegate::~SessionStateDelegate() {
17 } 20 }
18 21
19 int SessionStateDelegate::GetMaximumNumberOfLoggedInUsers() const { 22 int SessionStateDelegate::GetMaximumNumberOfLoggedInUsers() const {
20 return 3; 23 return 3;
21 } 24 }
22 25
23 int SessionStateDelegate::NumberOfLoggedInUsers() const { 26 int SessionStateDelegate::NumberOfLoggedInUsers() const {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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& SessionStateDelegate::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 SessionStateDelegate::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 SessionStateDelegate::SwitchActiveUser(const std::string& user_id) {
87 chromeos::UserManager::Get()->SwitchActiveUser(email); 89 chromeos::UserManager::Get()->SwitchActiveUser(user_id);
88 } 90 }
91
92 void SessionStateDelegate::AddSessionStateObserver(
93 ash::SessionStateObserver* observer) {
94 session_state_observer_list_.AddObserver(observer);
95 }
96
97 void SessionStateDelegate::RemoveSessionStateObserver(
98 ash::SessionStateObserver* observer) {
99 session_state_observer_list_.RemoveObserver(observer);
100 }
101
102 void SessionStateDelegate::ActiveUserChanged(
103 const chromeos::User* active_user) {
104 FOR_EACH_OBSERVER(ash::SessionStateObserver,
105 session_state_observer_list_,
106 ActiveUserChanged(active_user->email()));
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698