Chromium Code Reviews| 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_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" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/dbus/session_manager_client.h" | 22 #include "chromeos/dbus/session_manager_client.h" |
| 23 #include "google_apis/gaia/gaia_auth_util.h" | 23 #include "google_apis/gaia/gaia_auth_util.h" |
| 24 | 24 |
| 25 SessionStateDelegateChromeos::SessionStateDelegateChromeos() { | 25 SessionStateDelegateChromeos::SessionStateDelegateChromeos() |
| 26 : state_(STATE_UNKNOWN) { | |
| 26 chromeos::UserManager::Get()->AddSessionStateObserver(this); | 27 chromeos::UserManager::Get()->AddSessionStateObserver(this); |
| 28 chromeos::UserAddingScreen::Get()->AddObserver(this); | |
| 27 } | 29 } |
| 28 | 30 |
| 29 SessionStateDelegateChromeos::~SessionStateDelegateChromeos() { | 31 SessionStateDelegateChromeos::~SessionStateDelegateChromeos() { |
| 32 chromeos::UserManager::Get()->RemoveSessionStateObserver(this); | |
| 33 chromeos::UserAddingScreen::Get()->RemoveObserver(this); | |
| 30 } | 34 } |
| 31 | 35 |
| 32 content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex( | 36 content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex( |
| 33 ash::MultiProfileIndex index) { | 37 ash::MultiProfileIndex index) { |
| 34 DCHECK_LT(index, NumberOfLoggedInUsers()); | 38 DCHECK_LT(index, NumberOfLoggedInUsers()); |
| 35 chromeos::User* user = | 39 chromeos::User* user = |
| 36 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; | 40 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; |
| 37 DCHECK(user); | 41 DCHECK(user); |
| 38 return chromeos::UserManager::Get()->GetProfileByUser(user); | 42 return chromeos::UserManager::Get()->GetProfileByUser(user); |
| 39 } | 43 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 session_state_observer_list_.AddObserver(observer); | 207 session_state_observer_list_.AddObserver(observer); |
| 204 } | 208 } |
| 205 | 209 |
| 206 void SessionStateDelegateChromeos::RemoveSessionStateObserver( | 210 void SessionStateDelegateChromeos::RemoveSessionStateObserver( |
| 207 ash::SessionStateObserver* observer) { | 211 ash::SessionStateObserver* observer) { |
| 208 session_state_observer_list_.RemoveObserver(observer); | 212 session_state_observer_list_.RemoveObserver(observer); |
| 209 } | 213 } |
| 210 | 214 |
| 211 void SessionStateDelegateChromeos::ActiveUserChanged( | 215 void SessionStateDelegateChromeos::ActiveUserChanged( |
| 212 const chromeos::User* active_user) { | 216 const chromeos::User* active_user) { |
| 217 SetSessionState(STATE_SESSION); | |
| 213 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 218 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 214 session_state_observer_list_, | 219 session_state_observer_list_, |
| 215 ActiveUserChanged(active_user->email())); | 220 ActiveUserChanged(active_user->email())); |
| 216 } | 221 } |
| 217 | 222 |
| 218 void SessionStateDelegateChromeos::UserAddedToSession( | 223 void SessionStateDelegateChromeos::UserAddedToSession( |
| 219 const chromeos::User* added_user) { | 224 const chromeos::User* added_user) { |
| 225 SetSessionState(STATE_SESSION); | |
| 220 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 226 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 221 session_state_observer_list_, | 227 session_state_observer_list_, |
| 222 UserAddedToSession(added_user->email())); | 228 UserAddedToSession(added_user->email())); |
| 223 } | 229 } |
| 230 | |
| 231 void SessionStateDelegateChromeos::OnUserAddingStarted() { | |
| 232 SetSessionState(STATE_LOGIN_SECONDARY); | |
| 233 } | |
| 234 | |
| 235 void SessionStateDelegateChromeos::OnUserAddingFinished() { | |
|
Mr4D (OOO till 08-26)
2014/04/10 01:33:08
Do we also get here if the user cancels out of the
Nikita (slow)
2014/04/10 09:52:21
Yes.
| |
| 236 SetSessionState(STATE_SESSION); | |
| 237 } | |
| 238 | |
| 239 void SessionStateDelegateChromeos::SetSessionState(SessionState new_state) { | |
| 240 if (state_ == new_state) | |
| 241 return; | |
| 242 | |
| 243 state_ = new_state; | |
| 244 NotifySessionStateChanged(); | |
| 245 } | |
| 246 | |
| 247 void SessionStateDelegateChromeos::NotifySessionStateChanged() { | |
| 248 FOR_EACH_OBSERVER(ash::SessionStateObserver, | |
| 249 session_state_observer_list_, | |
| 250 SessionStateChanged(state_)); | |
| 251 } | |
| OLD | NEW |