OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LOCK_STATE_CONTROLLER_H_ | 5 #ifndef ASH_WM_LOCK_STATE_CONTROLLER_H_ |
6 #define ASH_WM_LOCK_STATE_CONTROLLER_H_ | 6 #define ASH_WM_LOCK_STATE_CONTROLLER_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/lock_state_observer.h" | 10 #include "ash/wm/lock_state_observer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 private: | 45 private: |
46 DISALLOW_COPY_AND_ASSIGN(LockStateControllerDelegate); | 46 DISALLOW_COPY_AND_ASSIGN(LockStateControllerDelegate); |
47 }; | 47 }; |
48 | 48 |
49 // Displays onscreen animations and locks or suspends the system in response to | 49 // Displays onscreen animations and locks or suspends the system in response to |
50 // the power button being pressed or released. | 50 // the power button being pressed or released. |
51 // Lock workflow: | 51 // Lock workflow: |
52 // Entry points: | 52 // Entry points: |
53 // * StartLockAnimation (bool shutdown after lock) - starts lock that can be | 53 // * StartLockAnimation (bool shutdown after lock) - starts lock that can be |
54 // cancelled. | 54 // cancelled. |
55 // * StartLockAnimationAndLockImmediately - starts uninterruptible lock | 55 // * StartLockAnimationAndLockImmediately (bool shutdown after lock) - starts |
56 // animation. | 56 // uninterruptible lock animation. |
57 // This leads to call of either StartImmediatePreLockAnimation or | 57 // This leads to call of either StartImmediatePreLockAnimation or |
58 // StartCancellablePreLockAnimation. Once they complete | 58 // StartCancellablePreLockAnimation. Once they complete |
59 // PreLockAnimationFinished is called, and system lock is requested. | 59 // PreLockAnimationFinished is called, and system lock is requested. |
60 // Once system locks and lock UI is created, OnLockStateChanged is called, and | 60 // Once system locks and lock UI is created, OnLockStateChanged is called, and |
61 // StartPostLockAnimation is called. In PostLockAnimationFinished two | 61 // StartPostLockAnimation is called. In PostLockAnimationFinished two |
62 // things happen : EVENT_LOCK_ANIMATION_FINISHED notification is sent (it | 62 // things happen : EVENT_LOCK_ANIMATION_FINISHED notification is sent (it |
63 // triggers third part of animation within lock UI), and check for continuing to | 63 // triggers third part of animation within lock UI), and check for continuing to |
64 // shutdown is made. | 64 // shutdown is made. |
65 // | 65 // |
66 // Unlock workflow: | 66 // Unlock workflow: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 controller_->lock_to_shutdown_timer_.Stop(); | 128 controller_->lock_to_shutdown_timer_.Stop(); |
129 } | 129 } |
130 void trigger_shutdown_timeout() { | 130 void trigger_shutdown_timeout() { |
131 controller_->OnPreShutdownAnimationTimeout(); | 131 controller_->OnPreShutdownAnimationTimeout(); |
132 controller_->pre_shutdown_timer_.Stop(); | 132 controller_->pre_shutdown_timer_.Stop(); |
133 } | 133 } |
134 void trigger_real_shutdown_timeout() { | 134 void trigger_real_shutdown_timeout() { |
135 controller_->OnRealShutdownTimeout(); | 135 controller_->OnRealShutdownTimeout(); |
136 controller_->real_shutdown_timer_.Stop(); | 136 controller_->real_shutdown_timer_.Stop(); |
137 } | 137 } |
138 | |
138 private: | 139 private: |
139 LockStateController* controller_; // not owned | 140 LockStateController* controller_; // not owned |
140 | 141 |
141 DISALLOW_COPY_AND_ASSIGN(TestApi); | 142 DISALLOW_COPY_AND_ASSIGN(TestApi); |
142 }; | 143 }; |
143 | 144 |
144 LockStateController(); | 145 LockStateController(); |
145 virtual ~LockStateController(); | 146 virtual ~LockStateController(); |
146 | 147 |
147 // Takes ownership of |delegate|. | 148 // Takes ownership of |delegate|. |
148 void SetDelegate(LockStateControllerDelegate* delegate); | 149 void SetDelegate(LockStateControllerDelegate* delegate); |
Daniel Erat
2014/09/08 16:16:02
nit: mind making the argument be a scoped_ptr so t
bruthig
2014/09/09 17:32:34
Done.
| |
149 | 150 |
150 void AddObserver(LockStateObserver* observer); | 151 void AddObserver(LockStateObserver* observer); |
151 void RemoveObserver(LockStateObserver* observer); | 152 void RemoveObserver(LockStateObserver* observer); |
152 bool HasObserver(LockStateObserver* observer); | 153 bool HasObserver(LockStateObserver* observer); |
153 | 154 |
154 // Starts locking (with slow animation) that can be cancelled. | 155 // Starts locking (with slow animation) that can be cancelled. |
155 // After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation() | 156 // After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation() |
156 // will be called unless CancelShutdownAnimation() is called, if | 157 // will be called unless CancelShutdownAnimation() is called, if |
157 // |shutdown_after_lock| is true. | 158 // |shutdown_after_lock| is true. |
158 void StartLockAnimation(bool shutdown_after_lock); | 159 void StartLockAnimation(bool shutdown_after_lock); |
159 | 160 |
160 // Starts shutting down (with slow animation) that can be cancelled. | 161 // Starts shutting down (with slow animation) that can be cancelled. |
161 void StartShutdownAnimation(); | 162 void StartShutdownAnimation(); |
162 | 163 |
163 // Starts usual lock animation, but locks immediately. | 164 // Starts usual lock animation, but locks immediately. After locking and |
164 // Unlike StartLockAnimation it does no lead to StartShutdownAnimation. | 165 // |kLockToShutdownTimeoutMs| StartShutdownAnimation() will be called unless |
165 void StartLockAnimationAndLockImmediately(); | 166 // CancelShutdownAnimation() is called, if |shutdown_after_lock| is true. |
167 void StartLockAnimationAndLockImmediately(bool shutdown_after_lock); | |
166 | 168 |
167 // Returns true if we have requested system to lock, but haven't received | 169 // Returns true if we have requested system to lock, but haven't received |
168 // confirmation yet. | 170 // confirmation yet. |
169 bool LockRequested(); | 171 bool LockRequested(); |
170 | 172 |
171 // Returns true if we are shutting down. | 173 // Returns true if we are shutting down. |
172 bool ShutdownRequested(); | 174 bool ShutdownRequested(); |
173 | 175 |
174 // Returns true if we are within cancellable lock timeframe. | 176 // Returns true if we are within cancellable lock timeframe. |
175 bool CanCancelLockAnimation(); | 177 bool CanCancelLockAnimation(); |
(...skipping 23 matching lines...) Expand all Loading... | |
199 void SetLockScreenDisplayedCallback(const base::Closure& callback); | 201 void SetLockScreenDisplayedCallback(const base::Closure& callback); |
200 | 202 |
201 // aura::WindowTreeHostObserver override: | 203 // aura::WindowTreeHostObserver override: |
202 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; | 204 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; |
203 | 205 |
204 // ShellObserver overrides: | 206 // ShellObserver overrides: |
205 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; | 207 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; |
206 virtual void OnAppTerminating() OVERRIDE; | 208 virtual void OnAppTerminating() OVERRIDE; |
207 virtual void OnLockStateChanged(bool locked) OVERRIDE; | 209 virtual void OnLockStateChanged(bool locked) OVERRIDE; |
208 | 210 |
211 void set_animator_for_test(SessionStateAnimator* animator) { | |
212 animator_.reset(animator); | |
213 } | |
214 | |
209 private: | 215 private: |
210 friend class test::PowerButtonControllerTest; | 216 friend class test::PowerButtonControllerTest; |
211 friend class test::LockStateControllerTest; | 217 friend class test::LockStateControllerTest; |
212 | 218 |
213 struct UnlockedStateProperties { | 219 struct UnlockedStateProperties { |
214 bool background_is_hidden; | 220 bool background_is_hidden; |
215 }; | 221 }; |
216 | 222 |
217 // Reverts the pre-lock animation, reports the error. | 223 // Reverts the pre-lock animation, reports the error. |
218 void OnLockFailTimeout(); | 224 void OnLockFailTimeout(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 void PostLockAnimationFinished(); | 265 void PostLockAnimationFinished(); |
260 void UnlockAnimationAfterUIDestroyedFinished(); | 266 void UnlockAnimationAfterUIDestroyedFinished(); |
261 | 267 |
262 // Stores properties of UI that have to be temporarily modified while locking. | 268 // Stores properties of UI that have to be temporarily modified while locking. |
263 void StoreUnlockedProperties(); | 269 void StoreUnlockedProperties(); |
264 void RestoreUnlockedProperties(); | 270 void RestoreUnlockedProperties(); |
265 | 271 |
266 // Fades in background layer with |speed| if it was hidden in unlocked state. | 272 // Fades in background layer with |speed| if it was hidden in unlocked state. |
267 void AnimateBackgroundAppearanceIfNecessary( | 273 void AnimateBackgroundAppearanceIfNecessary( |
268 ash::SessionStateAnimator::AnimationSpeed speed, | 274 ash::SessionStateAnimator::AnimationSpeed speed, |
269 ui::LayerAnimationObserver* observer); | 275 SessionStateAnimator::AnimationSequence* animation_sequence); |
270 | 276 |
271 // Fades out background layer with |speed| if it was hidden in unlocked state. | 277 // Fades out background layer with |speed| if it was hidden in unlocked state. |
272 void AnimateBackgroundHidingIfNecessary( | 278 void AnimateBackgroundHidingIfNecessary( |
273 ash::SessionStateAnimator::AnimationSpeed speed, | 279 ash::SessionStateAnimator::AnimationSpeed speed, |
274 ui::LayerAnimationObserver* observer); | 280 SessionStateAnimator::AnimationSequence* animation_sequence); |
275 | 281 |
276 scoped_ptr<SessionStateAnimator> animator_; | 282 scoped_ptr<SessionStateAnimator> animator_; |
277 | 283 |
278 scoped_ptr<LockStateControllerDelegate> delegate_; | 284 scoped_ptr<LockStateControllerDelegate> delegate_; |
279 | 285 |
280 ObserverList<LockStateObserver> observers_; | 286 ObserverList<LockStateObserver> observers_; |
281 | 287 |
282 // The current login status, or original login status from before we locked. | 288 // The current login status, or original login status from before we locked. |
283 user::LoginStatus login_status_; | 289 user::LoginStatus login_status_; |
284 | 290 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 base::Closure lock_screen_displayed_callback_; | 327 base::Closure lock_screen_displayed_callback_; |
322 | 328 |
323 base::WeakPtrFactory<LockStateController> weak_ptr_factory_; | 329 base::WeakPtrFactory<LockStateController> weak_ptr_factory_; |
324 | 330 |
325 DISALLOW_COPY_AND_ASSIGN(LockStateController); | 331 DISALLOW_COPY_AND_ASSIGN(LockStateController); |
326 }; | 332 }; |
327 | 333 |
328 } // namespace ash | 334 } // namespace ash |
329 | 335 |
330 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_ | 336 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_ |
OLD | NEW |