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_LOCK_STATE_CONTROLLER_IMPL2_H_ |
6 #define ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ | 6 #define ASH_WM_LOCK_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/lock_state_controller.h" |
10 #include "ash/wm/session_state_animator.h" | 11 #include "ash/wm/session_state_animator.h" |
11 #include "ash/wm/session_state_controller.h" | |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/timer.h" | 15 #include "base/timer.h" |
16 #include "ui/aura/root_window_observer.h" | 16 #include "ui/aura/root_window_observer.h" |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class Rect; | 19 class Rect; |
20 class Size; | 20 class Size; |
21 } | 21 } |
22 | 22 |
23 namespace ui { | 23 namespace ui { |
24 class Layer; | 24 class Layer; |
25 } | 25 } |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 | 28 |
29 namespace test { | 29 namespace test { |
30 class SessionStateControllerImpl2Test; | 30 class LockStateControllerImpl2Test; |
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: | 35 // Lock workflow: |
36 // Entry points: | 36 // Entry points: |
37 // * StartLockAnimation (bool shutdown after lock) - starts lock that can be | 37 // * StartLockAnimation (bool shutdown after lock) - starts lock that can be |
38 // cancelled. | 38 // cancelled. |
39 // * StartLockAnimationAndLockImmediately - starts uninterruptible lock | 39 // * StartLockAnimationAndLockImmediately - starts uninterruptible lock |
40 // animation. | 40 // animation. |
41 // This leads to call of either StartImmediatePreLockAnimation or | 41 // This leads to call of either StartImmediatePreLockAnimation or |
42 // StartCancellablePreLockAnimation. Once they complete | 42 // StartCancellablePreLockAnimation. Once they complete |
43 // PreLockAnimationFinished is called, and system lock is requested. | 43 // PreLockAnimationFinished is called, and system lock is requested. |
44 // Once system locks and lock UI is created, OnLockStateChanged is called, and | 44 // Once system locks and lock UI is created, OnLockStateChanged is called, and |
45 // StartPostLockAnimation is called. In PostLockAnimationFinished two | 45 // StartPostLockAnimation is called. In PostLockAnimationFinished two |
46 // things happen : EVENT_LOCK_ANIMATION_FINISHED notification is sent (it | 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 | 47 // triggers third part of animation within lock UI), and check for continuing to |
48 // shutdown is made. | 48 // shutdown is made. |
49 // | 49 // |
50 // Unlock workflow: | 50 // Unlock workflow: |
51 // WebUI does first part of animation, and calls OnLockScreenHide(callback) that | 51 // WebUI does first part of animation, and calls OnLockScreenHide(callback) that |
52 // triggers StartUnlockAnimationBeforeUIDestroyed(callback). Once callback is | 52 // triggers StartUnlockAnimationBeforeUIDestroyed(callback). Once callback is |
53 // called at the end of the animation, lock UI is deleted, system unlocks, and | 53 // called at the end of the animation, lock UI is deleted, system unlocks, and |
54 // OnLockStateChanged is called. It leads to | 54 // OnLockStateChanged is called. It leads to |
55 // StartUnlockAnimationAfterUIDestroyed. | 55 // StartUnlockAnimationAfterUIDestroyed. |
56 | 56 |
57 class ASH_EXPORT SessionStateControllerImpl2 : public SessionStateController { | 57 class ASH_EXPORT LockStateControllerImpl2 : public LockStateController { |
58 public: | 58 public: |
59 | 59 |
60 // Helper class used by tests to access internal state. | 60 // Helper class used by tests to access internal state. |
61 class ASH_EXPORT TestApi { | 61 class ASH_EXPORT TestApi { |
62 public: | 62 public: |
63 explicit TestApi(SessionStateControllerImpl2* controller); | 63 explicit TestApi(LockStateControllerImpl2* controller); |
64 | 64 |
65 virtual ~TestApi(); | 65 virtual ~TestApi(); |
66 | 66 |
67 bool lock_fail_timer_is_running() const { | 67 bool lock_fail_timer_is_running() const { |
68 return controller_->lock_fail_timer_.IsRunning(); | 68 return controller_->lock_fail_timer_.IsRunning(); |
69 } | 69 } |
70 bool lock_to_shutdown_timer_is_running() const { | 70 bool lock_to_shutdown_timer_is_running() const { |
71 return controller_->lock_to_shutdown_timer_.IsRunning(); | 71 return controller_->lock_to_shutdown_timer_.IsRunning(); |
72 } | 72 } |
73 bool shutdown_timer_is_running() const { | 73 bool shutdown_timer_is_running() const { |
(...skipping 19 matching lines...) Expand all Loading... |
93 } | 93 } |
94 void trigger_shutdown_timeout() { | 94 void trigger_shutdown_timeout() { |
95 controller_->OnPreShutdownAnimationTimeout(); | 95 controller_->OnPreShutdownAnimationTimeout(); |
96 controller_->pre_shutdown_timer_.Stop(); | 96 controller_->pre_shutdown_timer_.Stop(); |
97 } | 97 } |
98 void trigger_real_shutdown_timeout() { | 98 void trigger_real_shutdown_timeout() { |
99 controller_->OnRealShutdownTimeout(); | 99 controller_->OnRealShutdownTimeout(); |
100 controller_->real_shutdown_timer_.Stop(); | 100 controller_->real_shutdown_timer_.Stop(); |
101 } | 101 } |
102 private: | 102 private: |
103 SessionStateControllerImpl2* controller_; // not owned | 103 LockStateControllerImpl2* controller_; // not owned |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(TestApi); | 105 DISALLOW_COPY_AND_ASSIGN(TestApi); |
106 }; | 106 }; |
107 | 107 |
108 SessionStateControllerImpl2(); | 108 LockStateControllerImpl2(); |
109 virtual ~SessionStateControllerImpl2(); | 109 virtual ~LockStateControllerImpl2(); |
110 | 110 |
111 // RootWindowObserver override: | 111 // RootWindowObserver override: |
112 virtual void OnRootWindowHostCloseRequested( | 112 virtual void OnRootWindowHostCloseRequested( |
113 const aura::RootWindow* root) OVERRIDE; | 113 const aura::RootWindow* root) OVERRIDE; |
114 | 114 |
115 // ShellObserver overrides: | 115 // ShellObserver overrides: |
116 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; | 116 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; |
117 virtual void OnAppTerminating() OVERRIDE; | 117 virtual void OnAppTerminating() OVERRIDE; |
118 virtual void OnLockStateChanged(bool locked) OVERRIDE; | 118 virtual void OnLockStateChanged(bool locked) OVERRIDE; |
119 | 119 |
120 // SessionStateController overrides: | 120 // LockStateController overrides: |
121 virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE; | 121 virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE; |
122 | 122 |
123 virtual void StartShutdownAnimation() OVERRIDE; | 123 virtual void StartShutdownAnimation() OVERRIDE; |
124 virtual void StartLockAnimationAndLockImmediately() OVERRIDE; | 124 virtual void StartLockAnimationAndLockImmediately() OVERRIDE; |
125 | 125 |
126 virtual bool LockRequested() OVERRIDE; | 126 virtual bool LockRequested() OVERRIDE; |
127 virtual bool ShutdownRequested() OVERRIDE; | 127 virtual bool ShutdownRequested() OVERRIDE; |
128 | 128 |
129 virtual bool CanCancelLockAnimation() OVERRIDE; | 129 virtual bool CanCancelLockAnimation() OVERRIDE; |
130 virtual void CancelLockAnimation() OVERRIDE; | 130 virtual void CancelLockAnimation() OVERRIDE; |
131 | 131 |
132 virtual bool CanCancelShutdownAnimation() OVERRIDE; | 132 virtual bool CanCancelShutdownAnimation() OVERRIDE; |
133 virtual void CancelShutdownAnimation() OVERRIDE; | 133 virtual void CancelShutdownAnimation() OVERRIDE; |
134 | 134 |
135 virtual void OnStartingLock() OVERRIDE; | 135 virtual void OnStartingLock() OVERRIDE; |
136 virtual void RequestShutdown() OVERRIDE; | 136 virtual void RequestShutdown() OVERRIDE; |
137 | 137 |
138 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE; | 138 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE; |
139 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE; | 139 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE; |
140 | 140 |
141 protected: | 141 protected: |
142 friend class test::SessionStateControllerImpl2Test; | 142 friend class test::LockStateControllerImpl2Test; |
143 | 143 |
144 private: | 144 private: |
145 struct UnlockedStateProperties { | 145 struct UnlockedStateProperties { |
146 bool background_is_hidden; | 146 bool background_is_hidden; |
147 }; | 147 }; |
148 | 148 |
149 void RequestShutdownImpl(); | 149 void RequestShutdownImpl(); |
150 | 150 |
151 // Reverts the pre-lock animation, reports the error. | 151 // Reverts the pre-lock animation, reports the error. |
152 void OnLockFailTimeout(); | 152 void OnLockFailTimeout(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Indicates that controller displays lock animation. | 230 // Indicates that controller displays lock animation. |
231 bool animating_lock_; | 231 bool animating_lock_; |
232 | 232 |
233 // Indicates that lock animation can be undone. | 233 // Indicates that lock animation can be undone. |
234 bool can_cancel_lock_animation_; | 234 bool can_cancel_lock_animation_; |
235 | 235 |
236 scoped_ptr<UnlockedStateProperties> unlocked_properties_; | 236 scoped_ptr<UnlockedStateProperties> unlocked_properties_; |
237 | 237 |
238 // Started when we request that the screen be locked. When it fires, we | 238 // Started when we request that the screen be locked. When it fires, we |
239 // assume that our request got dropped. | 239 // assume that our request got dropped. |
240 base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_; | 240 base::OneShotTimer<LockStateControllerImpl2> lock_fail_timer_; |
241 | 241 |
242 // Started when the screen is locked while the power button is held. Adds a | 242 // Started when the screen is locked while the power button is held. Adds a |
243 // delay between the appearance of the lock screen and the beginning of the | 243 // delay between the appearance of the lock screen and the beginning of the |
244 // pre-shutdown animation. | 244 // pre-shutdown animation. |
245 base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_; | 245 base::OneShotTimer<LockStateControllerImpl2> lock_to_shutdown_timer_; |
246 | 246 |
247 // Started when we begin displaying the pre-shutdown animation. When it | 247 // Started when we begin displaying the pre-shutdown animation. When it |
248 // fires, we start the shutdown animation and get ready to request shutdown. | 248 // fires, we start the shutdown animation and get ready to request shutdown. |
249 base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_; | 249 base::OneShotTimer<LockStateControllerImpl2> pre_shutdown_timer_; |
250 | 250 |
251 // Started when we display the shutdown animation. When it fires, we actually | 251 // Started when we display the shutdown animation. When it fires, we actually |
252 // request shutdown. Gives the animation time to complete before Chrome, X, | 252 // request shutdown. Gives the animation time to complete before Chrome, X, |
253 // etc. are shut down. | 253 // etc. are shut down. |
254 base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_; | 254 base::OneShotTimer<LockStateControllerImpl2> real_shutdown_timer_; |
255 | 255 |
256 base::Closure lock_screen_displayed_callback_; | 256 base::Closure lock_screen_displayed_callback_; |
257 | 257 |
258 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2); | 258 DISALLOW_COPY_AND_ASSIGN(LockStateControllerImpl2); |
259 }; | 259 }; |
260 | 260 |
261 } // namespace ash | 261 } // namespace ash |
262 | 262 |
263 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ | 263 #endif // ASH_WM_LOCK_STATE_CONTROLLER_IMPL2_H_ |
OLD | NEW |