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

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

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove stuff for testing and disable some tests" Created 8 years 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/wm/session_state_animator.cc ('k') | ash/wm/session_state_controller_impl2.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 (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
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
38 // cancelled.
39 // * StartLockAnimationAndLockImmediately - starts uninterruptible lock
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_->CanCancelLockAnimation();
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();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 virtual void OnStartingLock() OVERRIDE; 135 virtual void OnStartingLock() OVERRIDE;
115 virtual void RequestShutdown() OVERRIDE; 136 virtual void RequestShutdown() OVERRIDE;
116 137
117 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE; 138 virtual void OnLockScreenHide(base::Closure& callback) OVERRIDE;
118 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE; 139 virtual void SetLockScreenDisplayedCallback(base::Closure& callback) OVERRIDE;
119 140
120 protected: 141 protected:
121 friend class test::SessionStateControllerImpl2Test; 142 friend class test::SessionStateControllerImpl2Test;
122 143
123 private: 144 private:
145 struct UnlockedStateProperties {
146 bool background_is_hidden;
147 };
148
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 void StartImmediatePreLockAnimation();
186 void StartCancellablePreLockAnimation();
187 void CancelPreLockAnimation();
188 void StartPostLockAnimation();
189 // This method calls |callback| when animation completes.
190 void StartUnlockAnimationBeforeUIDestroyed(base::Closure &callback);
191 void StartUnlockAnimationAfterUIDestroyed();
192
193 // These methods are called when corresponding animation completes.
194 void LockAnimationCancelled();
195 void PreLockAnimationFinished();
196 void PostLockAnimationFinished();
197 void UnlockAnimationAfterUIDestroyedFinished();
198
199 // Stores properties of UI that have to be temporarily modified while locking.
200 void StoreUnlockedProperties();
201 void RestoreUnlockedProperties();
202
203 // Fades in background layer with |speed| if it was hidden in unlocked state.
204 void AnimateBackgroundAppearanceIfNecessary(
205 ash::internal::SessionStateAnimator::AnimationSpeed speed,
206 ui::LayerAnimationObserver* observer);
207
208 // Fades out background layer with |speed| if it was hidden in unlocked state.
209 void AnimateBackgroundHidingIfNecessary(
210 ash::internal::SessionStateAnimator::AnimationSpeed speed,
211 ui::LayerAnimationObserver* observer);
212
156 // The current login status, or original login status from before we locked. 213 // The current login status, or original login status from before we locked.
157 user::LoginStatus login_status_; 214 user::LoginStatus login_status_;
158 215
159 // Current lock status. 216 // Current lock status.
160 bool system_is_locked_; 217 bool system_is_locked_;
161 218
162 // Are we in the process of shutting the machine down? 219 // Are we in the process of shutting the machine down?
163 bool shutting_down_; 220 bool shutting_down_;
164 221
165 // Indicates whether controller should proceed to (cancellable) shutdown after 222 // Indicates whether controller should proceed to (cancellable) shutdown after
166 // locking. 223 // locking.
167 bool shutdown_after_lock_; 224 bool shutdown_after_lock_;
168 225
169 // Started when the user first presses the power button while in a 226 // Indicates that controller displays lock animation.
170 // logged-in-as-a-non-guest-user, unlocked state. When it fires, we lock the 227 bool animating_lock_;
171 // screen. 228
172 base::OneShotTimer<SessionStateControllerImpl2> lock_timer_; 229 // Indicates that lock animation can be undone.
230 bool can_cancel_lock_animation_;
231
232 scoped_ptr<UnlockedStateProperties> unlocked_properties_;
173 233
174 // Started when we request that the screen be locked. When it fires, we 234 // Started when we request that the screen be locked. When it fires, we
175 // assume that our request got dropped. 235 // assume that our request got dropped.
176 base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_; 236 base::OneShotTimer<SessionStateControllerImpl2> lock_fail_timer_;
177 237
178 // Started when the screen is locked while the power button is held. Adds a 238 // 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 239 // delay between the appearance of the lock screen and the beginning of the
180 // pre-shutdown animation. 240 // pre-shutdown animation.
181 base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_; 241 base::OneShotTimer<SessionStateControllerImpl2> lock_to_shutdown_timer_;
182 242
183 // Started when we begin displaying the pre-shutdown animation. When it 243 // Started when we begin displaying the pre-shutdown animation. When it
184 // fires, we start the shutdown animation and get ready to request shutdown. 244 // fires, we start the shutdown animation and get ready to request shutdown.
185 base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_; 245 base::OneShotTimer<SessionStateControllerImpl2> pre_shutdown_timer_;
186 246
187 // Started when we display the shutdown animation. When it fires, we actually 247 // Started when we display the shutdown animation. When it fires, we actually
188 // request shutdown. Gives the animation time to complete before Chrome, X, 248 // request shutdown. Gives the animation time to complete before Chrome, X,
189 // etc. are shut down. 249 // etc. are shut down.
190 base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_; 250 base::OneShotTimer<SessionStateControllerImpl2> real_shutdown_timer_;
191 251
192 base::Closure lock_screen_displayed_callback_; 252 base::Closure lock_screen_displayed_callback_;
193 253
194 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2); 254 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2);
195 }; 255 };
196 256
197 } // namespace ash 257 } // namespace ash
198 258
199 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_ 259 #endif // ASH_WM_SESSION_STATE_CONTROLLER_IMPL2_H_
OLDNEW
« no previous file with comments | « ash/wm/session_state_animator.cc ('k') | ash/wm/session_state_controller_impl2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698