| Index: ash/common/system/user/user_card_view.cc
|
| diff --git a/ash/common/system/user/user_card_view.cc b/ash/common/system/user/user_card_view.cc
|
| index 609fa4afeed1af696fd988c555f722a53c1516fa..ae0315a00e3c1c17c2e3dee30515b80a93787faf 100644
|
| --- a/ash/common/system/user/user_card_view.cc
|
| +++ b/ash/common/system/user/user_card_view.cc
|
| @@ -10,7 +10,6 @@
|
|
|
| #include "ash/common/ash_view_ids.h"
|
| #include "ash/common/login_status.h"
|
| -#include "ash/common/material_design/material_design_controller.h"
|
| #include "ash/common/media_controller.h"
|
| #include "ash/common/session/session_state_delegate.h"
|
| #include "ash/common/system/tray/system_tray_controller.h"
|
| @@ -27,11 +26,9 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "components/user_manager/user_info.h"
|
| -#include "grit/ash_resources.h"
|
| #include "grit/ash_strings.h"
|
| #include "ui/accessibility/ax_node_data.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| -#include "ui/base/resource/resource_bundle.h"
|
| #include "ui/compositor/compositing_recorder.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/color_palette.h"
|
| @@ -48,7 +45,6 @@
|
| #include "ui/views/controls/link.h"
|
| #include "ui/views/controls/link_listener.h"
|
| #include "ui/views/layout/box_layout.h"
|
| -#include "ui/views/layout/fill_layout.h"
|
|
|
| namespace ash {
|
| namespace tray {
|
| @@ -61,19 +57,11 @@ const int kUserDetailsVerticalPadding = 5;
|
| // and end of the user's display name in the public account user card's text.
|
| const base::char16 kDisplayNameMark[] = {0x2060, 0};
|
|
|
| -bool UseMd() {
|
| - return MaterialDesignController::IsSystemTrayMenuMaterial();
|
| -}
|
| -
|
| views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) {
|
| - RoundedImageView* image_view = new RoundedImageView(
|
| - UseMd() ? kTrayItemSize / 2 : kTrayRoundedBorderRadius, user_index == 0);
|
| + RoundedImageView* image_view = new RoundedImageView(kTrayItemSize / 2);
|
| if (login_status == LoginStatus::GUEST) {
|
| gfx::ImageSkia icon =
|
| - UseMd() ? gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor)
|
| - : *ui::ResourceBundle::GetSharedInstance()
|
| - .GetImageNamed(IDR_AURA_UBER_TRAY_GUEST_ICON)
|
| - .ToImageSkia();
|
| + gfx::CreateVectorIcon(kSystemMenuGuestIcon, kMenuIconColor);
|
| image_view->SetImage(icon, icon.size());
|
| } else {
|
| SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
|
| @@ -81,80 +69,13 @@ views::View* CreateUserAvatarView(LoginStatus login_status, int user_index) {
|
| gfx::Size(kTrayItemSize, kTrayItemSize));
|
| }
|
|
|
| - if (UseMd()) {
|
| - image_view->SetBorder(views::CreateEmptyBorder(gfx::Insets(
|
| - (GetTrayConstant(TRAY_POPUP_ITEM_MAIN_IMAGE_CONTAINER_WIDTH) -
|
| - image_view->GetPreferredSize().width()) /
|
| - 2)));
|
| - }
|
| + image_view->SetBorder(views::CreateEmptyBorder(
|
| + gfx::Insets((GetTrayConstant(TRAY_POPUP_ITEM_MAIN_IMAGE_CONTAINER_WIDTH) -
|
| + image_view->GetPreferredSize().width()) /
|
| + 2)));
|
| return image_view;
|
| }
|
|
|
| -class MediaIndicator : public views::View, public MediaCaptureObserver {
|
| - public:
|
| - explicit MediaIndicator(UserIndex index)
|
| - : index_(index), label_(new views::Label) {
|
| - DCHECK(!UseMd());
|
| - SetLayoutManager(new views::FillLayout);
|
| - views::ImageView* icon = new views::ImageView;
|
| - icon->SetImage(ui::ResourceBundle::GetSharedInstance()
|
| - .GetImageNamed(IDR_AURA_UBER_TRAY_RECORDING_RED)
|
| - .ToImageSkia());
|
| - AddChildView(icon);
|
| - label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| - label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
|
| - ui::ResourceBundle::SmallFont));
|
| - WmShell::Get()->media_controller()->AddObserver(this);
|
| - SetVisible(false);
|
| - WmShell::Get()->media_controller()->RequestCaptureState();
|
| - set_id(VIEW_ID_USER_VIEW_MEDIA_INDICATOR);
|
| - }
|
| -
|
| - ~MediaIndicator() override {
|
| - WmShell::Get()->media_controller()->RemoveObserver(this);
|
| - }
|
| -
|
| - // MediaCaptureObserver:
|
| - void OnMediaCaptureChanged(
|
| - const std::vector<mojom::MediaCaptureState>& capture_states) override {
|
| - if (static_cast<size_t>(index_) >= capture_states.size()) {
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| -
|
| - mojom::MediaCaptureState state = capture_states[index_];
|
| - int res_id = 0;
|
| - switch (state) {
|
| - case mojom::MediaCaptureState::AUDIO_VIDEO:
|
| - res_id = IDS_ASH_STATUS_TRAY_MEDIA_RECORDING_AUDIO_VIDEO;
|
| - break;
|
| - case mojom::MediaCaptureState::AUDIO:
|
| - res_id = IDS_ASH_STATUS_TRAY_MEDIA_RECORDING_AUDIO;
|
| - break;
|
| - case mojom::MediaCaptureState::VIDEO:
|
| - res_id = IDS_ASH_STATUS_TRAY_MEDIA_RECORDING_VIDEO;
|
| - break;
|
| - case mojom::MediaCaptureState::NONE:
|
| - break;
|
| - }
|
| - SetMessage(res_id ? l10n_util::GetStringUTF16(res_id) : base::string16());
|
| - }
|
| -
|
| - views::View* GetMessageView() { return label_; }
|
| -
|
| - void SetMessage(const base::string16& message) {
|
| - SetVisible(!message.empty());
|
| - label_->SetText(message);
|
| - label_->SetVisible(!message.empty());
|
| - }
|
| -
|
| - private:
|
| - UserIndex index_;
|
| - views::Label* label_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(MediaIndicator);
|
| -};
|
| -
|
| // The user details shown in public account mode. This is essentially a label
|
| // but with custom painting code as the text is styled with multiple colors and
|
| // contains a link.
|
| @@ -176,7 +97,7 @@ class PublicAccountUserDetails : public views::View,
|
| // Calculate a preferred size that ensures the label text and the following
|
| // link do not wrap over more than three lines in total for aesthetic reasons
|
| // if possible.
|
| - void CalculatePreferredSize(int max_allowed_width);
|
| + void CalculatePreferredSize();
|
|
|
| base::string16 text_;
|
| views::Link* learn_more_;
|
| @@ -218,7 +139,7 @@ PublicAccountUserDetails::PublicAccountUserDetails(int max_width)
|
| learn_more_->set_listener(this);
|
| AddChildView(learn_more_);
|
|
|
| - CalculatePreferredSize(max_width);
|
| + CalculatePreferredSize();
|
| }
|
|
|
| PublicAccountUserDetails::~PublicAccountUserDetails() {}
|
| @@ -307,7 +228,7 @@ void PublicAccountUserDetails::LinkClicked(views::Link* source,
|
| WmShell::Get()->system_tray_controller()->ShowPublicAccountInfo();
|
| }
|
|
|
| -void PublicAccountUserDetails::CalculatePreferredSize(int max_allowed_width) {
|
| +void PublicAccountUserDetails::CalculatePreferredSize() {
|
| const gfx::FontList font_list;
|
| const gfx::Size link_size = learn_more_->GetPreferredSize();
|
| const int space_width =
|
| @@ -316,11 +237,7 @@ void PublicAccountUserDetails::CalculatePreferredSize(int max_allowed_width) {
|
| int min_width = link_size.width();
|
| int max_width =
|
| gfx::GetStringWidth(text_, font_list) + space_width + link_size.width();
|
| - // TODO(estade): |max_allowed_width| isn't used in MD.
|
| - if (UseMd())
|
| - DCHECK_EQ(-1, max_allowed_width);
|
| - else
|
| - max_width = std::min(max_width, max_allowed_width - insets.width());
|
| +
|
| // Do a binary search for the minimum width that ensures no more than three
|
| // lines are needed. The lower bound is the minimum of the current bubble
|
| // width and the width of the link (as no wrapping is permitted inside the
|
| @@ -371,37 +288,29 @@ UserCardView::UserCardView(LoginStatus login_status,
|
| media_capture_label_(nullptr),
|
| media_capture_icon_(nullptr) {
|
| auto layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
|
| - UseMd() ? kTrayPopupLabelHorizontalPadding
|
| - : kTrayPopupPaddingBetweenItems);
|
| + kTrayPopupLabelHorizontalPadding);
|
| SetLayoutManager(layout);
|
| - if (UseMd()) {
|
| - layout->set_minimum_cross_axis_size(
|
| - GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
|
| - layout->set_cross_axis_alignment(
|
| - views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
|
| - // For active users, the left inset is provided by ActiveUserBorder, which
|
| - // is necessary to make sure the ripple does not cover that part of the row.
|
| - // For inactive users, we set the inset here and this causes the ripple to
|
| - // extend all the way to the edges of the menu.
|
| - if (!is_active_user()) {
|
| - SetBorder(
|
| - views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0));
|
| - }
|
| -
|
| - WmShell::Get()->media_controller()->AddObserver(this);
|
| - }
|
| + layout->set_minimum_cross_axis_size(
|
| + GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
|
| + layout->set_cross_axis_alignment(
|
| + views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
|
| + // For active users, the left inset is provided by ActiveUserBorder, which
|
| + // is necessary to make sure the ripple does not cover that part of the row.
|
| + // For inactive users, we set the inset here and this causes the ripple to
|
| + // extend all the way to the edges of the menu.
|
| + if (!is_active_user())
|
| + SetBorder(views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0));
|
| +
|
| + WmShell::Get()->media_controller()->AddObserver(this);
|
|
|
| if (login_status == LoginStatus::PUBLIC)
|
| AddPublicModeUserContent(max_width);
|
| - else if (UseMd())
|
| - AddUserContentMd(layout, login_status);
|
| else
|
| - AddUserContent(login_status);
|
| + AddUserContent(layout, login_status);
|
| }
|
|
|
| UserCardView::~UserCardView() {
|
| - if (UseMd())
|
| - WmShell::Get()->media_controller()->RemoveObserver(this);
|
| + WmShell::Get()->media_controller()->RemoveObserver(this);
|
| }
|
|
|
| void UserCardView::PaintChildren(const ui::PaintContext& context) {
|
| @@ -457,82 +366,8 @@ void UserCardView::AddPublicModeUserContent(int max_width) {
|
| AddChildView(new PublicAccountUserDetails(details_max_width));
|
| }
|
|
|
| -void UserCardView::AddUserContent(LoginStatus login_status) {
|
| - DCHECK(!UseMd());
|
| - views::View* avatar = CreateUserAvatarView(login_status, user_index_);
|
| - AddChildView(avatar);
|
| - views::Label* user_name = NULL;
|
| - SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
|
| - if (!user_index_) {
|
| - base::string16 user_name_string =
|
| - login_status == LoginStatus::GUEST
|
| - ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)
|
| - : delegate->GetUserInfo(user_index_)->GetDisplayName();
|
| - if (!user_name_string.empty()) {
|
| - user_name = new views::Label(user_name_string);
|
| - user_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| - }
|
| - }
|
| -
|
| - views::Label* user_email = NULL;
|
| - if (login_status != LoginStatus::GUEST) {
|
| - SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate();
|
| - base::string16 user_email_string =
|
| - tray_delegate->IsUserSupervised()
|
| - ? l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SUPERVISED_LABEL)
|
| - : base::UTF8ToUTF16(
|
| - delegate->GetUserInfo(user_index_)->GetDisplayEmail());
|
| - if (!user_email_string.empty()) {
|
| - user_email = new views::Label(user_email_string);
|
| - user_email->SetFontList(
|
| - ui::ResourceBundle::GetSharedInstance().GetFontList(
|
| - ui::ResourceBundle::SmallFont));
|
| - user_email->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| - }
|
| - }
|
| -
|
| - // Adjust text properties dependent on if it is an active or inactive user.
|
| - if (user_index_) {
|
| - // Fade the text of non active users to 50%.
|
| - SkColor text_color = user_email->enabled_color();
|
| - text_color = SkColorSetA(text_color, SkColorGetA(text_color) / 2);
|
| - if (user_email)
|
| - user_email->SetDisabledColor(text_color);
|
| - if (user_name)
|
| - user_name->SetDisabledColor(text_color);
|
| - }
|
| -
|
| - if (user_email && user_name) {
|
| - views::View* details = new views::View;
|
| - details->SetLayoutManager(new views::BoxLayout(
|
| - views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
|
| - details->AddChildView(user_name);
|
| - details->AddChildView(user_email);
|
| - AddChildView(details);
|
| - } else {
|
| - if (user_name)
|
| - AddChildView(user_name);
|
| - if (user_email) {
|
| - // Only non active user can have a media indicator.
|
| - MediaIndicator* media_indicator = new MediaIndicator(user_index_);
|
| - views::View* email_indicator_view = new views::View;
|
| - email_indicator_view->SetLayoutManager(new views::BoxLayout(
|
| - views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems));
|
| - email_indicator_view->AddChildView(user_email);
|
| - email_indicator_view->AddChildView(media_indicator);
|
| -
|
| - views::View* details = new views::View;
|
| - details->SetLayoutManager(new views::BoxLayout(
|
| - views::BoxLayout::kVertical, 0, kUserDetailsVerticalPadding, 0));
|
| - details->AddChildView(email_indicator_view);
|
| - details->AddChildView(media_indicator->GetMessageView());
|
| - AddChildView(details);
|
| - }
|
| - }
|
| -}
|
| -
|
| -void UserCardView::AddUserContentMd(views::BoxLayout* layout,
|
| - LoginStatus login_status) {
|
| +void UserCardView::AddUserContent(views::BoxLayout* layout,
|
| + LoginStatus login_status) {
|
| AddChildView(CreateUserAvatarView(login_status, user_index_));
|
| SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
|
| base::string16 user_name_string =
|
|
|