| 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/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/tray/system_tray_delegate.h" | 12 #include "ash/common/system/tray/system_tray_delegate.h" |
| 12 #include "ash/common/system/tray/system_tray_notifier.h" | 13 #include "ash/common/system/tray/system_tray_notifier.h" |
| 13 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
| 14 #include "ash/common/system/tray/tray_utils.h" | 15 #include "ash/common/system/tray/tray_utils.h" |
| 15 #include "ash/common/system/user/login_status.h" | 16 #include "ash/common/system/user/login_status.h" |
| 16 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 17 #include "ash/shell.h" | |
| 18 #include "ash/system/chromeos/session/logout_confirmation_controller.h" | |
| 19 #include "base/logging.h" | 18 #include "base/logging.h" |
| 20 #include "grit/ash_resources.h" | 19 #include "grit/ash_resources.h" |
| 21 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 22 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 23 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
| 24 #include "ui/gfx/geometry/size.h" | 23 #include "ui/gfx/geometry/size.h" |
| 25 #include "ui/views/bubble/tray_bubble_view.h" | 24 #include "ui/views/bubble/tray_bubble_view.h" |
| 26 #include "ui/views/controls/button/label_button.h" | 25 #include "ui/views/controls/button/label_button.h" |
| 27 #include "ui/views/controls/button/label_button_border.h" | 26 #include "ui/views/controls/button/label_button_border.h" |
| 28 #include "ui/views/painter.h" | 27 #include "ui/views/painter.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 void LogoutButtonTray::OnLogoutDialogDurationChanged(base::TimeDelta duration) { | 130 void LogoutButtonTray::OnLogoutDialogDurationChanged(base::TimeDelta duration) { |
| 132 dialog_duration_ = duration; | 131 dialog_duration_ = duration; |
| 133 } | 132 } |
| 134 | 133 |
| 135 void LogoutButtonTray::ButtonPressed(views::Button* sender, | 134 void LogoutButtonTray::ButtonPressed(views::Button* sender, |
| 136 const ui::Event& event) { | 135 const ui::Event& event) { |
| 137 DCHECK_EQ(sender, button_); | 136 DCHECK_EQ(sender, button_); |
| 138 if (dialog_duration_ <= base::TimeDelta()) { | 137 if (dialog_duration_ <= base::TimeDelta()) { |
| 139 // Sign out immediately if |dialog_duration_| is non-positive. | 138 // Sign out immediately if |dialog_duration_| is non-positive. |
| 140 WmShell::Get()->system_tray_delegate()->SignOut(); | 139 WmShell::Get()->system_tray_delegate()->SignOut(); |
| 141 } else if (Shell::GetInstance()->logout_confirmation_controller()) { | 140 } else if (WmShell::Get()->logout_confirmation_controller()) { |
| 142 Shell::GetInstance()->logout_confirmation_controller()->ConfirmLogout( | 141 WmShell::Get()->logout_confirmation_controller()->ConfirmLogout( |
| 143 base::TimeTicks::Now() + dialog_duration_); | 142 base::TimeTicks::Now() + dialog_duration_); |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 | 145 |
| 147 void LogoutButtonTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { | 146 void LogoutButtonTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { |
| 148 login_status_ = login_status; | 147 login_status_ = login_status; |
| 149 const base::string16 title = | 148 const base::string16 title = |
| 150 user::GetLocalizedSignOutStringForStatus(login_status, false); | 149 user::GetLocalizedSignOutStringForStatus(login_status, false); |
| 151 button_->SetText(title); | 150 button_->SetText(title); |
| 152 button_->SetAccessibleName(title); | 151 button_->SetAccessibleName(title); |
| 153 UpdateVisibility(); | 152 UpdateVisibility(); |
| 154 } | 153 } |
| 155 | 154 |
| 156 void LogoutButtonTray::UpdateVisibility() { | 155 void LogoutButtonTray::UpdateVisibility() { |
| 157 SetVisible(show_logout_button_in_tray_ && | 156 SetVisible(show_logout_button_in_tray_ && |
| 158 login_status_ != LoginStatus::NOT_LOGGED_IN && | 157 login_status_ != LoginStatus::NOT_LOGGED_IN && |
| 159 login_status_ != LoginStatus::LOCKED); | 158 login_status_ != LoginStatus::LOCKED); |
| 160 } | 159 } |
| 161 | 160 |
| 162 } // namespace ash | 161 } // namespace ash |
| OLD | NEW |