Disable overview mode by default.
[chromium-blink-merge.git] / ash / wm / session_state_controller_impl.h
blob3ffc221661a59e11501b6eab25aaa94c92ea6623
1 // Copyright (c) 2012 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.
5 #ifndef ASH_WM_SESSION_STATE_CONTROLLER_IMPL_H_
6 #define ASH_WM_SESSION_STATE_CONTROLLER_IMPL_H_
8 #include "ash/ash_export.h"
9 #include "ash/shell_observer.h"
10 #include "ash/wm/lock_state_controller.h"
11 #include "ash/wm/session_state_animator.h"
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h"
15 #include "base/timer/timer.h"
16 #include "ui/aura/root_window_observer.h"
18 namespace gfx {
19 class Rect;
20 class Size;
23 namespace ui {
24 class Layer;
27 namespace ash {
29 namespace test {
30 class PowerButtonControllerTest;
33 // Displays onscreen animations and locks or suspends the system in response to
34 // the power button being pressed or released.
35 class ASH_EXPORT SessionStateControllerImpl :
36 public LockStateController {
37 public:
39 // Helper class used by tests to access internal state.
40 class ASH_EXPORT TestApi {
41 public:
42 explicit TestApi(SessionStateControllerImpl* controller);
44 virtual ~TestApi();
46 bool lock_timer_is_running() const {
47 return controller_->lock_timer_.IsRunning();
49 bool lock_fail_timer_is_running() const {
50 return controller_->lock_fail_timer_.IsRunning();
52 bool lock_to_shutdown_timer_is_running() const {
53 return controller_->lock_to_shutdown_timer_.IsRunning();
55 bool shutdown_timer_is_running() const {
56 return controller_->pre_shutdown_timer_.IsRunning();
58 bool real_shutdown_timer_is_running() const {
59 return controller_->real_shutdown_timer_.IsRunning();
62 void trigger_lock_timeout() {
63 controller_->OnLockTimeout();
64 controller_->lock_timer_.Stop();
66 void trigger_lock_fail_timeout() {
67 controller_->OnLockFailTimeout();
68 controller_->lock_fail_timer_.Stop();
70 void trigger_lock_to_shutdown_timeout() {
71 controller_->OnLockToShutdownTimeout();
72 controller_->lock_to_shutdown_timer_.Stop();
74 void trigger_shutdown_timeout() {
75 controller_->OnPreShutdownAnimationTimeout();
76 controller_->pre_shutdown_timer_.Stop();
78 void trigger_real_shutdown_timeout() {
79 controller_->OnRealShutdownTimeout();
80 controller_->real_shutdown_timer_.Stop();
82 private:
83 SessionStateControllerImpl* controller_; // not owned
85 DISALLOW_COPY_AND_ASSIGN(TestApi);
88 SessionStateControllerImpl();
89 virtual ~SessionStateControllerImpl();
91 // RootWindowObserver override:
92 virtual void OnRootWindowHostCloseRequested(
93 const aura::RootWindow* root) OVERRIDE;
95 // ShellObserver overrides:
96 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
97 virtual void OnAppTerminating() OVERRIDE;
98 virtual void OnLockStateChanged(bool locked) OVERRIDE;
100 // SessionLockStateController overrides:
101 virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE;
103 virtual void StartShutdownAnimation() OVERRIDE;
104 virtual void StartLockAnimationAndLockImmediately() OVERRIDE;
106 virtual bool LockRequested() OVERRIDE;
107 virtual bool ShutdownRequested() OVERRIDE;
109 virtual bool CanCancelLockAnimation() OVERRIDE;
110 virtual void CancelLockAnimation() OVERRIDE;
112 virtual bool CanCancelShutdownAnimation() OVERRIDE;
113 virtual void CancelShutdownAnimation() OVERRIDE;
115 virtual void OnStartingLock() OVERRIDE;
116 virtual void RequestShutdown() OVERRIDE;
118 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE;
119 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE;
121 protected:
122 friend class test::PowerButtonControllerTest;
124 private:
125 void RequestShutdownImpl();
127 // Starts lock timer.
128 void StartLockTimer();
130 // Requests that the screen be locked and starts |lock_fail_timer_|.
131 void OnLockTimeout();
133 // Reverts the pre-lock animation, reports the error.
134 void OnLockFailTimeout();
136 // Starts timer for gap between lock and shutdown.
137 void StartLockToShutdownTimer();
139 // Calls StartShutdownAnimation().
140 void OnLockToShutdownTimeout();
142 // Starts timer for undoable shutdown animation.
143 void StartPreShutdownAnimationTimer();
145 // Calls RequestShutdownImpl();
146 void OnPreShutdownAnimationTimeout();
148 // Starts timer for final shutdown animation.
149 void StartRealShutdownTimer();
151 // Requests that the machine be shut down.
152 void OnRealShutdownTimeout();
154 // The current login status, or original login status from before we locked..
155 user::LoginStatus login_status_;
157 // Current lock status.
158 bool system_is_locked_;
160 // Are we in the process of shutting the machine down?
161 bool shutting_down_;
163 // Indicates whether controller should proceed to (cancellable) shutdown after
164 // locking.
165 bool shutdown_after_lock_;
167 // Started when the user first presses the power button while in a
168 // logged-in-as-a-non-guest-user, unlocked state. When it fires, we lock the
169 // screen.
170 base::OneShotTimer<SessionStateControllerImpl> lock_timer_;
172 // Started when we request that the screen be locked. When it fires, we
173 // assume that our request got dropped.
174 base::OneShotTimer<SessionStateControllerImpl> lock_fail_timer_;
176 // Started when the screen is locked while the power button is held. Adds a
177 // delay between the appearance of the lock screen and the beginning of the
178 // pre-shutdown animation.
179 base::OneShotTimer<SessionStateControllerImpl> lock_to_shutdown_timer_;
181 // Started when we begin displaying the pre-shutdown animation. When it
182 // fires, we start the shutdown animation and get ready to request shutdown.
183 base::OneShotTimer<SessionStateControllerImpl> pre_shutdown_timer_;
185 // Started when we display the shutdown animation. When it fires, we actually
186 // request shutdown. Gives the animation time to complete before Chrome, X,
187 // etc. are shut down.
188 base::OneShotTimer<SessionStateControllerImpl> real_shutdown_timer_;
190 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl);
193 } // namespace ash
195 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL_H_