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

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

Issue 326813004: Added quick lock mechanism while in Touchview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ASH_EXPORT to SessionStateAnimator Created 6 years, 3 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
« no previous file with comments | « ash/test/test_session_state_animator.cc ('k') | ash/wm/lock_state_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 void SetDelegate(scoped_ptr<LockStateControllerDelegate> delegate);
148 void SetDelegate(LockStateControllerDelegate* delegate);
149 149
150 void AddObserver(LockStateObserver* observer); 150 void AddObserver(LockStateObserver* observer);
151 void RemoveObserver(LockStateObserver* observer); 151 void RemoveObserver(LockStateObserver* observer);
152 bool HasObserver(LockStateObserver* observer); 152 bool HasObserver(LockStateObserver* observer);
153 153
154 // Starts locking (with slow animation) that can be cancelled. 154 // Starts locking (with slow animation) that can be cancelled.
155 // After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation() 155 // After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation()
156 // will be called unless CancelShutdownAnimation() is called, if 156 // will be called unless CancelShutdownAnimation() is called, if
157 // |shutdown_after_lock| is true. 157 // |shutdown_after_lock| is true.
158 void StartLockAnimation(bool shutdown_after_lock); 158 void StartLockAnimation(bool shutdown_after_lock);
159 159
160 // Starts shutting down (with slow animation) that can be cancelled. 160 // Starts shutting down (with slow animation) that can be cancelled.
161 void StartShutdownAnimation(); 161 void StartShutdownAnimation();
162 162
163 // Starts usual lock animation, but locks immediately. 163 // Starts usual lock animation, but locks immediately. After locking and
164 // Unlike StartLockAnimation it does no lead to StartShutdownAnimation. 164 // |kLockToShutdownTimeoutMs| StartShutdownAnimation() will be called unless
165 void StartLockAnimationAndLockImmediately(); 165 // CancelShutdownAnimation() is called, if |shutdown_after_lock| is true.
166 void StartLockAnimationAndLockImmediately(bool shutdown_after_lock);
166 167
167 // Returns true if we have requested system to lock, but haven't received 168 // Returns true if we have requested system to lock, but haven't received
168 // confirmation yet. 169 // confirmation yet.
169 bool LockRequested(); 170 bool LockRequested();
170 171
171 // Returns true if we are shutting down. 172 // Returns true if we are shutting down.
172 bool ShutdownRequested(); 173 bool ShutdownRequested();
173 174
174 // Returns true if we are within cancellable lock timeframe. 175 // Returns true if we are within cancellable lock timeframe.
175 bool CanCancelLockAnimation(); 176 bool CanCancelLockAnimation();
(...skipping 23 matching lines...) Expand all
199 void SetLockScreenDisplayedCallback(const base::Closure& callback); 200 void SetLockScreenDisplayedCallback(const base::Closure& callback);
200 201
201 // aura::WindowTreeHostObserver override: 202 // aura::WindowTreeHostObserver override:
202 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; 203 virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE;
203 204
204 // ShellObserver overrides: 205 // ShellObserver overrides:
205 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; 206 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
206 virtual void OnAppTerminating() OVERRIDE; 207 virtual void OnAppTerminating() OVERRIDE;
207 virtual void OnLockStateChanged(bool locked) OVERRIDE; 208 virtual void OnLockStateChanged(bool locked) OVERRIDE;
208 209
210 void set_animator_for_test(SessionStateAnimator* animator) {
211 animator_.reset(animator);
212 }
213
209 private: 214 private:
210 friend class test::PowerButtonControllerTest; 215 friend class test::PowerButtonControllerTest;
211 friend class test::LockStateControllerTest; 216 friend class test::LockStateControllerTest;
212 217
213 struct UnlockedStateProperties { 218 struct UnlockedStateProperties {
214 bool background_is_hidden; 219 bool background_is_hidden;
215 }; 220 };
216 221
217 // Reverts the pre-lock animation, reports the error. 222 // Reverts the pre-lock animation, reports the error.
218 void OnLockFailTimeout(); 223 void OnLockFailTimeout();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void PostLockAnimationFinished(); 264 void PostLockAnimationFinished();
260 void UnlockAnimationAfterUIDestroyedFinished(); 265 void UnlockAnimationAfterUIDestroyedFinished();
261 266
262 // Stores properties of UI that have to be temporarily modified while locking. 267 // Stores properties of UI that have to be temporarily modified while locking.
263 void StoreUnlockedProperties(); 268 void StoreUnlockedProperties();
264 void RestoreUnlockedProperties(); 269 void RestoreUnlockedProperties();
265 270
266 // Fades in background layer with |speed| if it was hidden in unlocked state. 271 // Fades in background layer with |speed| if it was hidden in unlocked state.
267 void AnimateBackgroundAppearanceIfNecessary( 272 void AnimateBackgroundAppearanceIfNecessary(
268 ash::SessionStateAnimator::AnimationSpeed speed, 273 ash::SessionStateAnimator::AnimationSpeed speed,
269 ui::LayerAnimationObserver* observer); 274 SessionStateAnimator::AnimationSequence* animation_sequence);
270 275
271 // Fades out background layer with |speed| if it was hidden in unlocked state. 276 // Fades out background layer with |speed| if it was hidden in unlocked state.
272 void AnimateBackgroundHidingIfNecessary( 277 void AnimateBackgroundHidingIfNecessary(
273 ash::SessionStateAnimator::AnimationSpeed speed, 278 ash::SessionStateAnimator::AnimationSpeed speed,
274 ui::LayerAnimationObserver* observer); 279 SessionStateAnimator::AnimationSequence* animation_sequence);
275 280
276 scoped_ptr<SessionStateAnimator> animator_; 281 scoped_ptr<SessionStateAnimator> animator_;
277 282
278 scoped_ptr<LockStateControllerDelegate> delegate_; 283 scoped_ptr<LockStateControllerDelegate> delegate_;
279 284
280 ObserverList<LockStateObserver> observers_; 285 ObserverList<LockStateObserver> observers_;
281 286
282 // The current login status, or original login status from before we locked. 287 // The current login status, or original login status from before we locked.
283 user::LoginStatus login_status_; 288 user::LoginStatus login_status_;
284 289
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 base::Closure lock_screen_displayed_callback_; 326 base::Closure lock_screen_displayed_callback_;
322 327
323 base::WeakPtrFactory<LockStateController> weak_ptr_factory_; 328 base::WeakPtrFactory<LockStateController> weak_ptr_factory_;
324 329
325 DISALLOW_COPY_AND_ASSIGN(LockStateController); 330 DISALLOW_COPY_AND_ASSIGN(LockStateController);
326 }; 331 };
327 332
328 } // namespace ash 333 } // namespace ash
329 334
330 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_ 335 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/test/test_session_state_animator.cc ('k') | ash/wm/lock_state_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698