| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <climits> | 8 #include <climits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 912 |
| 913 views::View* UserView::CreateIconForUserCard(user::LoginStatus login) { | 913 views::View* UserView::CreateIconForUserCard(user::LoginStatus login) { |
| 914 RoundedImageView* icon = new RoundedImageView(kUserIconCornerRadius, | 914 RoundedImageView* icon = new RoundedImageView(kUserIconCornerRadius, |
| 915 multiprofile_index_ == 0); | 915 multiprofile_index_ == 0); |
| 916 icon->SetEnabled(false); | 916 icon->SetEnabled(false); |
| 917 if (login == user::LOGGED_IN_GUEST) { | 917 if (login == user::LOGGED_IN_GUEST) { |
| 918 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). | 918 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). |
| 919 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), | 919 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), |
| 920 gfx::Size(kUserIconSize, kUserIconSize)); | 920 gfx::Size(kUserIconSize, kUserIconSize)); |
| 921 } else { | 921 } else { |
| 922 icon->SetImage( | 922 SessionStateDelegate* delegate = |
| 923 Shell::GetInstance()->session_state_delegate()-> | 923 Shell::GetInstance()->session_state_delegate(); |
| 924 GetUserImage(multiprofile_index_), | 924 content::BrowserContext* context = delegate->GetBrowserContextByIndex( |
| 925 gfx::Size(kUserIconSize, kUserIconSize)); | 925 multiprofile_index_); |
| 926 icon->SetImage(delegate->GetUserImage(context), |
| 927 gfx::Size(kUserIconSize, kUserIconSize)); |
| 926 } | 928 } |
| 927 return icon; | 929 return icon; |
| 928 } | 930 } |
| 929 | 931 |
| 930 void UserView::AddLoggedInRetailModeUserCardContent() { | 932 void UserView::AddLoggedInRetailModeUserCardContent() { |
| 931 views::Label* details = new views::Label; | 933 views::Label* details = new views::Label; |
| 932 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 934 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 933 details->SetText( | 935 details->SetText( |
| 934 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_KIOSK_LABEL)); | 936 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_KIOSK_LABEL)); |
| 935 details->SetBorder(views::Border::CreateEmptyBorder(0, 4, 0, 1)); | 937 details->SetBorder(views::Border::CreateEmptyBorder(0, 4, 0, 1)); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 UpdateAvatarImage( | 1291 UpdateAvatarImage( |
| 1290 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()); | 1292 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()); |
| 1291 } | 1293 } |
| 1292 | 1294 |
| 1293 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { | 1295 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { |
| 1294 SessionStateDelegate* session_state_delegate = | 1296 SessionStateDelegate* session_state_delegate = |
| 1295 Shell::GetInstance()->session_state_delegate(); | 1297 Shell::GetInstance()->session_state_delegate(); |
| 1296 if (!avatar_ || | 1298 if (!avatar_ || |
| 1297 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) | 1299 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) |
| 1298 return; | 1300 return; |
| 1299 | 1301 content::BrowserContext* context = session_state_delegate-> |
| 1300 avatar_->SetImage( | 1302 GetBrowserContextByIndex(GetTrayIndex()); |
| 1301 Shell::GetInstance()->session_state_delegate()->GetUserImage( | 1303 avatar_->SetImage(session_state_delegate->GetUserImage(context), |
| 1302 GetTrayIndex()), | 1304 gfx::Size(kUserIconSize, kUserIconSize)); |
| 1303 gfx::Size(kUserIconSize, kUserIconSize)); | |
| 1304 | 1305 |
| 1305 // Unit tests might come here with no images for some users. | 1306 // Unit tests might come here with no images for some users. |
| 1306 if (avatar_->size().IsEmpty()) | 1307 if (avatar_->size().IsEmpty()) |
| 1307 avatar_->SetSize(gfx::Size(kUserIconSize, kUserIconSize)); | 1308 avatar_->SetSize(gfx::Size(kUserIconSize, kUserIconSize)); |
| 1308 } | 1309 } |
| 1309 | 1310 |
| 1310 MultiProfileIndex TrayUser::GetTrayIndex() { | 1311 MultiProfileIndex TrayUser::GetTrayIndex() { |
| 1311 Shell* shell = Shell::GetInstance(); | 1312 Shell* shell = Shell::GetInstance(); |
| 1312 // If multi profile is not enabled we can use the normal index. | 1313 // If multi profile is not enabled we can use the normal index. |
| 1313 if (!shell->delegate()->IsMultiProfilesEnabled()) | 1314 if (!shell->delegate()->IsMultiProfilesEnabled()) |
| 1314 return multiprofile_index_; | 1315 return multiprofile_index_; |
| 1315 // In case of multi profile we need to mirror the indices since the system | 1316 // In case of multi profile we need to mirror the indices since the system |
| 1316 // tray items are in the reverse order then the menu items. | 1317 // tray items are in the reverse order then the menu items. |
| 1317 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - | 1318 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - |
| 1318 1 - multiprofile_index_; | 1319 1 - multiprofile_index_; |
| 1319 } | 1320 } |
| 1320 | 1321 |
| 1321 void TrayUser::UpdateLayoutOfItem() { | 1322 void TrayUser::UpdateLayoutOfItem() { |
| 1322 internal::RootWindowController* controller = | 1323 internal::RootWindowController* controller = |
| 1323 internal::GetRootWindowController( | 1324 internal::GetRootWindowController( |
| 1324 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); | 1325 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); |
| 1325 if (controller && controller->shelf()) { | 1326 if (controller && controller->shelf()) { |
| 1326 UpdateAfterShelfAlignmentChange( | 1327 UpdateAfterShelfAlignmentChange( |
| 1327 controller->GetShelfLayoutManager()->GetAlignment()); | 1328 controller->GetShelfLayoutManager()->GetAlignment()); |
| 1328 } | 1329 } |
| 1329 } | 1330 } |
| 1330 | 1331 |
| 1331 } // namespace internal | 1332 } // namespace internal |
| 1332 } // namespace ash | 1333 } // namespace ash |
| OLD | NEW |