OLD | NEW |
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/system/user/tray_user.h" | 5 #include "ash/system/user/tray_user.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session_state_delegate.h" |
10 #include "ash/session/user_info.h" | |
11 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
13 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
14 #include "ash/system/tray/system_tray_notifier.h" | 13 #include "ash/system/tray/system_tray_notifier.h" |
15 #include "ash/system/tray/tray_constants.h" | 14 #include "ash/system/tray/tray_constants.h" |
16 #include "ash/system/tray/tray_item_view.h" | 15 #include "ash/system/tray/tray_item_view.h" |
17 #include "ash/system/tray/tray_utils.h" | 16 #include "ash/system/tray/tray_utils.h" |
18 #include "ash/system/user/accounts_detailed_view.h" | 17 #include "ash/system/user/accounts_detailed_view.h" |
19 #include "ash/system/user/rounded_image_view.h" | 18 #include "ash/system/user/rounded_image_view.h" |
20 #include "ash/system/user/user_view.h" | 19 #include "ash/system/user/user_view.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 256 |
258 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { | 257 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { |
259 SessionStateDelegate* session_state_delegate = | 258 SessionStateDelegate* session_state_delegate = |
260 Shell::GetInstance()->session_state_delegate(); | 259 Shell::GetInstance()->session_state_delegate(); |
261 if (!avatar_ || | 260 if (!avatar_ || |
262 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) | 261 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) |
263 return; | 262 return; |
264 | 263 |
265 content::BrowserContext* context = session_state_delegate-> | 264 content::BrowserContext* context = session_state_delegate-> |
266 GetBrowserContextByIndex(GetTrayIndex()); | 265 GetBrowserContextByIndex(GetTrayIndex()); |
267 avatar_->SetImage(session_state_delegate->GetUserInfo(context)->GetImage(), | 266 avatar_->SetImage(session_state_delegate->GetUserImage(context), |
268 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); | 267 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); |
269 | 268 |
270 // Unit tests might come here with no images for some users. | 269 // Unit tests might come here with no images for some users. |
271 if (avatar_->size().IsEmpty()) | 270 if (avatar_->size().IsEmpty()) |
272 avatar_->SetSize(gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); | 271 avatar_->SetSize(gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); |
273 } | 272 } |
274 | 273 |
275 MultiProfileIndex TrayUser::GetTrayIndex() { | 274 MultiProfileIndex TrayUser::GetTrayIndex() { |
276 Shell* shell = Shell::GetInstance(); | 275 Shell* shell = Shell::GetInstance(); |
277 // If multi profile is not enabled we can use the normal index. | 276 // If multi profile is not enabled we can use the normal index. |
278 if (!shell->delegate()->IsMultiProfilesEnabled()) | 277 if (!shell->delegate()->IsMultiProfilesEnabled()) |
279 return multiprofile_index_; | 278 return multiprofile_index_; |
280 // In case of multi profile we need to mirror the indices since the system | 279 // In case of multi profile we need to mirror the indices since the system |
281 // tray items are in the reverse order then the menu items. | 280 // tray items are in the reverse order then the menu items. |
282 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - | 281 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - |
283 1 - multiprofile_index_; | 282 1 - multiprofile_index_; |
284 } | 283 } |
285 | 284 |
286 void TrayUser::UpdateLayoutOfItem() { | 285 void TrayUser::UpdateLayoutOfItem() { |
287 RootWindowController* controller = GetRootWindowController( | 286 RootWindowController* controller = GetRootWindowController( |
288 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); | 287 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); |
289 if (controller && controller->shelf()) { | 288 if (controller && controller->shelf()) { |
290 UpdateAfterShelfAlignmentChange( | 289 UpdateAfterShelfAlignmentChange( |
291 controller->GetShelfLayoutManager()->GetAlignment()); | 290 controller->GetShelfLayoutManager()->GetAlignment()); |
292 } | 291 } |
293 } | 292 } |
294 | 293 |
295 } // namespace ash | 294 } // namespace ash |
OLD | NEW |