Chromium Code Reviews| Index: ash/common/system/chromeos/session/logout_button_tray.cc |
| diff --git a/ash/common/system/chromeos/session/logout_button_tray.cc b/ash/common/system/chromeos/session/logout_button_tray.cc |
| index 68aaef20c08544f2321b85fa197e8219446f551d..ccbdef9c8e86f7afb85416eb20918736e639d3cc 100644 |
| --- a/ash/common/system/chromeos/session/logout_button_tray.cc |
| +++ b/ash/common/system/chromeos/session/logout_button_tray.cc |
| @@ -23,6 +23,8 @@ |
| #include "ui/gfx/color_palette.h" |
| #include "ui/gfx/geometry/insets.h" |
| #include "ui/gfx/geometry/size.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| +#include "ui/gfx/vector_icons_public.h" |
| #include "ui/views/bubble/tray_bubble_view.h" |
| #include "ui/views/controls/button/label_button.h" |
| #include "ui/views/controls/button/label_button_border.h" |
| @@ -112,7 +114,6 @@ LogoutButtonTray::LogoutButtonTray(WmShelf* wm_shelf) |
| // TODO(estade): should this 2 be shared with other tray views? See |
| // crbug.com/623987 |
| button->AdjustFontSize(2); |
| - button->SetMinSize(gfx::Size(0, kTrayItemSize)); |
| button_ = button; |
| } else { |
| button_ = new LogoutButton(this); |
| @@ -127,6 +128,9 @@ LogoutButtonTray::~LogoutButtonTray() { |
| } |
| void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
| + // We must first update the button so that |
| + // TrayBackgroundView::SetShelfAlignment can lay it out correctly. |
|
tdanderson
2016/08/08 15:57:35
nit: () after SetShelfAlignment
Evan Stade
2016/08/08 16:00:57
will do
|
| + UpdateButtonTextAndImage(login_status_, alignment); |
| TrayBackgroundView::SetShelfAlignment(alignment); |
| tray_container()->SetBorder(views::Border::NullBorder()); |
| } |
| @@ -162,12 +166,7 @@ void LogoutButtonTray::ButtonPressed(views::Button* sender, |
| } |
| void LogoutButtonTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { |
| - login_status_ = login_status; |
| - const base::string16 title = |
| - user::GetLocalizedSignOutStringForStatus(login_status, false); |
| - button_->SetText(title); |
| - button_->SetAccessibleName(title); |
| - UpdateVisibility(); |
| + UpdateButtonTextAndImage(login_status, shelf_alignment()); |
| } |
| void LogoutButtonTray::UpdateVisibility() { |
| @@ -176,4 +175,24 @@ void LogoutButtonTray::UpdateVisibility() { |
| login_status_ != LoginStatus::LOCKED); |
| } |
| +void LogoutButtonTray::UpdateButtonTextAndImage(LoginStatus login_status, |
| + ShelfAlignment alignment) { |
| + login_status_ = login_status; |
| + const base::string16 title = |
| + user::GetLocalizedSignOutStringForStatus(login_status, false); |
| + if (alignment == SHELF_ALIGNMENT_BOTTOM) { |
| + button_->SetText(title); |
| + button_->SetImage(views::LabelButton::STATE_NORMAL, gfx::ImageSkia()); |
| + button_->SetMinSize(gfx::Size(0, kTrayItemSize)); |
| + } else { |
| + button_->SetText(base::string16()); |
| + button_->SetImage( |
| + views::LabelButton::STATE_NORMAL, |
| + gfx::CreateVectorIcon(gfx::VectorIconId::ASH_LOGOUT, kTrayIconColor)); |
| + button_->SetMinSize(gfx::Size(kTrayItemSize, kTrayItemSize)); |
| + } |
| + button_->SetAccessibleName(title); |
|
sadrul
2016/08/08 20:25:08
Do you need to explicitly do this (since LabelButt
Evan Stade
2016/08/08 22:40:54
it's necessary in the vertical shelf case. Moved t
|
| + UpdateVisibility(); |
| +} |
| + |
| } // namespace ash |