| 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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/session/session_state_observer.h" | 8 #include "ash/common/session/session_state_observer.h" |
| 9 #include "ash/content/shell_content_state.h" | 9 #include "ash/content/shell_content_state.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 session_state_observer_list_.RemoveObserver(observer); | 230 session_state_observer_list_.RemoveObserver(observer); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void SessionStateDelegateChromeos::LoggedInStateChanged() { | 233 void SessionStateDelegateChromeos::LoggedInStateChanged() { |
| 234 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ? | 234 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ? |
| 235 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, false); | 235 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, false); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void SessionStateDelegateChromeos::ActiveUserChanged( | 238 void SessionStateDelegateChromeos::ActiveUserChanged( |
| 239 const user_manager::User* active_user) { | 239 const user_manager::User* active_user) { |
| 240 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_, | 240 for (ash::SessionStateObserver& observer : session_state_observer_list_) |
| 241 ActiveUserChanged(active_user->GetAccountId())); | 241 observer.ActiveUserChanged(active_user->GetAccountId()); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void SessionStateDelegateChromeos::UserAddedToSession( | 244 void SessionStateDelegateChromeos::UserAddedToSession( |
| 245 const user_manager::User* added_user) { | 245 const user_manager::User* added_user) { |
| 246 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_, | 246 for (ash::SessionStateObserver& observer : session_state_observer_list_) |
| 247 UserAddedToSession(added_user->GetAccountId())); | 247 observer.UserAddedToSession(added_user->GetAccountId()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void SessionStateDelegateChromeos::OnUserAddingStarted() { | 250 void SessionStateDelegateChromeos::OnUserAddingStarted() { |
| 251 SetSessionState(SESSION_STATE_LOGIN_SECONDARY, false); | 251 SetSessionState(SESSION_STATE_LOGIN_SECONDARY, false); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void SessionStateDelegateChromeos::OnUserAddingFinished() { | 254 void SessionStateDelegateChromeos::OnUserAddingFinished() { |
| 255 SetSessionState(SESSION_STATE_ACTIVE, false); | 255 SetSessionState(SESSION_STATE_ACTIVE, false); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void SessionStateDelegateChromeos::SetSessionState(SessionState new_state, | 258 void SessionStateDelegateChromeos::SetSessionState(SessionState new_state, |
| 259 bool force) { | 259 bool force) { |
| 260 if (session_state_ == new_state && !force) | 260 if (session_state_ == new_state && !force) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 session_state_ = new_state; | 263 session_state_ = new_state; |
| 264 NotifySessionStateChanged(); | 264 NotifySessionStateChanged(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void SessionStateDelegateChromeos::NotifySessionStateChanged() { | 267 void SessionStateDelegateChromeos::NotifySessionStateChanged() { |
| 268 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 268 for (ash::SessionStateObserver& observer : session_state_observer_list_) |
| 269 session_state_observer_list_, | 269 observer.SessionStateChanged(session_state_); |
| 270 SessionStateChanged(session_state_)); | |
| 271 } | 270 } |
| 272 | 271 |
| 273 void DoSwitchUser(const AccountId& account_id) { | 272 void DoSwitchUser(const AccountId& account_id) { |
| 274 user_manager::UserManager::Get()->SwitchActiveUser(account_id); | 273 user_manager::UserManager::Get()->SwitchActiveUser(account_id); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void SessionStateDelegateChromeos::TryToSwitchUser( | 276 void SessionStateDelegateChromeos::TryToSwitchUser( |
| 278 const AccountId& account_id) { | 277 const AccountId& account_id) { |
| 279 TrySwitchingActiveUser(base::Bind(&DoSwitchUser, account_id)); | 278 TrySwitchingActiveUser(base::Bind(&DoSwitchUser, account_id)); |
| 280 } | 279 } |
| OLD | NEW |