| 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/chromeos/session/logout_button_tray.h" | 5 #include "ash/common/system/chromeos/session/logout_button_tray.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/shelf/shelf_types.h" | 10 #include "ash/common/shelf/shelf_types.h" |
| 11 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 11 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
| 12 #include "ash/common/system/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
| 13 #include "ash/common/system/tray/system_tray_notifier.h" | 13 #include "ash/common/system/tray/system_tray_notifier.h" |
| 14 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
| 15 #include "ash/common/system/tray/tray_utils.h" | 15 #include "ash/common/system/tray/tray_utils.h" |
| 16 #include "ash/common/system/user/login_status.h" | 16 #include "ash/common/system/user/login_status.h" |
| 17 #include "ash/common/system/view_observer.h" |
| 17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
| 20 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
| 21 #include "ui/events/event.h" | 22 #include "ui/events/event.h" |
| 22 #include "ui/gfx/geometry/insets.h" | 23 #include "ui/gfx/geometry/insets.h" |
| 23 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 24 #include "ui/views/bubble/tray_bubble_view.h" | 25 #include "ui/views/bubble/tray_bubble_view.h" |
| 25 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/label_button.h" |
| 26 #include "ui/views/controls/button/label_button_border.h" | 27 #include "ui/views/controls/button/label_button_border.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 kLogoutButtonHorizontalExtraPadding); | 87 kLogoutButtonHorizontalExtraPadding); |
| 87 border->set_insets(insets); | 88 border->set_insets(insets); |
| 88 SetBorder(std::move(border)); | 89 SetBorder(std::move(border)); |
| 89 set_animate_on_state_change(false); | 90 set_animate_on_state_change(false); |
| 90 | 91 |
| 91 SetMinSize(gfx::Size(0, GetTrayConstant(TRAY_ITEM_HEIGHT_LEGACY))); | 92 SetMinSize(gfx::Size(0, GetTrayConstant(TRAY_ITEM_HEIGHT_LEGACY))); |
| 92 } | 93 } |
| 93 | 94 |
| 94 LogoutButton::~LogoutButton() {} | 95 LogoutButton::~LogoutButton() {} |
| 95 | 96 |
| 96 LogoutButtonTray::LogoutButtonTray(WmShelf* wm_shelf) | 97 LogoutButtonTray::LogoutButtonTray(WmShelf* wm_shelf, |
| 97 : TrayBackgroundView(wm_shelf), | 98 ViewObserver* view_observer) |
| 99 : TrayBackgroundView(wm_shelf, view_observer), |
| 98 button_(NULL), | 100 button_(NULL), |
| 99 login_status_(LoginStatus::NOT_LOGGED_IN), | 101 login_status_(LoginStatus::NOT_LOGGED_IN), |
| 100 show_logout_button_in_tray_(false) { | 102 show_logout_button_in_tray_(false) { |
| 101 button_ = new LogoutButton(this); | 103 button_ = new LogoutButton(this); |
| 102 tray_container()->AddChildView(button_); | 104 tray_container()->AddChildView(button_); |
| 103 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 104 WmShell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this); | 105 WmShell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this); |
| 105 } | 106 } |
| 106 | 107 |
| 107 LogoutButtonTray::~LogoutButtonTray() { | 108 LogoutButtonTray::~LogoutButtonTray() { |
| 108 WmShell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this); | 109 WmShell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { | 112 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 112 TrayBackgroundView::SetShelfAlignment(alignment); | 113 TrayBackgroundView::SetShelfAlignment(alignment); |
| 113 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 114 } | 114 } |
| 115 | 115 |
| 116 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { | 116 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { |
| 117 return button_->GetText(); | 117 return button_->GetText(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void LogoutButtonTray::HideBubbleWithView( | 120 void LogoutButtonTray::HideBubbleWithView( |
| 121 const views::TrayBubbleView* bubble_view) {} | 121 const views::TrayBubbleView* bubble_view) {} |
| 122 | 122 |
| 123 void LogoutButtonTray::ClickedOutsideBubble() {} | 123 void LogoutButtonTray::ClickedOutsideBubble() {} |
| (...skipping 28 matching lines...) Expand all Loading... |
| 152 UpdateVisibility(); | 152 UpdateVisibility(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void LogoutButtonTray::UpdateVisibility() { | 155 void LogoutButtonTray::UpdateVisibility() { |
| 156 SetVisible(show_logout_button_in_tray_ && | 156 SetVisible(show_logout_button_in_tray_ && |
| 157 login_status_ != LoginStatus::NOT_LOGGED_IN && | 157 login_status_ != LoginStatus::NOT_LOGGED_IN && |
| 158 login_status_ != LoginStatus::LOCKED); | 158 login_status_ != LoginStatus::LOCKED); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace ash | 161 } // namespace ash |
| OLD | NEW |