| 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/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/tray/system_tray_delegate.h" | 11 #include "ash/common/system/tray/system_tray_delegate.h" |
| 12 #include "ash/common/system/tray/tray_constants.h" | 12 #include "ash/common/system/tray/tray_constants.h" |
| 13 #include "ash/common/wm_shell.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "ash/system/chromeos/session/logout_confirmation_controller.h" | 15 #include "ash/system/chromeos/session/logout_confirmation_controller.h" |
| 15 #include "ash/system/status_area_widget.h" | 16 #include "ash/system/status_area_widget.h" |
| 16 #include "ash/system/tray/system_tray_notifier.h" | 17 #include "ash/system/tray/system_tray_notifier.h" |
| 17 #include "ash/system/tray/tray_utils.h" | 18 #include "ash/system/tray/tray_utils.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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 132 |
| 132 void LogoutButtonTray::OnLogoutDialogDurationChanged(base::TimeDelta duration) { | 133 void LogoutButtonTray::OnLogoutDialogDurationChanged(base::TimeDelta duration) { |
| 133 dialog_duration_ = duration; | 134 dialog_duration_ = duration; |
| 134 } | 135 } |
| 135 | 136 |
| 136 void LogoutButtonTray::ButtonPressed(views::Button* sender, | 137 void LogoutButtonTray::ButtonPressed(views::Button* sender, |
| 137 const ui::Event& event) { | 138 const ui::Event& event) { |
| 138 DCHECK_EQ(sender, button_); | 139 DCHECK_EQ(sender, button_); |
| 139 if (dialog_duration_ <= base::TimeDelta()) { | 140 if (dialog_duration_ <= base::TimeDelta()) { |
| 140 // Sign out immediately if |dialog_duration_| is non-positive. | 141 // Sign out immediately if |dialog_duration_| is non-positive. |
| 141 Shell::GetInstance()->system_tray_delegate()->SignOut(); | 142 WmShell::Get()->system_tray_delegate()->SignOut(); |
| 142 } else if (Shell::GetInstance()->logout_confirmation_controller()) { | 143 } else if (Shell::GetInstance()->logout_confirmation_controller()) { |
| 143 Shell::GetInstance()->logout_confirmation_controller()->ConfirmLogout( | 144 Shell::GetInstance()->logout_confirmation_controller()->ConfirmLogout( |
| 144 base::TimeTicks::Now() + dialog_duration_); | 145 base::TimeTicks::Now() + dialog_duration_); |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 | 148 |
| 148 void LogoutButtonTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { | 149 void LogoutButtonTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { |
| 149 login_status_ = login_status; | 150 login_status_ = login_status; |
| 150 const base::string16 title = | 151 const base::string16 title = |
| 151 user::GetLocalizedSignOutStringForStatus(login_status, false); | 152 user::GetLocalizedSignOutStringForStatus(login_status, false); |
| 152 button_->SetText(title); | 153 button_->SetText(title); |
| 153 button_->SetAccessibleName(title); | 154 button_->SetAccessibleName(title); |
| 154 UpdateVisibility(); | 155 UpdateVisibility(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void LogoutButtonTray::UpdateVisibility() { | 158 void LogoutButtonTray::UpdateVisibility() { |
| 158 SetVisible(show_logout_button_in_tray_ && | 159 SetVisible(show_logout_button_in_tray_ && |
| 159 login_status_ != LoginStatus::NOT_LOGGED_IN && | 160 login_status_ != LoginStatus::NOT_LOGGED_IN && |
| 160 login_status_ != LoginStatus::LOCKED); | 161 login_status_ != LoginStatus::LOCKED); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } // namespace ash | 164 } // namespace ash |
| OLD | NEW |