Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: ash/common/system/chromeos/session/logout_confirmation_controller.cc

Issue 2739763003: Moves maintaining ShellObservers back to Shell (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_confirmation_controller.h" 5 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/login_status.h" 9 #include "ash/common/login_status.h"
10 #include "ash/common/system/chromeos/session/logout_confirmation_dialog.h" 10 #include "ash/common/system/chromeos/session/logout_confirmation_dialog.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/system_tray_notifier.h" 12 #include "ash/common/system/tray/system_tray_notifier.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ash/shell.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/time/default_tick_clock.h" 16 #include "base/time/default_tick_clock.h"
16 #include "base/time/tick_clock.h" 17 #include "base/time/tick_clock.h"
17 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
18 19
19 namespace ash { 20 namespace ash {
20 namespace { 21 namespace {
21 const int kLogoutConfirmationDelayInSeconds = 20; 22 const int kLogoutConfirmationDelayInSeconds = 20;
22 } 23 }
23 24
24 LogoutConfirmationController::LogoutConfirmationController( 25 LogoutConfirmationController::LogoutConfirmationController(
25 const base::Closure& logout_closure) 26 const base::Closure& logout_closure)
26 : clock_(new base::DefaultTickClock), 27 : clock_(new base::DefaultTickClock),
27 logout_closure_(logout_closure), 28 logout_closure_(logout_closure),
28 dialog_(NULL), 29 dialog_(NULL),
29 logout_timer_(false, false) { 30 logout_timer_(false, false) {
30 if (WmShell::HasInstance()) { 31 if (WmShell::HasInstance()) {
31 WmShell::Get()->AddShellObserver(this); 32 Shell::GetInstance()->AddShellObserver(this);
32 WmShell::Get()->system_tray_notifier()->AddLastWindowClosedObserver(this); 33 WmShell::Get()->system_tray_notifier()->AddLastWindowClosedObserver(this);
33 } 34 }
34 } 35 }
35 36
36 LogoutConfirmationController::~LogoutConfirmationController() { 37 LogoutConfirmationController::~LogoutConfirmationController() {
37 if (WmShell::HasInstance()) { 38 if (WmShell::HasInstance()) {
38 WmShell::Get()->RemoveShellObserver(this); 39 Shell::GetInstance()->RemoveShellObserver(this);
39 WmShell::Get()->system_tray_notifier()->RemoveLastWindowClosedObserver( 40 WmShell::Get()->system_tray_notifier()->RemoveLastWindowClosedObserver(
40 this); 41 this);
41 } 42 }
42 if (dialog_) 43 if (dialog_)
43 dialog_->ControllerGone(); 44 dialog_->ControllerGone();
44 } 45 }
45 46
46 void LogoutConfirmationController::ConfirmLogout(base::TimeTicks logout_time) { 47 void LogoutConfirmationController::ConfirmLogout(base::TimeTicks logout_time) {
47 if (!logout_time_.is_null() && logout_time >= logout_time_) { 48 if (!logout_time_.is_null() && logout_time >= logout_time_) {
48 // If a confirmation dialog is already being shown and its countdown expires 49 // If a confirmation dialog is already being shown and its countdown expires
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 100 }
100 101
101 // Ask the user to confirm logout if a public session is in progress and the 102 // Ask the user to confirm logout if a public session is in progress and the
102 // screen is not locked. 103 // screen is not locked.
103 ConfirmLogout( 104 ConfirmLogout(
104 base::TimeTicks::Now() + 105 base::TimeTicks::Now() +
105 base::TimeDelta::FromSeconds(kLogoutConfirmationDelayInSeconds)); 106 base::TimeDelta::FromSeconds(kLogoutConfirmationDelayInSeconds));
106 } 107 }
107 108
108 } // namespace ash 109 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698