Chromium Code Reviews| 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/session_state_delegate.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 user_ = nullptr; | 135 user_ = nullptr; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void TrayUser::DestroyDetailedView() { | 138 void TrayUser::DestroyDetailedView() { |
| 139 } | 139 } |
| 140 | 140 |
| 141 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 141 void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 142 // Only the active user is represented in the tray. | 142 // Only the active user is represented in the tray. |
| 143 if (!layout_view_) | 143 if (!layout_view_) |
| 144 return; | 144 return; |
| 145 if (GetTrayIndex() > 0) | 145 if (multiprofile_index_ > 0) |
| 146 return; | 146 return; |
| 147 bool need_label = false; | 147 bool need_label = false; |
| 148 bool need_avatar = false; | 148 bool need_avatar = false; |
| 149 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 149 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
| 150 if (delegate->IsUserSupervised()) | 150 if (delegate->IsUserSupervised()) |
| 151 need_label = true; | 151 need_label = true; |
| 152 switch (status) { | 152 switch (status) { |
| 153 case user::LOGGED_IN_LOCKED: | 153 case user::LOGGED_IN_LOCKED: |
| 154 case user::LOGGED_IN_USER: | 154 case user::LOGGED_IN_USER: |
| 155 case user::LOGGED_IN_OWNER: | 155 case user::LOGGED_IN_OWNER: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 | 252 |
| 253 void TrayUser::OnUserUpdate() { | 253 void TrayUser::OnUserUpdate() { |
| 254 UpdateAvatarImage(Shell::GetInstance()->system_tray_delegate()-> | 254 UpdateAvatarImage(Shell::GetInstance()->system_tray_delegate()-> |
| 255 GetUserLoginStatus()); | 255 GetUserLoginStatus()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void TrayUser::OnUserAddedToSession() { | 258 void TrayUser::OnUserAddedToSession() { |
| 259 SessionStateDelegate* session_state_delegate = | 259 SessionStateDelegate* session_state_delegate = |
| 260 Shell::GetInstance()->session_state_delegate(); | 260 Shell::GetInstance()->session_state_delegate(); |
| 261 // Only create views for user items which are logged in. | 261 // Only create views for user items which are logged in. |
| 262 if (GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) | 262 if (multiprofile_index_ >= session_state_delegate->NumberOfLoggedInUsers()) |
| 263 return; | 263 return; |
| 264 | 264 |
| 265 // Enforce a layout change that newly added items become visible. | 265 // Enforce a layout change that newly added items become visible. |
| 266 UpdateLayoutOfItem(); | 266 UpdateLayoutOfItem(); |
| 267 | 267 |
| 268 // Update the user item. | 268 // Update the user item. |
| 269 UpdateAvatarImage( | 269 UpdateAvatarImage( |
| 270 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()); | 270 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { | 273 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { |
| 274 SessionStateDelegate* session_state_delegate = | 274 SessionStateDelegate* session_state_delegate = |
| 275 Shell::GetInstance()->session_state_delegate(); | 275 Shell::GetInstance()->session_state_delegate(); |
| 276 if (!avatar_ || | 276 if (!avatar_ || |
| 277 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) | 277 multiprofile_index_ >= session_state_delegate->NumberOfLoggedInUsers()) |
| 278 return; | 278 return; |
| 279 | 279 |
| 280 const user_manager::UserInfo* user_info = | 280 const user_manager::UserInfo* user_info = |
| 281 session_state_delegate->GetUserInfo(GetTrayIndex()); | 281 session_state_delegate->GetUserInfo(multiprofile_index_); |
| 282 CHECK(user_info); | 282 CHECK(user_info); |
| 283 avatar_->SetImage(user_info->GetImage(), | 283 avatar_->SetImage(user_info->GetImage(), |
| 284 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); | 284 gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); |
| 285 | 285 |
| 286 // Unit tests might come here with no images for some users. | 286 // Unit tests might come here with no images for some users. |
| 287 if (avatar_->size().IsEmpty()) | 287 if (avatar_->size().IsEmpty()) |
| 288 avatar_->SetSize(gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); | 288 avatar_->SetSize(gfx::Size(kTrayAvatarSize, kTrayAvatarSize)); |
| 289 } | 289 } |
| 290 | 290 |
| 291 MultiProfileIndex TrayUser::GetTrayIndex() { | |
| 292 Shell* shell = Shell::GetInstance(); | |
| 293 // If multi profile is not enabled we can use the normal index. | |
| 294 if (!shell->delegate()->IsMultiProfilesEnabled()) | |
|
Mr4D (OOO till 08-26)
2015/03/21 20:59:16
Hmm. We have this other multi profile mode (where
merkulova
2015/03/23 09:53:54
I think you mean multi-login. It doesn't influence
| |
| 295 return multiprofile_index_; | |
| 296 // In case of multi profile we need to mirror the indices since the system | |
| 297 // tray items are in the reverse order then the menu items. | |
| 298 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - | |
| 299 1 - multiprofile_index_; | |
| 300 } | |
| 301 | |
| 302 void TrayUser::UpdateLayoutOfItem() { | 291 void TrayUser::UpdateLayoutOfItem() { |
| 303 RootWindowController* controller = GetRootWindowController( | 292 RootWindowController* controller = GetRootWindowController( |
| 304 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); | 293 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); |
| 305 if (controller && controller->shelf()) { | 294 if (controller && controller->shelf()) { |
| 306 UpdateAfterShelfAlignmentChange( | 295 UpdateAfterShelfAlignmentChange( |
| 307 controller->GetShelfLayoutManager()->GetAlignment()); | 296 controller->GetShelfLayoutManager()->GetAlignment()); |
| 308 } | 297 } |
| 309 } | 298 } |
| 310 | 299 |
| 311 } // namespace ash | 300 } // namespace ash |
| OLD | NEW |