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 #include "ash/wm/session_state_controller_impl.h" | 5 #include "ash/wm/session_state_controller_impl.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 void SessionStateControllerImpl::OnAppTerminating() { | 48 void SessionStateControllerImpl::OnAppTerminating() { |
49 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 49 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
50 // can really hope for is that we'll have time to clear the screen. | 50 // can really hope for is that we'll have time to clear the screen. |
51 if (!shutting_down_) { | 51 if (!shutting_down_) { |
52 shutting_down_ = true; | 52 shutting_down_ = true; |
53 Shell* shell = ash::Shell::GetInstance(); | 53 Shell* shell = ash::Shell::GetInstance(); |
54 shell->env_filter()->set_cursor_hidden_by_filter(false); | 54 shell->env_filter()->set_cursor_hidden_by_filter(false); |
55 shell->cursor_manager()->ShowCursor(false); | 55 shell->cursor_manager()->ShowCursor(false); |
56 animator_->ShowBlackLayer(); | |
57 animator_->StartAnimation( | 56 animator_->StartAnimation( |
58 internal::SessionStateAnimator::kAllContainersMask, | 57 internal::SessionStateAnimator::kAllContainersMask, |
59 internal::SessionStateAnimator::ANIMATION_HIDE); | 58 internal::SessionStateAnimator::ANIMATION_HIDE); |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
63 void SessionStateControllerImpl::OnLockStateChanged(bool locked) { | 62 void SessionStateControllerImpl::OnLockStateChanged(bool locked) { |
64 if (shutting_down_ || (IsLocked()) == locked) | 63 if (shutting_down_ || (IsLocked()) == locked) |
65 return; | 64 return; |
66 | 65 |
67 system_is_locked_ = locked; | 66 system_is_locked_ = locked; |
68 | 67 |
69 if (locked) { | 68 if (locked) { |
70 animator_->StartAnimation( | 69 animator_->StartAnimation( |
71 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 70 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
72 internal::SessionStateAnimator::ANIMATION_FADE_IN); | 71 internal::SessionStateAnimator::ANIMATION_FADE_IN); |
73 lock_timer_.Stop(); | 72 lock_timer_.Stop(); |
74 lock_fail_timer_.Stop(); | 73 lock_fail_timer_.Stop(); |
75 | 74 |
76 if (shutdown_after_lock_) { | 75 if (shutdown_after_lock_) { |
77 shutdown_after_lock_ = false; | 76 shutdown_after_lock_ = false; |
78 StartLockToShutdownTimer(); | 77 StartLockToShutdownTimer(); |
79 } | 78 } |
80 } else { | 79 } else { |
81 animator_->StartAnimation( | 80 animator_->StartAnimation( |
82 internal::SessionStateAnimator::DESKTOP_BACKGROUND | | 81 internal::SessionStateAnimator::DESKTOP_BACKGROUND | |
83 internal::SessionStateAnimator::LAUNCHER | | 82 internal::SessionStateAnimator::LAUNCHER | |
84 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 83 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
85 internal::SessionStateAnimator::ANIMATION_RESTORE); | 84 internal::SessionStateAnimator::ANIMATION_RESTORE); |
86 animator_->DropBlackLayer(); | |
87 } | 85 } |
88 } | 86 } |
89 | 87 |
90 void SessionStateControllerImpl::OnStartingLock() { | 88 void SessionStateControllerImpl::OnStartingLock() { |
91 if (shutting_down_ || system_is_locked_) | 89 if (shutting_down_ || system_is_locked_) |
92 return; | 90 return; |
93 | 91 |
94 // Ensure that the black layer is visible -- if the screen was locked via | |
95 // the wrench menu, we won't have already shown the black background | |
96 // as part of the slow-close animation. | |
97 animator_->ShowBlackLayer(); | |
98 | |
99 animator_->StartAnimation( | 92 animator_->StartAnimation( |
100 internal::SessionStateAnimator::LAUNCHER, | 93 internal::SessionStateAnimator::LAUNCHER, |
101 internal::SessionStateAnimator::ANIMATION_HIDE); | 94 internal::SessionStateAnimator::ANIMATION_HIDE); |
102 | 95 |
103 animator_->StartAnimation( | 96 animator_->StartAnimation( |
104 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 97 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
105 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE); | 98 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE); |
106 | 99 |
107 // Hide the screen locker containers so we can make them fade in later. | 100 // Hide the screen locker containers so we can make them fade in later. |
108 animator_->StartAnimation( | 101 animator_->StartAnimation( |
109 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 102 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
110 internal::SessionStateAnimator::ANIMATION_HIDE); | 103 internal::SessionStateAnimator::ANIMATION_HIDE); |
111 } | 104 } |
112 | 105 |
113 void SessionStateControllerImpl::StartLockAnimationAndLockImmediately() { | 106 void SessionStateControllerImpl::StartLockAnimationAndLockImmediately() { |
114 animator_->ShowBlackLayer(); | |
115 animator_->StartAnimation( | 107 animator_->StartAnimation( |
116 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 108 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
117 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); | 109 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); |
118 OnLockTimeout(); | 110 OnLockTimeout(); |
119 } | 111 } |
120 | 112 |
121 void SessionStateControllerImpl::StartLockAnimation(bool shutdown_after_lock) { | 113 void SessionStateControllerImpl::StartLockAnimation(bool shutdown_after_lock) { |
122 shutdown_after_lock_ = shutdown_after_lock; | 114 shutdown_after_lock_ = shutdown_after_lock; |
123 | 115 |
124 animator_->ShowBlackLayer(); | |
125 animator_->StartAnimation( | 116 animator_->StartAnimation( |
126 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 117 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
127 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); | 118 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); |
128 StartLockTimer(); | 119 StartLockTimer(); |
129 } | 120 } |
130 | 121 |
131 void SessionStateControllerImpl::StartShutdownAnimation() { | 122 void SessionStateControllerImpl::StartShutdownAnimation() { |
132 animator_->ShowBlackLayer(); | |
133 animator_->StartAnimation( | 123 animator_->StartAnimation( |
134 internal::SessionStateAnimator::kAllContainersMask, | 124 internal::SessionStateAnimator::kAllContainersMask, |
135 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); | 125 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE); |
136 | 126 |
137 StartPreShutdownAnimationTimer(); | 127 StartPreShutdownAnimationTimer(); |
138 } | 128 } |
139 | 129 |
140 bool SessionStateControllerImpl::IsEligibleForLock() { | 130 bool SessionStateControllerImpl::IsEligibleForLock() { |
141 return IsLoggedInAsNonGuest() && !IsLocked() && !LockRequested(); | 131 return IsLoggedInAsNonGuest() && !IsLocked() && !LockRequested(); |
142 } | 132 } |
(...skipping 14 matching lines...) Expand all Loading... |
157 return lock_timer_.IsRunning(); | 147 return lock_timer_.IsRunning(); |
158 } | 148 } |
159 | 149 |
160 void SessionStateControllerImpl::CancelLockAnimation() { | 150 void SessionStateControllerImpl::CancelLockAnimation() { |
161 if (!CanCancelLockAnimation()) | 151 if (!CanCancelLockAnimation()) |
162 return; | 152 return; |
163 shutdown_after_lock_ = false; | 153 shutdown_after_lock_ = false; |
164 animator_->StartAnimation( | 154 animator_->StartAnimation( |
165 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 155 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
166 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); | 156 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); |
167 animator_->ScheduleDropBlackLayer(); | |
168 lock_timer_.Stop(); | 157 lock_timer_.Stop(); |
169 } | 158 } |
170 | 159 |
171 bool SessionStateControllerImpl::CanCancelShutdownAnimation() { | 160 bool SessionStateControllerImpl::CanCancelShutdownAnimation() { |
172 return pre_shutdown_timer_.IsRunning() || | 161 return pre_shutdown_timer_.IsRunning() || |
173 shutdown_after_lock_ || | 162 shutdown_after_lock_ || |
174 lock_to_shutdown_timer_.IsRunning(); | 163 lock_to_shutdown_timer_.IsRunning(); |
175 } | 164 } |
176 | 165 |
177 void SessionStateControllerImpl::CancelShutdownAnimation() { | 166 void SessionStateControllerImpl::CancelShutdownAnimation() { |
(...skipping 10 matching lines...) Expand all Loading... |
188 | 177 |
189 if (system_is_locked_) { | 178 if (system_is_locked_) { |
190 // If we've already started shutdown transition at lock screen | 179 // If we've already started shutdown transition at lock screen |
191 // desktop background needs to be restored immediately. | 180 // desktop background needs to be restored immediately. |
192 animator_->StartAnimation( | 181 animator_->StartAnimation( |
193 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 182 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
194 internal::SessionStateAnimator::ANIMATION_RESTORE); | 183 internal::SessionStateAnimator::ANIMATION_RESTORE); |
195 animator_->StartAnimation( | 184 animator_->StartAnimation( |
196 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 185 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
197 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); | 186 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); |
198 animator_->ScheduleDropBlackLayer(); | |
199 } else { | 187 } else { |
200 animator_->StartAnimation( | 188 animator_->StartAnimation( |
201 internal::SessionStateAnimator::kAllContainersMask, | 189 internal::SessionStateAnimator::kAllContainersMask, |
202 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); | 190 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE); |
203 animator_->ScheduleDropBlackLayer(); | |
204 } | 191 } |
205 pre_shutdown_timer_.Stop(); | 192 pre_shutdown_timer_.Stop(); |
206 } | 193 } |
207 | 194 |
208 void SessionStateControllerImpl::RequestShutdown() { | 195 void SessionStateControllerImpl::RequestShutdown() { |
209 if (!shutting_down_) | 196 if (!shutting_down_) |
210 animator_->ShowBlackLayer(); | |
211 RequestShutdownImpl(); | 197 RequestShutdownImpl(); |
212 } | 198 } |
213 | 199 |
214 void SessionStateControllerImpl::RequestShutdownImpl() { | 200 void SessionStateControllerImpl::RequestShutdownImpl() { |
215 DCHECK(!shutting_down_); | 201 DCHECK(!shutting_down_); |
216 shutting_down_ = true; | 202 shutting_down_ = true; |
217 | 203 |
218 Shell* shell = ash::Shell::GetInstance(); | 204 Shell* shell = ash::Shell::GetInstance(); |
219 shell->env_filter()->set_cursor_hidden_by_filter(false); | 205 shell->env_filter()->set_cursor_hidden_by_filter(false); |
220 shell->cursor_manager()->ShowCursor(false); | 206 shell->cursor_manager()->ShowCursor(false); |
221 | 207 |
222 animator_->ShowBlackLayer(); | |
223 if (login_status_ != user::LOGGED_IN_NONE) { | 208 if (login_status_ != user::LOGGED_IN_NONE) { |
224 // Hide the other containers before starting the animation. | 209 // Hide the other containers before starting the animation. |
225 // ANIMATION_FULL_CLOSE will make the screen locker windows partially | 210 // ANIMATION_FULL_CLOSE will make the screen locker windows partially |
226 // transparent, and we don't want the other windows to show through. | 211 // transparent, and we don't want the other windows to show through. |
227 animator_->StartAnimation( | 212 animator_->StartAnimation( |
228 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | 213 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | |
229 internal::SessionStateAnimator::LAUNCHER, | 214 internal::SessionStateAnimator::LAUNCHER, |
230 internal::SessionStateAnimator::ANIMATION_HIDE); | 215 internal::SessionStateAnimator::ANIMATION_HIDE); |
231 animator_->StartAnimation( | 216 animator_->StartAnimation( |
232 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 217 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 this, &SessionStateControllerImpl::OnLockFailTimeout); | 251 this, &SessionStateControllerImpl::OnLockFailTimeout); |
267 } | 252 } |
268 | 253 |
269 void SessionStateControllerImpl::OnLockFailTimeout() { | 254 void SessionStateControllerImpl::OnLockFailTimeout() { |
270 DCHECK(!system_is_locked_); | 255 DCHECK(!system_is_locked_); |
271 // Undo lock animation. | 256 // Undo lock animation. |
272 animator_->StartAnimation( | 257 animator_->StartAnimation( |
273 internal::SessionStateAnimator::LAUNCHER | | 258 internal::SessionStateAnimator::LAUNCHER | |
274 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 259 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
275 internal::SessionStateAnimator::ANIMATION_RESTORE); | 260 internal::SessionStateAnimator::ANIMATION_RESTORE); |
276 animator_->DropBlackLayer(); | |
277 } | 261 } |
278 | 262 |
279 void SessionStateControllerImpl::StartLockToShutdownTimer() { | 263 void SessionStateControllerImpl::StartLockToShutdownTimer() { |
280 shutdown_after_lock_ = false; | 264 shutdown_after_lock_ = false; |
281 lock_to_shutdown_timer_.Stop(); | 265 lock_to_shutdown_timer_.Stop(); |
282 lock_to_shutdown_timer_.Start( | 266 lock_to_shutdown_timer_.Start( |
283 FROM_HERE, | 267 FROM_HERE, |
284 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), | 268 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), |
285 this, &SessionStateControllerImpl::OnLockToShutdownTimeout); | 269 this, &SessionStateControllerImpl::OnLockToShutdownTimeout); |
286 } | 270 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if (delegate) { | 304 if (delegate) { |
321 delegate->Exit(); | 305 delegate->Exit(); |
322 return; | 306 return; |
323 } | 307 } |
324 } | 308 } |
325 #endif | 309 #endif |
326 delegate_->RequestShutdown(); | 310 delegate_->RequestShutdown(); |
327 } | 311 } |
328 | 312 |
329 } // namespace ash | 313 } // namespace ash |
OLD | NEW |