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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 | 914 |
915 views::View* UserView::CreateIconForUserCard(user::LoginStatus login) { | 915 views::View* UserView::CreateIconForUserCard(user::LoginStatus login) { |
916 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius, | 916 RoundedImageView* icon = new RoundedImageView(kProfileRoundedCornerRadius, |
917 multiprofile_index_ == 0); | 917 multiprofile_index_ == 0); |
918 icon->SetEnabled(false); | 918 icon->SetEnabled(false); |
919 if (login == user::LOGGED_IN_GUEST) { | 919 if (login == user::LOGGED_IN_GUEST) { |
920 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). | 920 icon->SetImage(*ui::ResourceBundle::GetSharedInstance(). |
921 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), | 921 GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON).ToImageSkia(), |
922 gfx::Size(kUserIconSize, kUserIconSize)); | 922 gfx::Size(kUserIconSize, kUserIconSize)); |
923 } else { | 923 } else { |
924 icon->SetImage( | 924 SessionStateDelegate* delegate = |
925 Shell::GetInstance()->session_state_delegate()-> | 925 Shell::GetInstance()->session_state_delegate(); |
926 GetUserImage(multiprofile_index_), | 926 content::BrowserContext* context = delegate->GetBrowserContextByIndex( |
927 gfx::Size(kUserIconSize, kUserIconSize)); | 927 multiprofile_index_); |
| 928 icon->SetImage(delegate->GetUserImage(context), |
| 929 gfx::Size(kUserIconSize, kUserIconSize)); |
928 } | 930 } |
929 return icon; | 931 return icon; |
930 } | 932 } |
931 | 933 |
932 void UserView::AddLoggedInRetailModeUserCardContent() { | 934 void UserView::AddLoggedInRetailModeUserCardContent() { |
933 views::Label* details = new views::Label; | 935 views::Label* details = new views::Label; |
934 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 936 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
935 details->SetText( | 937 details->SetText( |
936 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_KIOSK_LABEL)); | 938 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_KIOSK_LABEL)); |
937 details->SetBorder(views::Border::CreateEmptyBorder(0, 4, 0, 1)); | 939 details->SetBorder(views::Border::CreateEmptyBorder(0, 4, 0, 1)); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { | 1327 void TrayUser::UpdateAvatarImage(user::LoginStatus status) { |
1326 SessionStateDelegate* session_state_delegate = | 1328 SessionStateDelegate* session_state_delegate = |
1327 Shell::GetInstance()->session_state_delegate(); | 1329 Shell::GetInstance()->session_state_delegate(); |
1328 if (!avatar_ || | 1330 if (!avatar_ || |
1329 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) | 1331 GetTrayIndex() >= session_state_delegate->NumberOfLoggedInUsers()) |
1330 return; | 1332 return; |
1331 | 1333 |
1332 int icon_size = switches::UseAlternateShelfLayout() ? | 1334 int icon_size = switches::UseAlternateShelfLayout() ? |
1333 kUserIconLargeSize : kUserIconSize; | 1335 kUserIconLargeSize : kUserIconSize; |
1334 | 1336 |
1335 avatar_->SetImage( | 1337 content::BrowserContext* context = session_state_delegate-> |
1336 Shell::GetInstance()->session_state_delegate()->GetUserImage( | 1338 GetBrowserContextByIndex(GetTrayIndex()); |
1337 GetTrayIndex()), | 1339 avatar_->SetImage(session_state_delegate->GetUserImage(context), |
1338 gfx::Size(icon_size, icon_size)); | 1340 gfx::Size(icon_size, icon_size)); |
1339 | 1341 |
1340 // Unit tests might come here with no images for some users. | 1342 // Unit tests might come here with no images for some users. |
1341 if (avatar_->size().IsEmpty()) | 1343 if (avatar_->size().IsEmpty()) |
1342 avatar_->SetSize(gfx::Size(icon_size, icon_size)); | 1344 avatar_->SetSize(gfx::Size(icon_size, icon_size)); |
1343 } | 1345 } |
1344 | 1346 |
1345 MultiProfileIndex TrayUser::GetTrayIndex() { | 1347 MultiProfileIndex TrayUser::GetTrayIndex() { |
1346 Shell* shell = Shell::GetInstance(); | 1348 Shell* shell = Shell::GetInstance(); |
1347 // If multi profile is not enabled we can use the normal index. | 1349 // If multi profile is not enabled we can use the normal index. |
1348 if (!shell->delegate()->IsMultiProfilesEnabled()) | 1350 if (!shell->delegate()->IsMultiProfilesEnabled()) |
1349 return multiprofile_index_; | 1351 return multiprofile_index_; |
1350 // In case of multi profile we need to mirror the indices since the system | 1352 // In case of multi profile we need to mirror the indices since the system |
1351 // tray items are in the reverse order then the menu items. | 1353 // tray items are in the reverse order then the menu items. |
1352 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - | 1354 return shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers() - |
1353 1 - multiprofile_index_; | 1355 1 - multiprofile_index_; |
1354 } | 1356 } |
1355 | 1357 |
1356 void TrayUser::UpdateLayoutOfItem() { | 1358 void TrayUser::UpdateLayoutOfItem() { |
1357 internal::RootWindowController* controller = | 1359 internal::RootWindowController* controller = |
1358 internal::GetRootWindowController( | 1360 internal::GetRootWindowController( |
1359 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); | 1361 system_tray()->GetWidget()->GetNativeWindow()->GetRootWindow()); |
1360 if (controller && controller->shelf()) { | 1362 if (controller && controller->shelf()) { |
1361 UpdateAfterShelfAlignmentChange( | 1363 UpdateAfterShelfAlignmentChange( |
1362 controller->GetShelfLayoutManager()->GetAlignment()); | 1364 controller->GetShelfLayoutManager()->GetAlignment()); |
1363 } | 1365 } |
1364 } | 1366 } |
1365 | 1367 |
1366 } // namespace internal | 1368 } // namespace internal |
1367 } // namespace ash | 1369 } // namespace ash |
OLD | NEW |