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

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

Issue 15974008: Rename SessionStateController -> LockStateController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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
OLDNEW
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_LOCK_STATE_CONTROLLER_IMPL2_H_
6 #define ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ 6 #define ASH_WM_SESSION_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/session_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 SessionLockStateControllerImpl2Test;
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 SessionLockStateControllerImpl2
58 : public SessionLockStateController {
58 public: 59 public:
59 60
60 // Helper class used by tests to access internal state. 61 // Helper class used by tests to access internal state.
61 class ASH_EXPORT TestApi { 62 class ASH_EXPORT TestApi {
62 public: 63 public:
63 explicit TestApi(SessionStateControllerImpl2* controller); 64 explicit TestApi(SessionLockStateControllerImpl2* controller);
64 65
65 virtual ~TestApi(); 66 virtual ~TestApi();
66 67
67 bool lock_fail_timer_is_running() const { 68 bool lock_fail_timer_is_running() const {
68 return controller_->lock_fail_timer_.IsRunning(); 69 return controller_->lock_fail_timer_.IsRunning();
69 } 70 }
70 bool lock_to_shutdown_timer_is_running() const { 71 bool lock_to_shutdown_timer_is_running() const {
71 return controller_->lock_to_shutdown_timer_.IsRunning(); 72 return controller_->lock_to_shutdown_timer_.IsRunning();
72 } 73 }
73 bool shutdown_timer_is_running() const { 74 bool shutdown_timer_is_running() const {
(...skipping 19 matching lines...) Expand all
93 } 94 }
94 void trigger_shutdown_timeout() { 95 void trigger_shutdown_timeout() {
95 controller_->OnPreShutdownAnimationTimeout(); 96 controller_->OnPreShutdownAnimationTimeout();
96 controller_->pre_shutdown_timer_.Stop(); 97 controller_->pre_shutdown_timer_.Stop();
97 } 98 }
98 void trigger_real_shutdown_timeout() { 99 void trigger_real_shutdown_timeout() {
99 controller_->OnRealShutdownTimeout(); 100 controller_->OnRealShutdownTimeout();
100 controller_->real_shutdown_timer_.Stop(); 101 controller_->real_shutdown_timer_.Stop();
101 } 102 }
102 private: 103 private:
103 SessionStateControllerImpl2* controller_; // not owned 104 SessionLockStateControllerImpl2* controller_; // not owned
104 105
105 DISALLOW_COPY_AND_ASSIGN(TestApi); 106 DISALLOW_COPY_AND_ASSIGN(TestApi);
106 }; 107 };
107 108
108 SessionStateControllerImpl2(); 109 SessionLockStateControllerImpl2();
109 virtual ~SessionStateControllerImpl2(); 110 virtual ~SessionLockStateControllerImpl2();
110 111
111 // RootWindowObserver override: 112 // RootWindowObserver override:
112 virtual void OnRootWindowHostCloseRequested( 113 virtual void OnRootWindowHostCloseRequested(
113 const aura::RootWindow* root) OVERRIDE; 114 const aura::RootWindow* root) OVERRIDE;
114 115
115 // ShellObserver overrides: 116 // ShellObserver overrides:
116 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; 117 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
117 virtual void OnAppTerminating() OVERRIDE; 118 virtual void OnAppTerminating() OVERRIDE;
118 virtual void OnLockStateChanged(bool locked) OVERRIDE; 119 virtual void OnLockStateChanged(bool locked) OVERRIDE;
119 120
120 // SessionStateController overrides: 121 // SessionLockStateController overrides:
121 virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE; 122 virtual void StartLockAnimation(bool shutdown_after_lock) OVERRIDE;
122 123
123 virtual void StartShutdownAnimation() OVERRIDE; 124 virtual void StartShutdownAnimation() OVERRIDE;
124 virtual void StartLockAnimationAndLockImmediately() OVERRIDE; 125 virtual void StartLockAnimationAndLockImmediately() OVERRIDE;
125 126
126 virtual bool LockRequested() OVERRIDE; 127 virtual bool LockRequested() OVERRIDE;
127 virtual bool ShutdownRequested() OVERRIDE; 128 virtual bool ShutdownRequested() OVERRIDE;
128 129
129 virtual bool CanCancelLockAnimation() OVERRIDE; 130 virtual bool CanCancelLockAnimation() OVERRIDE;
130 virtual void CancelLockAnimation() OVERRIDE; 131 virtual void CancelLockAnimation() OVERRIDE;
131 132
132 virtual bool CanCancelShutdownAnimation() OVERRIDE; 133 virtual bool CanCancelShutdownAnimation() OVERRIDE;
133 virtual void CancelShutdownAnimation() OVERRIDE; 134 virtual void CancelShutdownAnimation() OVERRIDE;
134 135
135 virtual void OnStartingLock() OVERRIDE; 136 virtual void OnStartingLock() OVERRIDE;
136 virtual void RequestShutdown() OVERRIDE; 137 virtual void RequestShutdown() OVERRIDE;
137 138
138 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE; 139 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE;
139 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE; 140 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE;
140 141
141 protected: 142 protected:
142 friend class test::SessionStateControllerImpl2Test; 143 friend class test::SessionLockStateControllerImpl2Test;
143 144
144 private: 145 private:
145 struct UnlockedStateProperties { 146 struct UnlockedStateProperties {
146 bool background_is_hidden; 147 bool background_is_hidden;
147 }; 148 };
148 149
149 void RequestShutdownImpl(); 150 void RequestShutdownImpl();
150 151
151 // Reverts the pre-lock animation, reports the error. 152 // Reverts the pre-lock animation, reports the error.
152 void OnLockFailTimeout(); 153 void OnLockFailTimeout();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // Indicates that controller displays lock animation. 231 // Indicates that controller displays lock animation.
231 bool animating_lock_; 232 bool animating_lock_;
232 233
233 // Indicates that lock animation can be undone. 234 // Indicates that lock animation can be undone.
234 bool can_cancel_lock_animation_; 235 bool can_cancel_lock_animation_;
235 236
236 scoped_ptr<UnlockedStateProperties> unlocked_properties_; 237 scoped_ptr<UnlockedStateProperties> unlocked_properties_;
237 238
238 // Started when we request that the screen be locked. When it fires, we 239 // Started when we request that the screen be locked. When it fires, we
239 // assume that our request got dropped. 240 // assume that our request got dropped.
240 base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_; 241 base::OneShotTimer<SessionLockStateControllerImpl2> lock_fail_timer_;
241 242
242 // Started when the screen is locked while the power button is held. Adds a 243 // 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 244 // delay between the appearance of the lock screen and the beginning of the
244 // pre-shutdown animation. 245 // pre-shutdown animation.
245 base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_; 246 base::OneShotTimer<SessionLockStateControllerImpl2> lock_to_shutdown_timer_;
246 247
247 // Started when we begin displaying the pre-shutdown animation. When it 248 // Started when we begin displaying the pre-shutdown animation. When it
248 // fires, we start the shutdown animation and get ready to request shutdown. 249 // fires, we start the shutdown animation and get ready to request shutdown.
249 base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_; 250 base::OneShotTimer<SessionLockStateControllerImpl2> pre_shutdown_timer_;
250 251
251 // Started when we display the shutdown animation. When it fires, we actually 252 // Started when we display the shutdown animation. When it fires, we actually
252 // request shutdown. Gives the animation time to complete before Chrome, X, 253 // request shutdown. Gives the animation time to complete before Chrome, X,
253 // etc. are shut down. 254 // etc. are shut down.
254 base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_; 255 base::OneShotTimer<SessionLockStateControllerImpl2> real_shutdown_timer_;
255 256
256 base::Closure lock_screen_displayed_callback_; 257 base::Closure lock_screen_displayed_callback_;
257 258
258 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2); 259 DISALLOW_COPY_AND_ASSIGN(SessionLockStateControllerImpl2);
259 }; 260 };
260 261
261 } // namespace ash 262 } // namespace ash
262 263
263 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ 264 #endif // ASH_WM_SESSION_LOCK_STATE_CONTROLLER_IMPL2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698