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

Side by Side Diff: chrome/browser/ui/ash/session_state_delegate_chromeos.cc

Issue 2416253004: ash: Use session_manager::SessionState (Closed)
Patch Set: fix compile Created 4 years, 2 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
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_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 16 matching lines...) Expand all
27 #include "chromeos/login/login_state.h" 27 #include "chromeos/login/login_state.h"
28 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
29 #include "components/signin/core/account_id/account_id.h" 29 #include "components/signin/core/account_id/account_id.h"
30 #include "components/user_manager/user.h" 30 #include "components/user_manager/user.h"
31 #include "components/user_manager/user_info.h" 31 #include "components/user_manager/user_info.h"
32 #include "components/user_manager/user_manager.h" 32 #include "components/user_manager/user_manager.h"
33 #include "google_apis/gaia/gaia_auth_util.h" 33 #include "google_apis/gaia/gaia_auth_util.h"
34 #include "ui/gfx/image/image_skia.h" 34 #include "ui/gfx/image/image_skia.h"
35 35
36 SessionStateDelegateChromeos::SessionStateDelegateChromeos() 36 SessionStateDelegateChromeos::SessionStateDelegateChromeos()
37 : session_state_(SESSION_STATE_LOGIN_PRIMARY) { 37 : session_state_(ash::SessionState::LOGIN_PRIMARY) {
38 user_manager::UserManager::Get()->AddSessionStateObserver(this); 38 user_manager::UserManager::Get()->AddSessionStateObserver(this);
39 chromeos::UserAddingScreen::Get()->AddObserver(this); 39 chromeos::UserAddingScreen::Get()->AddObserver(this);
40 40
41 // LoginState is not initialized in unit_tests. 41 // LoginState is not initialized in unit_tests.
42 if (chromeos::LoginState::IsInitialized()) { 42 if (chromeos::LoginState::IsInitialized()) {
43 chromeos::LoginState::Get()->AddObserver(this); 43 chromeos::LoginState::Get()->AddObserver(this);
44 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ? 44 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn()
45 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, true); 45 ? ash::SessionState::ACTIVE
46 : ash::SessionState::LOGIN_PRIMARY,
47 true);
46 } 48 }
47 } 49 }
48 50
49 SessionStateDelegateChromeos::~SessionStateDelegateChromeos() { 51 SessionStateDelegateChromeos::~SessionStateDelegateChromeos() {
50 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); 52 user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
51 chromeos::UserAddingScreen::Get()->RemoveObserver(this); 53 chromeos::UserAddingScreen::Get()->RemoveObserver(this);
52 54
53 // LoginState is not initialized in unit_tests. 55 // LoginState is not initialized in unit_tests.
54 if (chromeos::LoginState::IsInitialized()) 56 if (chromeos::LoginState::IsInitialized())
55 chromeos::LoginState::Get()->RemoveObserver(this); 57 chromeos::LoginState::Get()->RemoveObserver(this);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 128 }
127 129
128 bool SessionStateDelegateChromeos::IsUserSessionBlocked() const { 130 bool SessionStateDelegateChromeos::IsUserSessionBlocked() const {
129 bool has_login_manager = base::CommandLine::ForCurrentProcess()->HasSwitch( 131 bool has_login_manager = base::CommandLine::ForCurrentProcess()->HasSwitch(
130 chromeos::switches::kLoginManager); 132 chromeos::switches::kLoginManager);
131 return (has_login_manager && !IsActiveUserSessionStarted()) || 133 return (has_login_manager && !IsActiveUserSessionStarted()) ||
132 IsScreenLocked() || 134 IsScreenLocked() ||
133 chromeos::UserAddingScreen::Get()->IsRunning(); 135 chromeos::UserAddingScreen::Get()->IsRunning();
134 } 136 }
135 137
136 ash::SessionStateDelegate::SessionState 138 ash::SessionState SessionStateDelegateChromeos::GetSessionState() const {
137 SessionStateDelegateChromeos::GetSessionState() const {
138 return session_state_; 139 return session_state_;
139 } 140 }
140 141
141 const user_manager::UserInfo* SessionStateDelegateChromeos::GetUserInfo( 142 const user_manager::UserInfo* SessionStateDelegateChromeos::GetUserInfo(
142 ash::UserIndex index) const { 143 ash::UserIndex index) const {
143 DCHECK_LT(index, NumberOfLoggedInUsers()); 144 DCHECK_LT(index, NumberOfLoggedInUsers());
144 return user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; 145 return user_manager::UserManager::Get()->GetLRULoggedInUsers()[index];
145 } 146 }
146 147
147 bool SessionStateDelegateChromeos::ShouldShowAvatar( 148 bool SessionStateDelegateChromeos::ShouldShowAvatar(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ash::SessionStateObserver* observer) { 225 ash::SessionStateObserver* observer) {
225 session_state_observer_list_.AddObserver(observer); 226 session_state_observer_list_.AddObserver(observer);
226 } 227 }
227 228
228 void SessionStateDelegateChromeos::RemoveSessionStateObserver( 229 void SessionStateDelegateChromeos::RemoveSessionStateObserver(
229 ash::SessionStateObserver* observer) { 230 ash::SessionStateObserver* observer) {
230 session_state_observer_list_.RemoveObserver(observer); 231 session_state_observer_list_.RemoveObserver(observer);
231 } 232 }
232 233
233 void SessionStateDelegateChromeos::LoggedInStateChanged() { 234 void SessionStateDelegateChromeos::LoggedInStateChanged() {
234 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ? 235 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn()
235 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, false); 236 ? ash::SessionState::ACTIVE
237 : ash::SessionState::LOGIN_PRIMARY,
238 false);
236 } 239 }
237 240
238 void SessionStateDelegateChromeos::ActiveUserChanged( 241 void SessionStateDelegateChromeos::ActiveUserChanged(
239 const user_manager::User* active_user) { 242 const user_manager::User* active_user) {
240 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_, 243 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_,
241 ActiveUserChanged(active_user->GetAccountId())); 244 ActiveUserChanged(active_user->GetAccountId()));
242 } 245 }
243 246
244 void SessionStateDelegateChromeos::UserAddedToSession( 247 void SessionStateDelegateChromeos::UserAddedToSession(
245 const user_manager::User* added_user) { 248 const user_manager::User* added_user) {
246 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_, 249 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_,
247 UserAddedToSession(added_user->GetAccountId())); 250 UserAddedToSession(added_user->GetAccountId()));
248 } 251 }
249 252
250 void SessionStateDelegateChromeos::OnUserAddingStarted() { 253 void SessionStateDelegateChromeos::OnUserAddingStarted() {
251 SetSessionState(SESSION_STATE_LOGIN_SECONDARY, false); 254 SetSessionState(ash::SessionState::LOGIN_SECONDARY, false);
252 } 255 }
253 256
254 void SessionStateDelegateChromeos::OnUserAddingFinished() { 257 void SessionStateDelegateChromeos::OnUserAddingFinished() {
255 SetSessionState(SESSION_STATE_ACTIVE, false); 258 SetSessionState(ash::SessionState::ACTIVE, false);
256 } 259 }
257 260
258 void SessionStateDelegateChromeos::SetSessionState(SessionState new_state, 261 void SessionStateDelegateChromeos::SetSessionState(ash::SessionState new_state,
259 bool force) { 262 bool force) {
260 if (session_state_ == new_state && !force) 263 if (session_state_ == new_state && !force)
261 return; 264 return;
262 265
263 session_state_ = new_state; 266 session_state_ = new_state;
264 NotifySessionStateChanged(); 267 NotifySessionStateChanged();
265 } 268 }
266 269
267 void SessionStateDelegateChromeos::NotifySessionStateChanged() { 270 void SessionStateDelegateChromeos::NotifySessionStateChanged() {
268 FOR_EACH_OBSERVER(ash::SessionStateObserver, 271 FOR_EACH_OBSERVER(ash::SessionStateObserver,
269 session_state_observer_list_, 272 session_state_observer_list_,
270 SessionStateChanged(session_state_)); 273 SessionStateChanged(session_state_));
271 } 274 }
272 275
273 void DoSwitchUser(const AccountId& account_id) { 276 void DoSwitchUser(const AccountId& account_id) {
274 user_manager::UserManager::Get()->SwitchActiveUser(account_id); 277 user_manager::UserManager::Get()->SwitchActiveUser(account_id);
275 } 278 }
276 279
277 void SessionStateDelegateChromeos::TryToSwitchUser( 280 void SessionStateDelegateChromeos::TryToSwitchUser(
278 const AccountId& account_id) { 281 const AccountId& account_id) {
279 TrySwitchingActiveUser(base::Bind(&DoSwitchUser, account_id)); 282 TrySwitchingActiveUser(base::Bind(&DoSwitchUser, account_id));
280 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698