| 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/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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/chromeos/login/screen_locker.h" | 12 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 13 #include "chrome/browser/chromeos/login/user.h" | 13 #include "chrome/browser/chromeos/login/user.h" |
| 14 #include "chrome/browser/chromeos/login/user_adding_screen.h" | 14 #include "chrome/browser/chromeos/login/user_adding_screen.h" |
| 15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return (has_login_manager && !IsActiveUserSessionStarted()) || | 125 return (has_login_manager && !IsActiveUserSessionStarted()) || |
| 126 IsScreenLocked() || | 126 IsScreenLocked() || |
| 127 chromeos::UserAddingScreen::Get()->IsRunning(); | 127 chromeos::UserAddingScreen::Get()->IsRunning(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 ash::SessionStateDelegate::SessionState | 130 ash::SessionStateDelegate::SessionState |
| 131 SessionStateDelegateChromeos::GetSessionState() const { | 131 SessionStateDelegateChromeos::GetSessionState() const { |
| 132 return session_state_; | 132 return session_state_; |
| 133 } | 133 } |
| 134 | 134 |
| 135 const base::string16 SessionStateDelegateChromeos::GetUserDisplayName( | 135 const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo( |
| 136 ash::MultiProfileIndex index) const { | 136 ash::MultiProfileIndex index) const { |
| 137 DCHECK_LT(index, NumberOfLoggedInUsers()); | 137 DCHECK_LT(index, NumberOfLoggedInUsers()); |
| 138 return chromeos::UserManager::Get()-> | 138 return chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; |
| 139 GetLRULoggedInUsers()[index]->display_name(); | |
| 140 } | 139 } |
| 141 | 140 |
| 142 const base::string16 SessionStateDelegateChromeos::GetUserGivenName( | 141 const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo( |
| 143 ash::MultiProfileIndex index) const { | |
| 144 DCHECK_LT(index, NumberOfLoggedInUsers()); | |
| 145 return chromeos::UserManager::Get() | |
| 146 ->GetLRULoggedInUsers()[index] | |
| 147 ->given_name(); | |
| 148 } | |
| 149 | |
| 150 const std::string SessionStateDelegateChromeos::GetUserEmail( | |
| 151 ash::MultiProfileIndex index) const { | |
| 152 DCHECK_LT(index, NumberOfLoggedInUsers()); | |
| 153 return chromeos::UserManager::Get()-> | |
| 154 GetLRULoggedInUsers()[index]->display_email(); | |
| 155 } | |
| 156 | |
| 157 const std::string SessionStateDelegateChromeos::GetUserID( | |
| 158 ash::MultiProfileIndex index) const { | |
| 159 DCHECK_LT(index, NumberOfLoggedInUsers()); | |
| 160 return gaia::CanonicalizeEmail(gaia::SanitizeEmail( | |
| 161 chromeos::UserManager::Get()-> | |
| 162 GetLRULoggedInUsers()[index]->email())); | |
| 163 } | |
| 164 | |
| 165 const gfx::ImageSkia& SessionStateDelegateChromeos::GetUserImage( | |
| 166 content::BrowserContext* context) const { | 142 content::BrowserContext* context) const { |
| 167 DCHECK(context); | 143 DCHECK(context); |
| 168 return chromeos::UserManager::Get()->GetUserByProfile( | 144 return chromeos::UserManager::Get()->GetUserByProfile( |
| 169 Profile::FromBrowserContext(context))->image(); | 145 Profile::FromBrowserContext(context)); |
| 170 } | 146 } |
| 171 | 147 |
| 172 bool SessionStateDelegateChromeos::ShouldShowAvatar(aura::Window* window) { | 148 bool SessionStateDelegateChromeos::ShouldShowAvatar( |
| 149 aura::Window* window) const { |
| 173 return chrome::MultiUserWindowManager::GetInstance()-> | 150 return chrome::MultiUserWindowManager::GetInstance()-> |
| 174 ShouldShowAvatar(window); | 151 ShouldShowAvatar(window); |
| 175 } | 152 } |
| 176 | 153 |
| 177 void SessionStateDelegateChromeos::SwitchActiveUser( | 154 void SessionStateDelegateChromeos::SwitchActiveUser( |
| 178 const std::string& user_id) { | 155 const std::string& user_id) { |
| 179 // Disallow switching to an already active user since that might crash. | 156 // Disallow switching to an already active user since that might crash. |
| 180 // Also check that we got a user id and not an email address. | 157 // Also check that we got a user id and not an email address. |
| 181 DCHECK_EQ(user_id, | 158 DCHECK_EQ(user_id, |
| 182 gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id))); | 159 gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id))); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 248 |
| 272 session_state_ = new_state; | 249 session_state_ = new_state; |
| 273 NotifySessionStateChanged(); | 250 NotifySessionStateChanged(); |
| 274 } | 251 } |
| 275 | 252 |
| 276 void SessionStateDelegateChromeos::NotifySessionStateChanged() { | 253 void SessionStateDelegateChromeos::NotifySessionStateChanged() { |
| 277 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 254 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 278 session_state_observer_list_, | 255 session_state_observer_list_, |
| 279 SessionStateChanged(session_state_)); | 256 SessionStateChanged(session_state_)); |
| 280 } | 257 } |
| OLD | NEW |