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

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

Issue 2416253004: ash: Use session_manager::SessionState (Closed)
Patch Set: use session_manager::SessionState 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_(session_manager::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);
stevenjb 2016/10/17 22:59:34 We might want to add a comment here that we are on
xiyuan 2016/10/17 23:17:28 Added a comment. My goal is to replace SessionStat
44 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ? 44 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn()
45 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, true); 45 ? session_manager::SessionState::ACTIVE
46 : session_manager::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 session_manager::SessionState SessionStateDelegateChromeos::GetSessionState()
137 SessionStateDelegateChromeos::GetSessionState() const { 139 const {
138 return session_state_; 140 return session_state_;
139 } 141 }
140 142
141 const user_manager::UserInfo* SessionStateDelegateChromeos::GetUserInfo( 143 const user_manager::UserInfo* SessionStateDelegateChromeos::GetUserInfo(
142 ash::UserIndex index) const { 144 ash::UserIndex index) const {
143 DCHECK_LT(index, NumberOfLoggedInUsers()); 145 DCHECK_LT(index, NumberOfLoggedInUsers());
144 return user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; 146 return user_manager::UserManager::Get()->GetLRULoggedInUsers()[index];
145 } 147 }
146 148
147 bool SessionStateDelegateChromeos::ShouldShowAvatar( 149 bool SessionStateDelegateChromeos::ShouldShowAvatar(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ash::SessionStateObserver* observer) { 226 ash::SessionStateObserver* observer) {
225 session_state_observer_list_.AddObserver(observer); 227 session_state_observer_list_.AddObserver(observer);
226 } 228 }
227 229
228 void SessionStateDelegateChromeos::RemoveSessionStateObserver( 230 void SessionStateDelegateChromeos::RemoveSessionStateObserver(
229 ash::SessionStateObserver* observer) { 231 ash::SessionStateObserver* observer) {
230 session_state_observer_list_.RemoveObserver(observer); 232 session_state_observer_list_.RemoveObserver(observer);
231 } 233 }
232 234
233 void SessionStateDelegateChromeos::LoggedInStateChanged() { 235 void SessionStateDelegateChromeos::LoggedInStateChanged() {
234 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ? 236 SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn()
235 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, false); 237 ? session_manager::SessionState::ACTIVE
238 : session_manager::SessionState::LOGIN_PRIMARY,
239 false);
236 } 240 }
237 241
238 void SessionStateDelegateChromeos::ActiveUserChanged( 242 void SessionStateDelegateChromeos::ActiveUserChanged(
239 const user_manager::User* active_user) { 243 const user_manager::User* active_user) {
240 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_, 244 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_,
241 ActiveUserChanged(active_user->GetAccountId())); 245 ActiveUserChanged(active_user->GetAccountId()));
242 } 246 }
243 247
244 void SessionStateDelegateChromeos::UserAddedToSession( 248 void SessionStateDelegateChromeos::UserAddedToSession(
245 const user_manager::User* added_user) { 249 const user_manager::User* added_user) {
246 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_, 250 FOR_EACH_OBSERVER(ash::SessionStateObserver, session_state_observer_list_,
247 UserAddedToSession(added_user->GetAccountId())); 251 UserAddedToSession(added_user->GetAccountId()));
248 } 252 }
249 253
250 void SessionStateDelegateChromeos::OnUserAddingStarted() { 254 void SessionStateDelegateChromeos::OnUserAddingStarted() {
251 SetSessionState(SESSION_STATE_LOGIN_SECONDARY, false); 255 SetSessionState(session_manager::SessionState::LOGIN_SECONDARY, false);
252 } 256 }
253 257
254 void SessionStateDelegateChromeos::OnUserAddingFinished() { 258 void SessionStateDelegateChromeos::OnUserAddingFinished() {
255 SetSessionState(SESSION_STATE_ACTIVE, false); 259 SetSessionState(session_manager::SessionState::ACTIVE, false);
256 } 260 }
257 261
258 void SessionStateDelegateChromeos::SetSessionState(SessionState new_state, 262 void SessionStateDelegateChromeos::SetSessionState(
259 bool force) { 263 session_manager::SessionState new_state,
264 bool force) {
260 if (session_state_ == new_state && !force) 265 if (session_state_ == new_state && !force)
261 return; 266 return;
262 267
263 session_state_ = new_state; 268 session_state_ = new_state;
264 NotifySessionStateChanged(); 269 NotifySessionStateChanged();
265 } 270 }
266 271
267 void SessionStateDelegateChromeos::NotifySessionStateChanged() { 272 void SessionStateDelegateChromeos::NotifySessionStateChanged() {
268 FOR_EACH_OBSERVER(ash::SessionStateObserver, 273 FOR_EACH_OBSERVER(ash::SessionStateObserver,
269 session_state_observer_list_, 274 session_state_observer_list_,
270 SessionStateChanged(session_state_)); 275 SessionStateChanged(session_state_));
271 } 276 }
272 277
273 void DoSwitchUser(const AccountId& account_id) { 278 void DoSwitchUser(const AccountId& account_id) {
274 user_manager::UserManager::Get()->SwitchActiveUser(account_id); 279 user_manager::UserManager::Get()->SwitchActiveUser(account_id);
275 } 280 }
276 281
277 void SessionStateDelegateChromeos::TryToSwitchUser( 282 void SessionStateDelegateChromeos::TryToSwitchUser(
278 const AccountId& account_id) { 283 const AccountId& account_id) {
279 TrySwitchingActiveUser(base::Bind(&DoSwitchUser, account_id)); 284 TrySwitchingActiveUser(base::Bind(&DoSwitchUser, account_id));
280 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698