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

Side by Side Diff: ash/common/system/user/tray_user.cc

Issue 2797743002: ash: Merge LoginStatus update code path (Closed)
Patch Set: for #2 comments Created 3 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/common/system/user/tray_user.h" 5 #include "ash/common/system/user/tray_user.h"
6 6
7 #include "ash/common/session/session_controller.h" 7 #include "ash/common/session/session_controller.h"
8 #include "ash/common/shelf/wm_shelf_util.h" 8 #include "ash/common/shelf/wm_shelf_util.h"
9 #include "ash/common/system/tray/system_tray.h" 9 #include "ash/common/system/tray/system_tray.h"
10 #include "ash/common/system/tray/system_tray_delegate.h" 10 #include "ash/common/system/tray/system_tray_delegate.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const SessionController* const session_controller = 218 const SessionController* const session_controller =
219 Shell::Get()->session_controller(); 219 Shell::Get()->session_controller();
220 // Only create views for user items which are logged in. 220 // Only create views for user items which are logged in.
221 if (user_index_ >= session_controller->NumberOfLoggedInUsers()) 221 if (user_index_ >= session_controller->NumberOfLoggedInUsers())
222 return; 222 return;
223 223
224 // Enforce a layout change that newly added items become visible. 224 // Enforce a layout change that newly added items become visible.
225 UpdateLayoutOfItem(); 225 UpdateLayoutOfItem();
226 226
227 // Update the user item. 227 // Update the user item.
228 UpdateAvatarImage(Shell::Get()->session_controller()->GetLoginStatus()); 228 UpdateAvatarImage(Shell::Get()->session_controller()->login_status());
229 } 229 }
230 230
231 void TrayUser::UserSessionUpdated(const AccountId& account_id) { 231 void TrayUser::UserSessionUpdated(const AccountId& account_id) {
232 UpdateAvatarImage(Shell::Get()->session_controller()->GetLoginStatus()); 232 UpdateAvatarImage(Shell::Get()->session_controller()->login_status());
233 } 233 }
234 234
235 void TrayUser::UpdateAvatarImage(LoginStatus status) { 235 void TrayUser::UpdateAvatarImage(LoginStatus status) {
236 const SessionController* const session_controller = 236 const SessionController* const session_controller =
237 Shell::Get()->session_controller(); 237 Shell::Get()->session_controller();
238 if (!avatar_ || user_index_ >= session_controller->NumberOfLoggedInUsers()) 238 if (!avatar_ || user_index_ >= session_controller->NumberOfLoggedInUsers())
239 return; 239 return;
240 240
241 const mojom::UserSession* const user_session = 241 const mojom::UserSession* const user_session =
242 session_controller->GetUserSession(user_index_); 242 session_controller->GetUserSession(user_index_);
243 CHECK(user_session); 243 CHECK(user_session);
244 avatar_->SetImage(user_session->avatar, 244 avatar_->SetImage(user_session->avatar,
245 gfx::Size(kTrayItemSize, kTrayItemSize)); 245 gfx::Size(kTrayItemSize, kTrayItemSize));
246 246
247 // Unit tests might come here with no images for some users. 247 // Unit tests might come here with no images for some users.
248 if (avatar_->size().IsEmpty()) 248 if (avatar_->size().IsEmpty())
249 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); 249 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize));
250 } 250 }
251 251
252 void TrayUser::UpdateLayoutOfItem() { 252 void TrayUser::UpdateLayoutOfItem() {
253 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment()); 253 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment());
254 } 254 }
255 255
256 } // namespace ash 256 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/session/session_state_observer.h ('k') | ash/common/test/test_session_controller_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698