OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ | 5 #ifndef ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ |
6 #define ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ | 6 #define ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/shell_observer.h" | 9 #include "ash/shell_observer.h" |
10 #include "ash/wm/session_state_animator.h" | 10 #include "ash/wm/session_state_animator.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 } | 25 } |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 | 28 |
29 namespace test { | 29 namespace test { |
30 class SessionStateControllerImpl2Test; | 30 class SessionStateControllerImpl2Test; |
31 } | 31 } |
32 | 32 |
33 // Displays onscreen animations and locks or suspends the system in response to | 33 // Displays onscreen animations and locks or suspends the system in response to |
34 // the power button being pressed or released. | 34 // the power button being pressed or released. |
35 // Lock workflow: | |
36 // Entry points: | |
37 // * StartLockAnimation (bool shutdown after lock) - starts lock that can be | |
Daniel Erat
2012/12/13 21:47:33
nit: delete the "(bool shutdown after lock)" part
| |
38 // cancelled. | |
39 // * StartLockAnimationAndLockImmediately - starts uninterruptable lock | |
Daniel Erat
2012/12/13 21:47:33
nit: s/uninterruptable/uninterruptible/
| |
40 // animation. | |
41 // This leads to call of either StartImmediatePreLockAnimation or | |
42 // StartCancellablePreLockAnimation. Once they complete | |
43 // PreLockAnimationFinished is called, and system lock is requested. | |
44 // Once system locks and lock UI is created, OnLockStateChanged is called, and | |
45 // StartPostLockAnimation is called. In PostLockAnimationFinished two | |
46 // things happen : EVENT_LOCK_ANIMATION_FINISHED notification is sent (it | |
47 // triggers third part of animation within lock UI), and check for continuing to | |
48 // shutdown is made. | |
49 // | |
50 // Unlock workflow: | |
51 // WebUI does first part of animation, and calls OnLockScreenHide(callback) that | |
52 // triggers StartUnlockAnimationBeforeUIDestroyed(callback). Once callback is | |
53 // called at the end of the animation, lock UI is deleted, system unlocks, and | |
54 // OnLockStateChanged is called. It leads to | |
55 // StartUnlockAnimationAfterUIDestroyed. | |
56 | |
35 class ASH_EXPORT SessionStateControllerImpl2 : public SessionStateController { | 57 class ASH_EXPORT SessionStateControllerImpl2 : public SessionStateController { |
36 public: | 58 public: |
37 | 59 |
38 // Helper class used by tests to access internal state. | 60 // Helper class used by tests to access internal state. |
39 class ASH_EXPORT TestApi { | 61 class ASH_EXPORT TestApi { |
40 public: | 62 public: |
41 explicit TestApi(SessionStateControllerImpl2* controller); | 63 explicit TestApi(SessionStateControllerImpl2* controller); |
42 | 64 |
43 virtual ~TestApi(); | 65 virtual ~TestApi(); |
44 | 66 |
45 bool lock_timer_is_running() const { | |
46 return controller_->lock_timer_.IsRunning(); | |
47 } | |
48 bool lock_fail_timer_is_running() const { | 67 bool lock_fail_timer_is_running() const { |
49 return controller_->lock_fail_timer_.IsRunning(); | 68 return controller_->lock_fail_timer_.IsRunning(); |
50 } | 69 } |
51 bool lock_to_shutdown_timer_is_running() const { | 70 bool lock_to_shutdown_timer_is_running() const { |
52 return controller_->lock_to_shutdown_timer_.IsRunning(); | 71 return controller_->lock_to_shutdown_timer_.IsRunning(); |
53 } | 72 } |
54 bool shutdown_timer_is_running() const { | 73 bool shutdown_timer_is_running() const { |
55 return controller_->pre_shutdown_timer_.IsRunning(); | 74 return controller_->pre_shutdown_timer_.IsRunning(); |
56 } | 75 } |
57 bool real_shutdown_timer_is_running() const { | 76 bool real_shutdown_timer_is_running() const { |
58 return controller_->real_shutdown_timer_.IsRunning(); | 77 return controller_->real_shutdown_timer_.IsRunning(); |
59 } | 78 } |
79 bool is_animating_lock() const { | |
80 return controller_->animating_lock_; | |
81 } | |
82 bool is_lock_cancellable() const { | |
83 return controller_->can_cancel_lock_animation_; | |
Daniel Erat
2012/12/13 21:47:33
nit: call CanCancelLockAnimation() instead?
| |
84 } | |
60 | 85 |
61 void trigger_lock_timeout() { | |
62 controller_->OnLockTimeout(); | |
63 controller_->lock_timer_.Stop(); | |
64 } | |
65 void trigger_lock_fail_timeout() { | 86 void trigger_lock_fail_timeout() { |
66 controller_->OnLockFailTimeout(); | 87 controller_->OnLockFailTimeout(); |
67 controller_->lock_fail_timer_.Stop(); | 88 controller_->lock_fail_timer_.Stop(); |
68 } | 89 } |
69 void trigger_lock_to_shutdown_timeout() { | 90 void trigger_lock_to_shutdown_timeout() { |
70 controller_->OnLockToShutdownTimeout(); | 91 controller_->OnLockToShutdownTimeout(); |
71 controller_->lock_to_shutdown_timer_.Stop(); | 92 controller_->lock_to_shutdown_timer_.Stop(); |
72 } | 93 } |
73 void trigger_shutdown_timeout() { | 94 void trigger_shutdown_timeout() { |
74 controller_->OnPreShutdownAnimationTimeout(); | 95 controller_->OnPreShutdownAnimationTimeout(); |
75 controller_->pre_shutdown_timer_.Stop(); | 96 controller_->pre_shutdown_timer_.Stop(); |
76 } | 97 } |
77 void trigger_real_shutdown_timeout() { | 98 void trigger_real_shutdown_timeout() { |
78 controller_->OnRealShutdownTimeout(); | 99 controller_->OnRealShutdownTimeout(); |
79 controller_->real_shutdown_timer_.Stop(); | 100 controller_->real_shutdown_timer_.Stop(); |
80 } | 101 } |
81 private: | 102 private: |
82 SessionStateControllerImpl2* controller_; // not owned | 103 SessionStateControllerImpl2* controller_; // not owned |
83 | 104 |
84 DISALLOW_COPY_AND_ASSIGN(TestApi); | 105 DISALLOW_COPY_AND_ASSIGN(TestApi); |
85 }; | 106 }; |
86 | 107 |
108 struct UnlockedStateProperties { | |
Daniel Erat
2012/12/13 21:47:33
if this isn't accessed by other classes, move it t
| |
109 bool background_is_hidden; | |
110 }; | |
111 | |
87 SessionStateControllerImpl2(); | 112 SessionStateControllerImpl2(); |
88 virtual ~SessionStateControllerImpl2(); | 113 virtual ~SessionStateControllerImpl2(); |
89 | 114 |
90 // RootWindowObserver override: | 115 // RootWindowObserver override: |
91 virtual void OnRootWindowHostCloseRequested( | 116 virtual void OnRootWindowHostCloseRequested( |
92 const aura::RootWindow* root) OVERRIDE; | 117 const aura::RootWindow* root) OVERRIDE; |
93 | 118 |
94 // ShellObserver overrides: | 119 // ShellObserver overrides: |
95 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; | 120 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; |
96 virtual void OnAppTerminating() OVERRIDE; | 121 virtual void OnAppTerminating() OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... | |
116 | 141 |
117 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE; | 142 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE; |
118 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE; | 143 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE; |
119 | 144 |
120 protected: | 145 protected: |
121 friend class test::SessionStateControllerImpl2Test; | 146 friend class test::SessionStateControllerImpl2Test; |
122 | 147 |
123 private: | 148 private: |
124 void RequestShutdownImpl(); | 149 void RequestShutdownImpl(); |
125 | 150 |
126 // Starts lock timer. | |
127 void StartLockTimer(); | |
128 | |
129 // Requests that the screen be locked and starts |lock_fail_timer_|. | |
130 void OnLockTimeout(); | |
131 | |
132 // Reverts the pre-lock animation, reports the error. | 151 // Reverts the pre-lock animation, reports the error. |
133 void OnLockFailTimeout(); | 152 void OnLockFailTimeout(); |
134 | 153 |
135 // Starts timer for gap between lock and shutdown. | 154 // Starts timer for gap between lock and shutdown. |
136 void StartLockToShutdownTimer(); | 155 void StartLockToShutdownTimer(); |
137 | 156 |
138 // Calls StartShutdownAnimation(). | 157 // Calls StartShutdownAnimation(). |
139 void OnLockToShutdownTimeout(); | 158 void OnLockToShutdownTimeout(); |
140 | 159 |
141 // Starts timer for undoable shutdown animation. | 160 // Starts timer for undoable shutdown animation. |
142 void StartPreShutdownAnimationTimer(); | 161 void StartPreShutdownAnimationTimer(); |
143 | 162 |
144 // Calls RequestShutdownImpl(); | 163 // Calls RequestShutdownImpl(); |
145 void OnPreShutdownAnimationTimeout(); | 164 void OnPreShutdownAnimationTimeout(); |
146 | 165 |
147 // Starts timer for final shutdown animation. | 166 // Starts timer for final shutdown animation. |
148 void StartRealShutdownTimer(); | 167 // If |with_animation_time| is true, it will also include time of "fade to |
168 // white" shutdown animation. | |
169 void StartRealShutdownTimer(bool with_animation_time); | |
149 | 170 |
150 // Requests that the machine be shut down. | 171 // Requests that the machine be shut down. |
151 void OnRealShutdownTimeout(); | 172 void OnRealShutdownTimeout(); |
152 | 173 |
174 // Starts shutdown animation that can be cancelled and starts pre-shutdown | |
175 // timer. | |
176 void StartCancellableShutdownAnimation(); | |
177 | |
178 // Starts non-cancellable animation and starts real shutdown timer that | |
179 // includes animation time. | |
180 void StartShutdownAnimationImpl(); | |
181 | |
153 // Triggers late animations on the lock screen. | 182 // Triggers late animations on the lock screen. |
154 void OnLockScreenAnimationFinished(); | 183 void OnLockScreenAnimationFinished(); |
155 | 184 |
185 // Methods for initiating and checking different phases of | |
186 // lock/unlock animations: | |
187 // Lock phase one : windows lift (can be undone in some cases) | |
Daniel Erat
2012/12/13 21:47:33
nit: delete these outdated comments
| |
188 // Lock phase two : lock screen raises | |
189 // Unlock phase one : lock screen lowers | |
190 // Unlock phase two : windows drop down | |
191 | |
192 void StartImmediatePreLockAnimation(); | |
193 void StartCancellablePreLockAnimation(); | |
194 void CancelPreLockAnimation(); | |
195 void StartPostLockAnimation(); | |
196 // This method calls |callback| when animation completes. | |
197 void StartUnlockAnimationBeforeUIDestroyed(base::Closure &callback); | |
198 void StartUnlockAnimationAfterUIDestroyed(); | |
199 | |
200 // These methods are called when corresponding animation completes. | |
201 void LockAnimationCancelled(); | |
202 void PreLockAnimationFinished(); | |
203 void PostLockAnimationFinished(); | |
204 void UnlockAnimationAfterUIDestroyedFinished(); | |
205 | |
206 // Stores properties of UI that have to be temporary modified while locking. | |
Daniel Erat
2012/12/13 21:47:33
nit: s/temporary/temporarily/
| |
207 void StoreUnlockedProperties(); | |
208 void RestoreUnlockedProperties(); | |
209 | |
210 // Fades in background layer with |speed| if it was hidden in unlocked state. | |
211 void AnimateBackgroundAppearanceIfNecessary( | |
212 ash::internal::SessionStateAnimator::AnimationSpeed speed, | |
213 ui::LayerAnimationObserver* observer); | |
214 | |
215 // Fades out background layer with |speed| if it was hidden in unlocked state. | |
216 void AnimateBackgroundHidingIfNecessary( | |
217 ash::internal::SessionStateAnimator::AnimationSpeed speed, | |
218 ui::LayerAnimationObserver* observer); | |
219 | |
156 // The current login status, or original login status from before we locked. | 220 // The current login status, or original login status from before we locked. |
157 user::LoginStatus login_status_; | 221 user::LoginStatus login_status_; |
158 | 222 |
159 // Current lock status. | 223 // Current lock status. |
160 bool system_is_locked_; | 224 bool system_is_locked_; |
161 | 225 |
162 // Are we in the process of shutting the machine down? | 226 // Are we in the process of shutting the machine down? |
163 bool shutting_down_; | 227 bool shutting_down_; |
164 | 228 |
165 // Indicates whether controller should proceed to (cancellable) shutdown after | 229 // Indicates whether controller should proceed to (cancellable) shutdown after |
166 // locking. | 230 // locking. |
167 bool shutdown_after_lock_; | 231 bool shutdown_after_lock_; |
168 | 232 |
169 // Started when the user first presses the power button while in a | 233 // Indicates that controller displays lock animation. |
170 // logged-in-as-a-non-guest-user, unlocked state. When it fires, we lock the | 234 bool animating_lock_; |
171 // screen. | 235 |
172 base::OneShotTimer<SessionStateControllerImpl2> lock_timer_; | 236 // Indicates that lock animation can be undone. |
237 bool can_cancel_lock_animation_; | |
238 | |
239 scoped_ptr<UnlockedStateProperties> unlocked_properties_; | |
173 | 240 |
174 // Started when we request that the screen be locked. When it fires, we | 241 // Started when we request that the screen be locked. When it fires, we |
175 // assume that our request got dropped. | 242 // assume that our request got dropped. |
176 base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_; | 243 base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_; |
177 | 244 |
178 // Started when the screen is locked while the power button is held. Adds a | 245 // Started when the screen is locked while the power button is held. Adds a |
179 // delay between the appearance of the lock screen and the beginning of the | 246 // delay between the appearance of the lock screen and the beginning of the |
180 // pre-shutdown animation. | 247 // pre-shutdown animation. |
181 base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_; | 248 base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_; |
182 | 249 |
183 // Started when we begin displaying the pre-shutdown animation. When it | 250 // Started when we begin displaying the pre-shutdown animation. When it |
184 // fires, we start the shutdown animation and get ready to request shutdown. | 251 // fires, we start the shutdown animation and get ready to request shutdown. |
185 base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_; | 252 base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_; |
186 | 253 |
187 // Started when we display the shutdown animation. When it fires, we actually | 254 // Started when we display the shutdown animation. When it fires, we actually |
188 // request shutdown. Gives the animation time to complete before Chrome, X, | 255 // request shutdown. Gives the animation time to complete before Chrome, X, |
189 // etc. are shut down. | 256 // etc. are shut down. |
190 base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_; | 257 base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_; |
191 | 258 |
192 base::Closure lock_screen_displayed_callback_; | 259 base::Closure lock_screen_displayed_callback_; |
193 | 260 |
194 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2); | 261 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2); |
195 }; | 262 }; |
196 | 263 |
197 } // namespace ash | 264 } // namespace ash |
198 | 265 |
199 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ | 266 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ |
OLD | NEW |