Chromium Code Reviews| Index: chrome/browser/ui/ash/session_state_delegate_chromeos.cc |
| diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc |
| index 24936e92002d982118004c262589a074eb8fdfd3..131b2e545be924354c44d4e67127cbc85ba78539 100644 |
| --- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc |
| +++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc |
| @@ -10,14 +10,19 @@ |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/session_manager_client.h" |
| +// TODO(skuhne): To be able to test this I had to hardcode the number of known |
| +// users. Get rid of it once it works. |
| +#define ADD_TEST_USER_ACCOUNTS_FOR_MULTI_USER_TEST_ENVIRONMENT 1 |
|
Mr4D (OOO till 08-26)
2013/05/17 04:08:33
As mentioned in my CL comment, this define is only
James Cook
2013/05/17 14:03:25
That's fine.
|
| + |
| SessionStateDelegate::SessionStateDelegate() { |
| } |
| SessionStateDelegate::~SessionStateDelegate() { |
| } |
| -bool SessionStateDelegate::HasActiveUser() const { |
| - return chromeos::UserManager::Get()->IsUserLoggedIn(); |
| +int SessionStateDelegate::NumberOfLoggedInUsers() const { |
| + return chromeos::UserManager::Get()->GetLoggedInUsers().size() + |
|
James Cook
2013/05/17 14:03:25
Does this mean that all canary build users will se
Mr4D (OOO till 08-26)
2013/05/17 16:26:40
Just with the flag turned on. But again - before s
|
| + ADD_TEST_USER_ACCOUNTS_FOR_MULTI_USER_TEST_ENVIRONMENT; |
| } |
| bool SessionStateDelegate::IsActiveUserSessionStarted() const { |
| @@ -47,3 +52,47 @@ void SessionStateDelegate::UnlockScreen() { |
| // This is used only for testing thus far. |
| NOTIMPLEMENTED(); |
| } |
| + |
| +const base::string16 SessionStateDelegate::GetUserDisplayName( |
| + ash::MultiProfileIndex index) const { |
| + if (ADD_TEST_USER_ACCOUNTS_FOR_MULTI_USER_TEST_ENVIRONMENT && |
| + index >= (int)chromeos::UserManager::Get()->GetLoggedInUsers().size()) |
|
James Cook
2013/05/17 14:03:25
(int) -> static_cast<int>()
It hurts, but casting
Mr4D (OOO till 08-26)
2013/05/17 16:26:40
Done.
|
| + index = 0; |
| + DCHECK_LT(index, NumberOfLoggedInUsers()); |
| + return chromeos::UserManager::Get()->GetLRULoggedInUsers()[ |
| + index]->display_name(); |
| +} |
| + |
| +const std::string SessionStateDelegate::GetUserEmail( |
| + ash::MultiProfileIndex index) const { |
| + if (ADD_TEST_USER_ACCOUNTS_FOR_MULTI_USER_TEST_ENVIRONMENT && |
| + index >= (int)chromeos::UserManager::Get()->GetLoggedInUsers().size()) |
| + index = 0; |
| + DCHECK_LT(index, NumberOfLoggedInUsers()); |
| + return chromeos::UserManager::Get()->GetLRULoggedInUsers()[ |
| + index]->display_email(); |
| +} |
| + |
| +const gfx::ImageSkia& SessionStateDelegate::GetUserImage( |
| + ash::MultiProfileIndex index) const { |
| + if (ADD_TEST_USER_ACCOUNTS_FOR_MULTI_USER_TEST_ENVIRONMENT && |
| + index >= (int)chromeos::UserManager::Get()->GetLoggedInUsers().size()) |
| + index = 0; |
| + DCHECK_LT(index, NumberOfLoggedInUsers()); |
| + return chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]->image(); |
| +} |
| + |
| +void SessionStateDelegate::GetLoggedInUsers( |
| + ash::UserEmailList* users) { |
| + const chromeos::UserList& logged_in_users = |
| + chromeos::UserManager::Get()->GetLoggedInUsers(); |
| + for (chromeos::UserList::const_iterator it = logged_in_users.begin(); |
| + it != logged_in_users.end(); ++it) { |
| + const chromeos::User* user = (*it); |
| + users->push_back(user->email()); |
| + } |
| +} |
| + |
| +void SessionStateDelegate::SwitchActiveUser(const std::string& email) { |
| + chromeos::UserManager::Get()->SwitchActiveUser(email); |
| +} |