Index: ash/common/system/chromeos/session/logout_confirmation_controller.cc |
diff --git a/ash/system/chromeos/session/logout_confirmation_controller.cc b/ash/common/system/chromeos/session/logout_confirmation_controller.cc |
similarity index 69% |
rename from ash/system/chromeos/session/logout_confirmation_controller.cc |
rename to ash/common/system/chromeos/session/logout_confirmation_controller.cc |
index fba683a54b6c236546dbd1aa6cbfd776b2e49f0c..80726792bb7b4cec31103ed29c003607d19f12c2 100644 |
--- a/ash/system/chromeos/session/logout_confirmation_controller.cc |
+++ b/ash/common/system/chromeos/session/logout_confirmation_controller.cc |
@@ -2,18 +2,24 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ash/system/chromeos/session/logout_confirmation_controller.h" |
+#include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
#include <utility> |
+#include "ash/common/login_status.h" |
+#include "ash/common/system/chromeos/session/logout_confirmation_dialog.h" |
+#include "ash/common/system/tray/system_tray_delegate.h" |
+#include "ash/common/system/tray/system_tray_notifier.h" |
#include "ash/common/wm_shell.h" |
-#include "ash/system/chromeos/session/logout_confirmation_dialog.h" |
#include "base/location.h" |
#include "base/time/default_tick_clock.h" |
#include "base/time/tick_clock.h" |
#include "ui/views/widget/widget.h" |
namespace ash { |
+namespace { |
+const int kLogoutConfirmationDelayInSeconds = 20; |
+} |
LogoutConfirmationController::LogoutConfirmationController( |
const base::Closure& logout_closure) |
@@ -21,13 +27,18 @@ LogoutConfirmationController::LogoutConfirmationController( |
logout_closure_(logout_closure), |
dialog_(NULL), |
logout_timer_(false, false) { |
- if (WmShell::HasInstance()) |
+ if (WmShell::HasInstance()) { |
WmShell::Get()->AddShellObserver(this); |
+ WmShell::Get()->system_tray_notifier()->AddLastWindowClosedObserver(this); |
+ } |
} |
LogoutConfirmationController::~LogoutConfirmationController() { |
- if (WmShell::HasInstance()) |
+ if (WmShell::HasInstance()) { |
WmShell::Get()->RemoveShellObserver(this); |
+ WmShell::Get()->system_tray_notifier()->RemoveLastWindowClosedObserver( |
+ this); |
+ } |
if (dialog_) |
dialog_->ControllerGone(); |
} |
@@ -81,4 +92,17 @@ void LogoutConfirmationController::OnDialogClosed() { |
logout_timer_.Stop(); |
} |
+void LogoutConfirmationController::OnLastWindowClosed() { |
+ if (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
+ LoginStatus::PUBLIC) { |
+ return; |
+ } |
+ |
+ // Ask the user to confirm logout if a public session is in progress and the |
+ // screen is not locked. |
+ ConfirmLogout( |
+ base::TimeTicks::Now() + |
+ base::TimeDelta::FromSeconds(kLogoutConfirmationDelayInSeconds)); |
+} |
+ |
} // namespace ash |