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

Side by Side Diff: ash/wm/session_state_controller_impl.h

Issue 24980006: ash: Remove old lock animation implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge again Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/session_state_controller_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef ASH_WM_SESSION_STATE_CONTROLLER_IMPL_H_
6 #define ASH_WM_SESSION_STATE_CONTROLLER_IMPL_H_
7
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"
17
18 namespace gfx {
19 class Rect;
20 class Size;
21 }
22
23 namespace ui {
24 class Layer;
25 }
26
27 namespace ash {
28
29 namespace test {
30 class PowerButtonControllerTest;
31 }
32
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:
38
39 // Helper class used by tests to access internal state.
40 class ASH_EXPORT TestApi {
41 public:
42 explicit TestApi(SessionStateControllerImpl* controller);
43
44 virtual ~TestApi();
45
46 bool lock_timer_is_running() const {
47 return controller_->lock_timer_.IsRunning();
48 }
49 bool lock_fail_timer_is_running() const {
50 return controller_->lock_fail_timer_.IsRunning();
51 }
52 bool lock_to_shutdown_timer_is_running() const {
53 return controller_->lock_to_shutdown_timer_.IsRunning();
54 }
55 bool shutdown_timer_is_running() const {
56 return controller_->pre_shutdown_timer_.IsRunning();
57 }
58 bool real_shutdown_timer_is_running() const {
59 return controller_->real_shutdown_timer_.IsRunning();
60 }
61
62 void trigger_lock_timeout() {
63 controller_->OnLockTimeout();
64 controller_->lock_timer_.Stop();
65 }
66 void trigger_lock_fail_timeout() {
67 controller_->OnLockFailTimeout();
68 controller_->lock_fail_timer_.Stop();
69 }
70 void trigger_lock_to_shutdown_timeout() {
71 controller_->OnLockToShutdownTimeout();
72 controller_->lock_to_shutdown_timer_.Stop();
73 }
74 void trigger_shutdown_timeout() {
75 controller_->OnPreShutdownAnimationTimeout();
76 controller_->pre_shutdown_timer_.Stop();
77 }
78 void trigger_real_shutdown_timeout() {
79 controller_->OnRealShutdownTimeout();
80 controller_->real_shutdown_timer_.Stop();
81 }
82 private:
83 SessionStateControllerImpl* controller_; // not owned
84
85 DISALLOW_COPY_AND_ASSIGN(TestApi);
86 };
87
88 SessionStateControllerImpl();
89 virtual ~SessionStateControllerImpl();
90
91 // RootWindowObserver override:
92 virtual void OnRootWindowHostCloseRequested(
93 const aura::RootWindow* root) OVERRIDE;
94
95 // ShellObserver overrides:
96 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
97 virtual void OnAppTerminating() OVERRIDE;
98 virtual void OnLockStateChanged(bool locked) OVERRIDE;
99
100 // SessionLockStateController overrides:
101 virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE;
102
103 virtual void StartShutdownAnimation() OVERRIDE;
104 virtual void StartLockAnimationAndLockImmediately() OVERRIDE;
105
106 virtual bool LockRequested() OVERRIDE;
107 virtual bool ShutdownRequested() OVERRIDE;
108
109 virtual bool CanCancelLockAnimation() OVERRIDE;
110 virtual void CancelLockAnimation() OVERRIDE;
111
112 virtual bool CanCancelShutdownAnimation() OVERRIDE;
113 virtual void CancelShutdownAnimation() OVERRIDE;
114
115 virtual void OnStartingLock() OVERRIDE;
116 virtual void RequestShutdown() OVERRIDE;
117
118 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE;
119 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE;
120
121 protected:
122 friend class test::PowerButtonControllerTest;
123
124 private:
125 void RequestShutdownImpl();
126
127 // Starts lock timer.
128 void StartLockTimer();
129
130 // Requests that the screen be locked and starts |lock_fail_timer_|.
131 void OnLockTimeout();
132
133 // Reverts the pre-lock animation, reports the error.
134 void OnLockFailTimeout();
135
136 // Starts timer for gap between lock and shutdown.
137 void StartLockToShutdownTimer();
138
139 // Calls StartShutdownAnimation().
140 void OnLockToShutdownTimeout();
141
142 // Starts timer for undoable shutdown animation.
143 void StartPreShutdownAnimationTimer();
144
145 // Calls RequestShutdownImpl();
146 void OnPreShutdownAnimationTimeout();
147
148 // Starts timer for final shutdown animation.
149 void StartRealShutdownTimer();
150
151 // Requests that the machine be shut down.
152 void OnRealShutdownTimeout();
153
154 // The current login status, or original login status from before we locked..
155 user::LoginStatus login_status_;
156
157 // Current lock status.
158 bool system_is_locked_;
159
160 // Are we in the process of shutting the machine down?
161 bool shutting_down_;
162
163 // Indicates whether controller should proceed to (cancellable) shutdown after
164 // locking.
165 bool shutdown_after_lock_;
166
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_;
171
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_;
175
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_;
180
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_;
184
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_;
189
190 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl);
191 };
192
193 } // namespace ash
194
195 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/session_state_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698