| Index: ash/system/session/logout_button_tray.cc
|
| diff --git a/ash/system/session/logout_button_tray.cc b/ash/system/session/logout_button_tray.cc
|
| index 7cadf6e680bd168811c74d5ca91852e54304d8e4..a2783a91858f083280ba165acaaa8fef0dda57f4 100644
|
| --- a/ash/system/session/logout_button_tray.cc
|
| +++ b/ash/system/session/logout_button_tray.cc
|
| @@ -4,80 +4,56 @@
|
|
|
| #include "ash/system/session/logout_button_tray.h"
|
|
|
| -#include <memory>
|
| -#include <utility>
|
| -
|
| -#include "ash/public/cpp/shelf_types.h"
|
| -#include "ash/resources/grit/ash_resources.h"
|
| #include "ash/resources/vector_icons/vector_icons.h"
|
| -#include "ash/shelf/wm_shelf_util.h"
|
| +#include "ash/shelf/wm_shelf.h"
|
| #include "ash/shell.h"
|
| #include "ash/system/session/logout_confirmation_controller.h"
|
| +#include "ash/system/status_area_widget.h"
|
| #include "ash/system/tray/system_tray_controller.h"
|
| #include "ash/system/tray/system_tray_notifier.h"
|
| #include "ash/system/tray/tray_constants.h"
|
| -#include "ash/system/tray/tray_utils.h"
|
| +#include "ash/system/tray/tray_container.h"
|
| #include "ash/system/user/login_status.h"
|
| -#include "base/logging.h"
|
| -#include "third_party/skia/include/core/SkColor.h"
|
| -#include "ui/events/event.h"
|
| +#include "ui/accessibility/ax_node_data.h"
|
| #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/views/bubble/tray_bubble_view.h"
|
| -#include "ui/views/controls/button/label_button.h"
|
| -#include "ui/views/controls/button/label_button_border.h"
|
| #include "ui/views/controls/button/md_text_button.h"
|
| -#include "ui/views/painter.h"
|
| +#include "ui/views/layout/fill_layout.h"
|
|
|
| namespace ash {
|
|
|
| LogoutButtonTray::LogoutButtonTray(WmShelf* wm_shelf)
|
| - : TrayBackgroundView(wm_shelf, false),
|
| - button_(nullptr),
|
| - login_status_(LoginStatus::NOT_LOGGED_IN),
|
| + : wm_shelf_(wm_shelf),
|
| + container_(new TrayContainer(wm_shelf)),
|
| + button_(views::MdTextButton::Create(this, base::string16())),
|
| show_logout_button_in_tray_(false) {
|
| - views::MdTextButton* button =
|
| - views::MdTextButton::Create(this, base::string16());
|
| - button->SetProminent(true);
|
| - button->SetBgColorOverride(gfx::kGoogleRed700);
|
| - button->AdjustFontSize(kTrayTextFontSizeIncrease);
|
| - button_ = button;
|
| -
|
| - // Since LogoutButtonTray has a red background and it is distinguished
|
| - // by itself, no separator is needed on its right side.
|
| - set_separator_visibility(false);
|
| - tray_container()->AddChildView(button_);
|
| + SetLayoutManager(new views::FillLayout);
|
| + AddChildView(container_);
|
| +
|
| + button_->SetProminent(true);
|
| + button_->SetBgColorOverride(gfx::kGoogleRed700);
|
| + button_->AdjustFontSize(kTrayTextFontSizeIncrease);
|
| +
|
| + container_->AddChildView(button_);
|
| Shell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this);
|
| + SetVisible(false);
|
| }
|
|
|
| LogoutButtonTray::~LogoutButtonTray() {
|
| Shell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this);
|
| }
|
|
|
| -void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
|
| - // We must first update the button so that
|
| - // TrayBackgroundView::SetShelfAlignment() can lay it out correctly.
|
| - UpdateButtonTextAndImage(login_status_, alignment);
|
| - TrayBackgroundView::SetShelfAlignment(alignment);
|
| -}
|
| -
|
| -base::string16 LogoutButtonTray::GetAccessibleNameForTray() {
|
| - return button_->GetText();
|
| +void LogoutButtonTray::UpdateAfterShelfAlignmentChange() {
|
| + // We must first update the button so that |container_| can lay it out
|
| + // correctly.
|
| + UpdateButtonTextAndImage();
|
| + container_->UpdateAfterShelfAlignmentChange();
|
| }
|
|
|
| -void LogoutButtonTray::HideBubbleWithView(
|
| - const views::TrayBubbleView* bubble_view) {}
|
| -
|
| -void LogoutButtonTray::ClickedOutsideBubble() {}
|
| -
|
| void LogoutButtonTray::ButtonPressed(views::Button* sender,
|
| const ui::Event& event) {
|
| - if (sender != button_) {
|
| - TrayBackgroundView::ButtonPressed(sender, event);
|
| - return;
|
| - }
|
| + DCHECK_EQ(button_, sender);
|
|
|
| if (dialog_duration_ <= base::TimeDelta()) {
|
| // Sign out immediately if |dialog_duration_| is non-positive.
|
| @@ -88,6 +64,11 @@ void LogoutButtonTray::ButtonPressed(views::Button* sender,
|
| }
|
| }
|
|
|
| +void LogoutButtonTray::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
| + View::GetAccessibleNodeData(node_data);
|
| + node_data->SetName(button_->GetText());
|
| +}
|
| +
|
| void LogoutButtonTray::OnShowLogoutButtonInTrayChanged(bool show) {
|
| show_logout_button_in_tray_ = show;
|
| UpdateVisibility();
|
| @@ -97,29 +78,29 @@ void LogoutButtonTray::OnLogoutDialogDurationChanged(base::TimeDelta duration) {
|
| dialog_duration_ = duration;
|
| }
|
|
|
| -void LogoutButtonTray::UpdateAfterLoginStatusChange(LoginStatus login_status) {
|
| - UpdateButtonTextAndImage(login_status, shelf_alignment());
|
| +void LogoutButtonTray::UpdateAfterLoginStatusChange() {
|
| + UpdateButtonTextAndImage();
|
| }
|
|
|
| void LogoutButtonTray::UpdateVisibility() {
|
| + LoginStatus login_status = wm_shelf_->GetStatusAreaWidget()->login_status();
|
| SetVisible(show_logout_button_in_tray_ &&
|
| - login_status_ != LoginStatus::NOT_LOGGED_IN &&
|
| - login_status_ != LoginStatus::LOCKED);
|
| + login_status != LoginStatus::NOT_LOGGED_IN &&
|
| + login_status != LoginStatus::LOCKED);
|
| }
|
|
|
| -void LogoutButtonTray::UpdateButtonTextAndImage(LoginStatus login_status,
|
| - ShelfAlignment alignment) {
|
| - login_status_ = login_status;
|
| +void LogoutButtonTray::UpdateButtonTextAndImage() {
|
| + LoginStatus login_status = wm_shelf_->GetStatusAreaWidget()->login_status();
|
| const base::string16 title =
|
| user::GetLocalizedSignOutStringForStatus(login_status, false);
|
| - if (IsHorizontalAlignment(alignment)) {
|
| + if (wm_shelf_->IsHorizontalAlignment()) {
|
| button_->SetText(title);
|
| - button_->SetImage(views::LabelButton::STATE_NORMAL, gfx::ImageSkia());
|
| + button_->SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia());
|
| button_->SetMinSize(gfx::Size(0, kTrayItemSize));
|
| } else {
|
| button_->SetText(base::string16());
|
| button_->SetAccessibleName(title);
|
| - button_->SetImage(views::LabelButton::STATE_NORMAL,
|
| + button_->SetImage(views::Button::STATE_NORMAL,
|
| gfx::CreateVectorIcon(kShelfLogoutIcon, kTrayIconColor));
|
| button_->SetMinSize(gfx::Size(kTrayItemSize, kTrayItemSize));
|
| }
|
|
|