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