| 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/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/shelf/shelf_types.h" | 11 #include "ash/common/shelf/shelf_types.h" |
| 12 #include "ash/common/shelf/wm_shelf_observer.h" |
| 12 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 13 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 14 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/system/tray/system_tray_notifier.h" | 15 #include "ash/common/system/tray/system_tray_notifier.h" |
| 15 #include "ash/common/system/tray/tray_constants.h" | 16 #include "ash/common/system/tray/tray_constants.h" |
| 16 #include "ash/common/system/tray/tray_utils.h" | 17 #include "ash/common/system/tray/tray_utils.h" |
| 17 #include "ash/common/system/user/login_status.h" | 18 #include "ash/common/system/user/login_status.h" |
| 18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 19 #include "base/logging.h" | 20 #include "base/logging.h" |
| 20 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
| 21 #include "third_party/skia/include/core/SkColor.h" | 22 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 kLogoutButtonHorizontalExtraPadding); | 92 kLogoutButtonHorizontalExtraPadding); |
| 92 border->set_insets(insets); | 93 border->set_insets(insets); |
| 93 SetBorder(std::move(border)); | 94 SetBorder(std::move(border)); |
| 94 set_animate_on_state_change(false); | 95 set_animate_on_state_change(false); |
| 95 | 96 |
| 96 SetMinSize(gfx::Size(0, GetTrayConstant(TRAY_ITEM_HEIGHT_LEGACY))); | 97 SetMinSize(gfx::Size(0, GetTrayConstant(TRAY_ITEM_HEIGHT_LEGACY))); |
| 97 } | 98 } |
| 98 | 99 |
| 99 LogoutButton::~LogoutButton() {} | 100 LogoutButton::~LogoutButton() {} |
| 100 | 101 |
| 101 LogoutButtonTray::LogoutButtonTray(WmShelf* wm_shelf) | 102 LogoutButtonTray::LogoutButtonTray(WmShelf* wm_shelf, |
| 102 : TrayBackgroundView(wm_shelf), | 103 WmShelfObserver* wm_shelf_observer) |
| 104 : TrayBackgroundView(wm_shelf, wm_shelf_observer), |
| 103 button_(nullptr), | 105 button_(nullptr), |
| 104 login_status_(LoginStatus::NOT_LOGGED_IN), | 106 login_status_(LoginStatus::NOT_LOGGED_IN), |
| 105 show_logout_button_in_tray_(false) { | 107 show_logout_button_in_tray_(false) { |
| 106 if (MaterialDesignController::IsShelfMaterial()) { | 108 if (MaterialDesignController::IsShelfMaterial()) { |
| 107 views::MdTextButton* button = | 109 views::MdTextButton* button = |
| 108 views::MdTextButton::CreateMdButton(this, base::string16()); | 110 views::MdTextButton::CreateMdButton(this, base::string16()); |
| 109 button->SetCallToAction(true); | 111 button->SetCallToAction(true); |
| 110 button->set_bg_color_override(gfx::kGoogleRed700); | 112 button->set_bg_color_override(gfx::kGoogleRed700); |
| 111 // Base font size + 2 = 14. | 113 // Base font size + 2 = 14. |
| 112 // TODO(estade): should this 2 be shared with other tray views? See | 114 // TODO(estade): should this 2 be shared with other tray views? See |
| 113 // crbug.com/623987 | 115 // crbug.com/623987 |
| 114 button->AdjustFontSize(2); | 116 button->AdjustFontSize(2); |
| 115 button->SetMinSize(gfx::Size(0, kTrayItemSize)); | 117 button->SetMinSize(gfx::Size(0, kTrayItemSize)); |
| 116 button_ = button; | 118 button_ = button; |
| 117 } else { | 119 } else { |
| 118 button_ = new LogoutButton(this); | 120 button_ = new LogoutButton(this); |
| 119 } | 121 } |
| 120 tray_container()->AddChildView(button_); | 122 tray_container()->AddChildView(button_); |
| 121 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 122 WmShell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this); | 123 WmShell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this); |
| 123 } | 124 } |
| 124 | 125 |
| 125 LogoutButtonTray::~LogoutButtonTray() { | 126 LogoutButtonTray::~LogoutButtonTray() { |
| 126 WmShell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this); | 127 WmShell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { | 130 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 130 TrayBackgroundView::SetShelfAlignment(alignment); | 131 TrayBackgroundView::SetShelfAlignment(alignment); |
| 131 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 132 } | 132 } |
| 133 | 133 |
| 134 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { | 134 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { |
| 135 return button_->GetText(); | 135 return button_->GetText(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void LogoutButtonTray::HideBubbleWithView( | 138 void LogoutButtonTray::HideBubbleWithView( |
| 139 const views::TrayBubbleView* bubble_view) {} | 139 const views::TrayBubbleView* bubble_view) {} |
| 140 | 140 |
| 141 void LogoutButtonTray::ClickedOutsideBubble() {} | 141 void LogoutButtonTray::ClickedOutsideBubble() {} |
| (...skipping 28 matching lines...) Expand all Loading... |
| 170 UpdateVisibility(); | 170 UpdateVisibility(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void LogoutButtonTray::UpdateVisibility() { | 173 void LogoutButtonTray::UpdateVisibility() { |
| 174 SetVisible(show_logout_button_in_tray_ && | 174 SetVisible(show_logout_button_in_tray_ && |
| 175 login_status_ != LoginStatus::NOT_LOGGED_IN && | 175 login_status_ != LoginStatus::NOT_LOGGED_IN && |
| 176 login_status_ != LoginStatus::LOCKED); | 176 login_status_ != LoginStatus::LOCKED); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace ash | 179 } // namespace ash |
| OLD | NEW |