| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/system/user/user_card_view.h" | 5 #include "ash/common/system/user/user_card_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // and end of the user's display name in the public account user card's text. | 57 // and end of the user's display name in the public account user card's text. |
| 58 const base::char16 kDisplayNameMark[] = {0x2060, 0}; | 58 const base::char16 kDisplayNameMark[] = {0x2060, 0}; |
| 59 | 59 |
| 60 views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) { | 60 views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) { |
| 61 RoundedImageView* image_view = new RoundedImageView(kTrayItemSize / 2); | 61 RoundedImageView* image_view = new RoundedImageView(kTrayItemSize / 2); |
| 62 if (login_status == LoginStatus::GUEST) { | 62 if (login_status == LoginStatus::GUEST) { |
| 63 gfx::ImageSkia icon = | 63 gfx::ImageSkia icon = |
| 64 gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor); | 64 gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor); |
| 65 image_view->SetImage(icon, icon.size()); | 65 image_view->SetImage(icon, icon.size()); |
| 66 } else { | 66 } else { |
| 67 SessionController* controller = WmShell::Get()->session_controller(); | 67 SessionController* controller = Shell::Get()->session_controller(); |
| 68 // TODO(xiyuan); HiDpi avatar support. http://crbug.com/702689 | 68 // TODO(xiyuan); HiDpi avatar support. http://crbug.com/702689 |
| 69 image_view->SetImage(gfx::ImageSkia::CreateFrom1xBitmap( | 69 image_view->SetImage(gfx::ImageSkia::CreateFrom1xBitmap( |
| 70 controller->GetUserSession(user_index)->avatar), | 70 controller->GetUserSession(user_index)->avatar), |
| 71 gfx::Size(kTrayItemSize, kTrayItemSize)); | 71 gfx::Size(kTrayItemSize, kTrayItemSize)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 image_view->SetBorder(views::CreateEmptyBorder(gfx::Insets( | 74 image_view->SetBorder(views::CreateEmptyBorder(gfx::Insets( |
| 75 (kTrayPopupItemMinStartWidth - image_view->GetPreferredSize().width()) / | 75 (kTrayPopupItemMinStartWidth - image_view->GetPreferredSize().width()) / |
| 76 2))); | 76 2))); |
| 77 return image_view; | 77 return image_view; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems; | 115 kTrayPopupPaddingHorizontal - kTrayPopupPaddingBetweenItems; |
| 116 const bool rtl = base::i18n::IsRTL(); | 116 const bool rtl = base::i18n::IsRTL(); |
| 117 SetBorder(views::CreateEmptyBorder( | 117 SetBorder(views::CreateEmptyBorder( |
| 118 kUserDetailsVerticalPadding, rtl ? 0 : inner_padding, | 118 kUserDetailsVerticalPadding, rtl ? 0 : inner_padding, |
| 119 kUserDetailsVerticalPadding, rtl ? inner_padding : 0)); | 119 kUserDetailsVerticalPadding, rtl ? inner_padding : 0)); |
| 120 | 120 |
| 121 // Retrieve the user's display name and wrap it with markers. | 121 // Retrieve the user's display name and wrap it with markers. |
| 122 // Note that since this is a public account it always has to be the primary | 122 // Note that since this is a public account it always has to be the primary |
| 123 // user. | 123 // user. |
| 124 base::string16 display_name = base::UTF8ToUTF16( | 124 base::string16 display_name = base::UTF8ToUTF16( |
| 125 WmShell::Get()->session_controller()->GetUserSession(0)->display_name); | 125 Shell::Get()->session_controller()->GetUserSession(0)->display_name); |
| 126 base::RemoveChars(display_name, kDisplayNameMark, &display_name); | 126 base::RemoveChars(display_name, kDisplayNameMark, &display_name); |
| 127 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; | 127 display_name = kDisplayNameMark[0] + display_name + kDisplayNameMark[0]; |
| 128 // Retrieve the domain managing the device and wrap it with markers. | 128 // Retrieve the domain managing the device and wrap it with markers. |
| 129 base::string16 domain = base::UTF8ToUTF16( | 129 base::string16 domain = base::UTF8ToUTF16( |
| 130 Shell::Get()->system_tray_delegate()->GetEnterpriseDomain()); | 130 Shell::Get()->system_tray_delegate()->GetEnterpriseDomain()); |
| 131 base::RemoveChars(domain, kDisplayNameMark, &domain); | 131 base::RemoveChars(domain, kDisplayNameMark, &domain); |
| 132 base::i18n::WrapStringWithLTRFormatting(&domain); | 132 base::i18n::WrapStringWithLTRFormatting(&domain); |
| 133 // Retrieve the label text, inserting the display name and domain. | 133 // Retrieve the label text, inserting the display name and domain. |
| 134 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, | 134 text_ = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_PUBLIC_LABEL, |
| 135 display_name, domain); | 135 display_name, domain); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 views::View* avatar = CreateUserAvatarView(LoginStatus::PUBLIC, 0); | 389 views::View* avatar = CreateUserAvatarView(LoginStatus::PUBLIC, 0); |
| 390 AddChildView(avatar); | 390 AddChildView(avatar); |
| 391 int details_max_width = max_width - avatar->GetPreferredSize().width() - | 391 int details_max_width = max_width - avatar->GetPreferredSize().width() - |
| 392 kTrayPopupPaddingBetweenItems; | 392 kTrayPopupPaddingBetweenItems; |
| 393 AddChildView(new PublicAccountUserDetails(details_max_width)); | 393 AddChildView(new PublicAccountUserDetails(details_max_width)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void UserCardView::AddUserContent(views::BoxLayout* layout, | 396 void UserCardView::AddUserContent(views::BoxLayout* layout, |
| 397 LoginStatus login_status) { | 397 LoginStatus login_status) { |
| 398 AddChildView(CreateUserAvatarView(login_status, user_index_)); | 398 AddChildView(CreateUserAvatarView(login_status, user_index_)); |
| 399 SessionController* controller = WmShell::Get()->session_controller(); | 399 SessionController* controller = Shell::Get()->session_controller(); |
| 400 base::string16 user_name_string = | 400 base::string16 user_name_string = |
| 401 login_status == LoginStatus::GUEST | 401 login_status == LoginStatus::GUEST |
| 402 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) | 402 ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL) |
| 403 : base::UTF8ToUTF16( | 403 : base::UTF8ToUTF16( |
| 404 controller->GetUserSession(user_index_)->display_name); | 404 controller->GetUserSession(user_index_)->display_name); |
| 405 user_name_ = new views::Label(user_name_string); | 405 user_name_ = new views::Label(user_name_string); |
| 406 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 406 user_name_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 407 TrayPopupItemStyle user_name_style( | 407 TrayPopupItemStyle user_name_style( |
| 408 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | 408 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); |
| 409 user_name_style.SetupLabel(user_name_); | 409 user_name_style.SetupLabel(user_name_); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); | 464 media_capture_icon_->set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR); |
| 465 AddChildView(media_capture_icon_); | 465 AddChildView(media_capture_icon_); |
| 466 | 466 |
| 467 Shell::Get()->media_controller()->RequestCaptureState(); | 467 Shell::Get()->media_controller()->RequestCaptureState(); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 } // namespace tray | 471 } // namespace tray |
| 472 } // namespace ash | 472 } // namespace ash |
| OLD | NEW |