last_window_closed_logout_reminder.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 3// found in the LICENSE file. 4 5#include "ash/system/chromeos/session/last_window_closed_logout_reminder.h" 6 7#include "ash/shell.h" 8#include "ash/system/chromeos/session/logout_confirmation_controller.h" 9#include "ash/system/tray/system_tray_delegate.h" 10#include "ash/system/tray/system_tray_notifier.h" 11#include "ash/system/user/login_status.h" 12#include "base/time/time.h" 13 14namespace ash { 15namespace internal { 16 17namespace { 18const int kLogoutConfirmationDelayInSeconds = 20; 19} 20 21LastWindowClosedLogoutReminder::LastWindowClosedLogoutReminder() { 22 Shell::GetInstance()->system_tray_notifier()->AddLastWindowClosedObserver( 23 this); 24} 25 26LastWindowClosedLogoutReminder::~LastWindowClosedLogoutReminder() { 27 Shell::GetInstance()->system_tray_notifier()->RemoveLastWindowClosedObserver( 28 this); 29} 30 31void LastWindowClosedLogoutReminder::OnLastWindowClosed() { 32 if (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() != 33 user::LOGGED_IN_PUBLIC) { 34 return; 35 } 36 37 // Ask the user to confirm logout if a public session is in progress and the 38 // screen is not locked. 39 Shell::GetInstance()->logout_confirmation_controller()->ConfirmLogout( 40 base::TimeTicks::Now() + 41 base::TimeDelta::FromSeconds(kLogoutConfirmationDelayInSeconds)); 42} 43 44} // namespace internal 45} // namespace ash 46