OLD | NEW |
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 #include "ash/wm/lock_state_controller.h" | 5 #include "ash/wm/lock_state_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> |
8 | 9 |
9 #include "ash/accessibility_delegate.h" | 10 #include "ash/accessibility_delegate.h" |
10 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
11 #include "ash/cancel_mode.h" | 12 #include "ash/cancel_mode.h" |
12 #include "ash/metrics/user_metrics_recorder.h" | 13 #include "ash/metrics/user_metrics_recorder.h" |
13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
14 #include "ash/shell_delegate.h" | 15 #include "ash/shell_delegate.h" |
15 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
16 #include "ash/wm/session_state_animator.h" | 17 #include "ash/wm/session_state_animator.h" |
| 18 #include "ash/wm/session_state_animator_impl.h" |
17 #include "base/bind_helpers.h" | 19 #include "base/bind_helpers.h" |
18 #include "base/command_line.h" | 20 #include "base/command_line.h" |
19 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
20 #include "base/timer/timer.h" | 22 #include "base/timer/timer.h" |
21 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
22 #include "ui/compositor/layer_animation_sequence.h" | 24 #include "ui/compositor/layer_animation_sequence.h" |
23 #include "ui/compositor/scoped_layer_animation_settings.h" | 25 #include "ui/compositor/scoped_layer_animation_settings.h" |
24 #include "ui/views/controls/menu/menu_controller.h" | 26 #include "ui/views/controls/menu/menu_controller.h" |
25 #include "ui/wm/core/compound_event_filter.h" | 27 #include "ui/wm/core/compound_event_filter.h" |
26 | 28 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 GetBackground()->Show(); | 60 GetBackground()->Show(); |
59 } | 61 } |
60 | 62 |
61 void HideBackground() { | 63 void HideBackground() { |
62 ui::ScopedLayerAnimationSettings settings( | 64 ui::ScopedLayerAnimationSettings settings( |
63 GetBackground()->layer()->GetAnimator()); | 65 GetBackground()->layer()->GetAnimator()); |
64 settings.SetTransitionDuration(base::TimeDelta()); | 66 settings.SetTransitionDuration(base::TimeDelta()); |
65 GetBackground()->Hide(); | 67 GetBackground()->Hide(); |
66 } | 68 } |
67 | 69 |
68 // This observer is intended to use in cases when some action has to be taken | |
69 // once some animation successfully completes (i.e. it was not aborted). | |
70 // Observer will count a number of sequences it is attached to, and a number of | |
71 // finished sequences (either Ended or Aborted). Once these two numbers are | |
72 // equal, observer will delete itself, calling callback passed to constructor if | |
73 // there were no aborted animations. | |
74 // This way it can be either used to wait for some animation to be finished in | |
75 // multiple layers, to wait once a sequence of animations is finished in one | |
76 // layer or the mixture of both. | |
77 class AnimationFinishedObserver : public ui::LayerAnimationObserver { | |
78 public: | |
79 explicit AnimationFinishedObserver(base::Closure &callback) | |
80 : callback_(callback), | |
81 sequences_attached_(0), | |
82 sequences_completed_(0), | |
83 paused_(false) { | |
84 } | |
85 | |
86 // Pauses observer: no checks will be made while paused. It can be used when | |
87 // a sequence has some immediate animations in the beginning, and for | |
88 // animations that can be tested with flag that makes all animations | |
89 // immediate. | |
90 void Pause() { | |
91 paused_ = true; | |
92 } | |
93 | |
94 // Unpauses observer. It does a check and calls callback if conditions are | |
95 // met. | |
96 void Unpause() { | |
97 if (!paused_) | |
98 return; | |
99 paused_ = false; | |
100 if (sequences_completed_ == sequences_attached_) { | |
101 callback_.Run(); | |
102 delete this; | |
103 } | |
104 } | |
105 | |
106 private: | |
107 virtual ~AnimationFinishedObserver() { | |
108 } | |
109 | |
110 // LayerAnimationObserver implementation | |
111 virtual void OnLayerAnimationEnded( | |
112 ui::LayerAnimationSequence* sequence) OVERRIDE { | |
113 sequences_completed_++; | |
114 if ((sequences_completed_ == sequences_attached_) && !paused_) { | |
115 callback_.Run(); | |
116 delete this; | |
117 } | |
118 } | |
119 | |
120 virtual void OnLayerAnimationAborted( | |
121 ui::LayerAnimationSequence* sequence) OVERRIDE { | |
122 sequences_completed_++; | |
123 if ((sequences_completed_ == sequences_attached_) && !paused_) | |
124 delete this; | |
125 } | |
126 | |
127 virtual void OnLayerAnimationScheduled( | |
128 ui::LayerAnimationSequence* sequence) OVERRIDE { | |
129 } | |
130 | |
131 virtual void OnAttachedToSequence( | |
132 ui::LayerAnimationSequence* sequence) OVERRIDE { | |
133 LayerAnimationObserver::OnAttachedToSequence(sequence); | |
134 sequences_attached_++; | |
135 } | |
136 | |
137 // Callback to be called. | |
138 base::Closure callback_; | |
139 | |
140 // Number of sequences this observer was attached to. | |
141 int sequences_attached_; | |
142 | |
143 // Number of sequences either ended or aborted. | |
144 int sequences_completed_; | |
145 | |
146 bool paused_; | |
147 | |
148 DISALLOW_COPY_AND_ASSIGN(AnimationFinishedObserver); | |
149 }; | |
150 | |
151 } // namespace | 70 } // namespace |
152 | 71 |
153 const int LockStateController::kLockTimeoutMs = 400; | 72 const int LockStateController::kLockTimeoutMs = 400; |
154 const int LockStateController::kShutdownTimeoutMs = 400; | 73 const int LockStateController::kShutdownTimeoutMs = 400; |
155 const int LockStateController::kLockFailTimeoutMs = 8000; | 74 const int LockStateController::kLockFailTimeoutMs = 8000; |
156 const int LockStateController::kLockToShutdownTimeoutMs = 150; | 75 const int LockStateController::kLockToShutdownTimeoutMs = 150; |
157 const int LockStateController::kShutdownRequestDelayMs = 50; | 76 const int LockStateController::kShutdownRequestDelayMs = 50; |
158 | 77 |
159 LockStateController::TestApi::TestApi(LockStateController* controller) | 78 LockStateController::TestApi::TestApi(LockStateController* controller) |
160 : controller_(controller) { | 79 : controller_(controller) { |
161 } | 80 } |
162 | 81 |
163 LockStateController::TestApi::~TestApi() { | 82 LockStateController::TestApi::~TestApi() { |
164 } | 83 } |
165 | 84 |
166 LockStateController::LockStateController() | 85 LockStateController::LockStateController() |
167 : animator_(new SessionStateAnimator()), | 86 : animator_(new SessionStateAnimatorImpl()), |
168 login_status_(user::LOGGED_IN_NONE), | 87 login_status_(user::LOGGED_IN_NONE), |
169 system_is_locked_(false), | 88 system_is_locked_(false), |
170 shutting_down_(false), | 89 shutting_down_(false), |
171 shutdown_after_lock_(false), | 90 shutdown_after_lock_(false), |
172 animating_lock_(false), | 91 animating_lock_(false), |
173 can_cancel_lock_animation_(false), | 92 can_cancel_lock_animation_(false), |
174 weak_ptr_factory_(this) { | 93 weak_ptr_factory_(this) { |
175 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); | 94 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); |
176 } | 95 } |
177 | 96 |
(...skipping 24 matching lines...) Expand all Loading... |
202 shutdown_after_lock_ = shutdown_after_lock; | 121 shutdown_after_lock_ = shutdown_after_lock; |
203 can_cancel_lock_animation_ = true; | 122 can_cancel_lock_animation_ = true; |
204 | 123 |
205 StartCancellablePreLockAnimation(); | 124 StartCancellablePreLockAnimation(); |
206 } | 125 } |
207 | 126 |
208 void LockStateController::StartShutdownAnimation() { | 127 void LockStateController::StartShutdownAnimation() { |
209 StartCancellableShutdownAnimation(); | 128 StartCancellableShutdownAnimation(); |
210 } | 129 } |
211 | 130 |
212 void LockStateController::StartLockAnimationAndLockImmediately() { | 131 void LockStateController::StartLockAnimationAndLockImmediately( |
| 132 bool shutdown_after_lock) { |
213 if (animating_lock_) | 133 if (animating_lock_) |
214 return; | 134 return; |
| 135 shutdown_after_lock_ = shutdown_after_lock; |
215 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); | 136 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); |
216 } | 137 } |
217 | 138 |
218 bool LockStateController::LockRequested() { | 139 bool LockStateController::LockRequested() { |
219 return lock_fail_timer_.IsRunning(); | 140 return lock_fail_timer_.IsRunning(); |
220 } | 141 } |
221 | 142 |
222 bool LockStateController::ShutdownRequested() { | 143 bool LockStateController::ShutdownRequested() { |
223 return shutting_down_; | 144 return shutting_down_; |
224 } | 145 } |
(...skipping 21 matching lines...) Expand all Loading... |
246 return; | 167 return; |
247 if (lock_to_shutdown_timer_.IsRunning()) { | 168 if (lock_to_shutdown_timer_.IsRunning()) { |
248 lock_to_shutdown_timer_.Stop(); | 169 lock_to_shutdown_timer_.Stop(); |
249 return; | 170 return; |
250 } | 171 } |
251 if (shutdown_after_lock_) { | 172 if (shutdown_after_lock_) { |
252 shutdown_after_lock_ = false; | 173 shutdown_after_lock_ = false; |
253 return; | 174 return; |
254 } | 175 } |
255 | 176 |
256 animator_->StartGlobalAnimation( | 177 animator_->StartAnimation( |
| 178 SessionStateAnimator::ROOT_CONTAINER, |
257 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS, | 179 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS, |
258 SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); | 180 SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); |
259 pre_shutdown_timer_.Stop(); | 181 pre_shutdown_timer_.Stop(); |
260 } | 182 } |
261 | 183 |
262 void LockStateController::OnStartingLock() { | 184 void LockStateController::OnStartingLock() { |
263 if (shutting_down_ || system_is_locked_) | 185 if (shutting_down_ || system_is_locked_) |
264 return; | 186 return; |
265 if (animating_lock_) | 187 if (animating_lock_) |
266 return; | 188 return; |
267 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); | 189 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); |
268 } | 190 } |
269 | 191 |
270 void LockStateController::RequestShutdown() { | 192 void LockStateController::RequestShutdown() { |
271 if (shutting_down_) | 193 if (shutting_down_) |
272 return; | 194 return; |
273 | 195 |
274 shutting_down_ = true; | 196 shutting_down_ = true; |
275 | 197 |
276 Shell* shell = ash::Shell::GetInstance(); | 198 Shell* shell = ash::Shell::GetInstance(); |
277 shell->cursor_manager()->HideCursor(); | 199 shell->cursor_manager()->HideCursor(); |
278 shell->cursor_manager()->LockCursor(); | 200 shell->cursor_manager()->LockCursor(); |
279 | 201 |
280 animator_->StartGlobalAnimation( | 202 animator_->StartAnimation( |
| 203 SessionStateAnimator::ROOT_CONTAINER, |
281 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 204 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
282 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 205 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
283 StartRealShutdownTimer(true); | 206 StartRealShutdownTimer(true); |
284 } | 207 } |
285 | 208 |
286 void LockStateController::OnLockScreenHide( | 209 void LockStateController::OnLockScreenHide( |
287 base::Callback<void(void)>& callback) { | 210 base::Callback<void(void)>& callback) { |
288 StartUnlockAnimationBeforeUIDestroyed(callback); | 211 StartUnlockAnimationBeforeUIDestroyed(callback); |
289 } | 212 } |
290 | 213 |
(...skipping 16 matching lines...) Expand all Loading... |
307 | 230 |
308 void LockStateController::OnAppTerminating() { | 231 void LockStateController::OnAppTerminating() { |
309 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 232 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
310 // can really hope for is that we'll have time to clear the screen. | 233 // can really hope for is that we'll have time to clear the screen. |
311 // This is also the case when the user signs off. | 234 // This is also the case when the user signs off. |
312 if (!shutting_down_) { | 235 if (!shutting_down_) { |
313 shutting_down_ = true; | 236 shutting_down_ = true; |
314 Shell* shell = ash::Shell::GetInstance(); | 237 Shell* shell = ash::Shell::GetInstance(); |
315 shell->cursor_manager()->HideCursor(); | 238 shell->cursor_manager()->HideCursor(); |
316 shell->cursor_manager()->LockCursor(); | 239 shell->cursor_manager()->LockCursor(); |
317 animator_->StartAnimation(SessionStateAnimator::kAllContainersMask, | 240 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, |
318 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 241 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
319 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 242 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
320 } | 243 } |
321 } | 244 } |
322 | 245 |
323 void LockStateController::OnLockStateChanged(bool locked) { | 246 void LockStateController::OnLockStateChanged(bool locked) { |
324 VLOG(1) << "OnLockStateChanged " << locked; | 247 VLOG(1) << "OnLockStateChanged " << locked; |
325 if (shutting_down_ || (system_is_locked_ == locked)) | 248 if (shutting_down_ || (system_is_locked_ == locked)) |
326 return; | 249 return; |
327 | 250 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 334 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
412 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | 335 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
413 delegate_->RequestShutdown(); | 336 delegate_->RequestShutdown(); |
414 } | 337 } |
415 | 338 |
416 void LockStateController::StartCancellableShutdownAnimation() { | 339 void LockStateController::StartCancellableShutdownAnimation() { |
417 Shell* shell = ash::Shell::GetInstance(); | 340 Shell* shell = ash::Shell::GetInstance(); |
418 // Hide cursor, but let it reappear if the mouse moves. | 341 // Hide cursor, but let it reappear if the mouse moves. |
419 shell->cursor_manager()->HideCursor(); | 342 shell->cursor_manager()->HideCursor(); |
420 | 343 |
421 animator_->StartGlobalAnimation( | 344 animator_->StartAnimation( |
| 345 SessionStateAnimator::ROOT_CONTAINER, |
422 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 346 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
423 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 347 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
424 StartPreShutdownAnimationTimer(); | 348 StartPreShutdownAnimationTimer(); |
425 } | 349 } |
426 | 350 |
427 void LockStateController::StartImmediatePreLockAnimation( | 351 void LockStateController::StartImmediatePreLockAnimation( |
428 bool request_lock_on_completion) { | 352 bool request_lock_on_completion) { |
429 VLOG(1) << "StartImmediatePreLockAnimation " << request_lock_on_completion; | 353 VLOG(1) << "StartImmediatePreLockAnimation " << request_lock_on_completion; |
430 animating_lock_ = true; | 354 animating_lock_ = true; |
431 StoreUnlockedProperties(); | 355 StoreUnlockedProperties(); |
432 | 356 |
433 base::Closure next_animation_starter = | 357 base::Closure next_animation_starter = |
434 base::Bind(&LockStateController::PreLockAnimationFinished, | 358 base::Bind(&LockStateController::PreLockAnimationFinished, |
435 weak_ptr_factory_.GetWeakPtr(), | 359 weak_ptr_factory_.GetWeakPtr(), |
436 request_lock_on_completion); | 360 request_lock_on_completion); |
437 AnimationFinishedObserver* observer = | 361 SessionStateAnimator::AnimationSequence* animation_sequence = |
438 new AnimationFinishedObserver(next_animation_starter); | 362 animator_->BeginAnimationSequence(next_animation_starter); |
439 | 363 |
440 observer->Pause(); | 364 animation_sequence->StartAnimation( |
441 | |
442 animator_->StartAnimationWithObserver( | |
443 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 365 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
444 SessionStateAnimator::ANIMATION_LIFT, | 366 SessionStateAnimator::ANIMATION_LIFT, |
445 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 367 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
446 observer); | 368 animation_sequence->StartAnimation( |
447 animator_->StartAnimationWithObserver( | |
448 SessionStateAnimator::LAUNCHER, | 369 SessionStateAnimator::LAUNCHER, |
449 SessionStateAnimator::ANIMATION_FADE_OUT, | 370 SessionStateAnimator::ANIMATION_FADE_OUT, |
450 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 371 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
451 observer); | |
452 // Hide the screen locker containers so we can raise them later. | 372 // Hide the screen locker containers so we can raise them later. |
453 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 373 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
454 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 374 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
455 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 375 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
456 AnimateBackgroundAppearanceIfNecessary( | 376 AnimateBackgroundAppearanceIfNecessary( |
457 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, observer); | 377 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); |
458 | 378 |
459 observer->Unpause(); | 379 animation_sequence->EndSequence(); |
460 | 380 |
461 DispatchCancelMode(); | 381 DispatchCancelMode(); |
462 FOR_EACH_OBSERVER(LockStateObserver, observers_, | 382 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
463 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED)); | 383 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED)); |
464 } | 384 } |
465 | 385 |
466 void LockStateController::StartCancellablePreLockAnimation() { | 386 void LockStateController::StartCancellablePreLockAnimation() { |
467 animating_lock_ = true; | 387 animating_lock_ = true; |
468 StoreUnlockedProperties(); | 388 StoreUnlockedProperties(); |
469 VLOG(1) << "StartCancellablePreLockAnimation"; | 389 VLOG(1) << "StartCancellablePreLockAnimation"; |
470 base::Closure next_animation_starter = | 390 base::Closure next_animation_starter = |
471 base::Bind(&LockStateController::PreLockAnimationFinished, | 391 base::Bind(&LockStateController::PreLockAnimationFinished, |
472 weak_ptr_factory_.GetWeakPtr(), | 392 weak_ptr_factory_.GetWeakPtr(), |
473 true /* request_lock */); | 393 true /* request_lock */); |
474 AnimationFinishedObserver* observer = | 394 SessionStateAnimator::AnimationSequence* animation_sequence = |
475 new AnimationFinishedObserver(next_animation_starter); | 395 animator_->BeginAnimationSequence(next_animation_starter); |
476 | 396 |
477 observer->Pause(); | 397 animation_sequence->StartAnimation( |
478 | |
479 animator_->StartAnimationWithObserver( | |
480 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 398 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
481 SessionStateAnimator::ANIMATION_LIFT, | 399 SessionStateAnimator::ANIMATION_LIFT, |
482 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 400 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
483 observer); | 401 animation_sequence->StartAnimation( |
484 animator_->StartAnimationWithObserver( | |
485 SessionStateAnimator::LAUNCHER, | 402 SessionStateAnimator::LAUNCHER, |
486 SessionStateAnimator::ANIMATION_FADE_OUT, | 403 SessionStateAnimator::ANIMATION_FADE_OUT, |
487 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 404 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
488 observer); | |
489 // Hide the screen locker containers so we can raise them later. | 405 // Hide the screen locker containers so we can raise them later. |
490 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 406 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
491 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 407 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
492 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 408 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
493 AnimateBackgroundAppearanceIfNecessary( | 409 AnimateBackgroundAppearanceIfNecessary( |
494 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, observer); | 410 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence); |
495 | 411 |
496 DispatchCancelMode(); | 412 DispatchCancelMode(); |
497 FOR_EACH_OBSERVER(LockStateObserver, observers_, | 413 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
498 OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); | 414 OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); |
499 observer->Unpause(); | 415 animation_sequence->EndSequence(); |
500 } | 416 } |
501 | 417 |
502 void LockStateController::CancelPreLockAnimation() { | 418 void LockStateController::CancelPreLockAnimation() { |
503 VLOG(1) << "CancelPreLockAnimation"; | 419 VLOG(1) << "CancelPreLockAnimation"; |
504 base::Closure next_animation_starter = | 420 base::Closure next_animation_starter = |
505 base::Bind(&LockStateController::LockAnimationCancelled, | 421 base::Bind(&LockStateController::LockAnimationCancelled, |
506 weak_ptr_factory_.GetWeakPtr()); | 422 weak_ptr_factory_.GetWeakPtr()); |
507 AnimationFinishedObserver* observer = | 423 SessionStateAnimator::AnimationSequence* animation_sequence = |
508 new AnimationFinishedObserver(next_animation_starter); | 424 animator_->BeginAnimationSequence(next_animation_starter); |
509 | 425 |
510 observer->Pause(); | 426 animation_sequence->StartAnimation( |
511 | |
512 animator_->StartAnimationWithObserver( | |
513 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 427 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
514 SessionStateAnimator::ANIMATION_UNDO_LIFT, | 428 SessionStateAnimator::ANIMATION_UNDO_LIFT, |
515 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 429 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); |
516 observer); | 430 animation_sequence->StartAnimation( |
517 animator_->StartAnimationWithObserver( | |
518 SessionStateAnimator::LAUNCHER, | 431 SessionStateAnimator::LAUNCHER, |
519 SessionStateAnimator::ANIMATION_FADE_IN, | 432 SessionStateAnimator::ANIMATION_FADE_IN, |
| 433 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); |
| 434 AnimateBackgroundHidingIfNecessary( |
520 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 435 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, |
521 observer); | 436 animation_sequence); |
522 AnimateBackgroundHidingIfNecessary( | |
523 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, observer); | |
524 | 437 |
525 observer->Unpause(); | 438 animation_sequence->EndSequence(); |
526 } | 439 } |
527 | 440 |
528 void LockStateController::StartPostLockAnimation() { | 441 void LockStateController::StartPostLockAnimation() { |
529 VLOG(1) << "StartPostLockAnimation"; | 442 VLOG(1) << "StartPostLockAnimation"; |
530 base::Closure next_animation_starter = | 443 base::Closure next_animation_starter = |
531 base::Bind(&LockStateController::PostLockAnimationFinished, | 444 base::Bind(&LockStateController::PostLockAnimationFinished, |
532 weak_ptr_factory_.GetWeakPtr()); | 445 weak_ptr_factory_.GetWeakPtr()); |
| 446 SessionStateAnimator::AnimationSequence* animation_sequence = |
| 447 animator_->BeginAnimationSequence(next_animation_starter); |
533 | 448 |
534 AnimationFinishedObserver* observer = | 449 animation_sequence->StartAnimation( |
535 new AnimationFinishedObserver(next_animation_starter); | |
536 | |
537 observer->Pause(); | |
538 animator_->StartAnimationWithObserver( | |
539 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 450 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
540 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, | 451 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, |
541 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 452 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
542 observer); | 453 animation_sequence->EndSequence(); |
543 observer->Unpause(); | |
544 } | 454 } |
545 | 455 |
546 void LockStateController::StartUnlockAnimationBeforeUIDestroyed( | 456 void LockStateController::StartUnlockAnimationBeforeUIDestroyed( |
547 base::Closure& callback) { | 457 base::Closure& callback) { |
548 VLOG(1) << "StartUnlockAnimationBeforeUIDestroyed"; | 458 VLOG(1) << "StartUnlockAnimationBeforeUIDestroyed"; |
549 animator_->StartAnimationWithCallback( | 459 animator_->StartAnimationWithCallback( |
550 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 460 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
551 SessionStateAnimator::ANIMATION_LIFT, | 461 SessionStateAnimator::ANIMATION_LIFT, |
552 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 462 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
553 callback); | 463 callback); |
554 } | 464 } |
555 | 465 |
556 void LockStateController::StartUnlockAnimationAfterUIDestroyed() { | 466 void LockStateController::StartUnlockAnimationAfterUIDestroyed() { |
557 VLOG(1) << "StartUnlockAnimationAfterUIDestroyed"; | 467 VLOG(1) << "StartUnlockAnimationAfterUIDestroyed"; |
558 base::Closure next_animation_starter = | 468 base::Closure next_animation_starter = |
559 base::Bind(&LockStateController::UnlockAnimationAfterUIDestroyedFinished, | 469 base::Bind(&LockStateController::UnlockAnimationAfterUIDestroyedFinished, |
560 weak_ptr_factory_.GetWeakPtr()); | 470 weak_ptr_factory_.GetWeakPtr()); |
| 471 SessionStateAnimator::AnimationSequence* animation_sequence = |
| 472 animator_->BeginAnimationSequence(next_animation_starter); |
561 | 473 |
562 AnimationFinishedObserver* observer = | 474 animation_sequence->StartAnimation( |
563 new AnimationFinishedObserver(next_animation_starter); | |
564 | |
565 observer->Pause(); | |
566 | |
567 animator_->StartAnimationWithObserver( | |
568 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 475 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
569 SessionStateAnimator::ANIMATION_DROP, | 476 SessionStateAnimator::ANIMATION_DROP, |
570 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 477 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
571 observer); | 478 animation_sequence->StartAnimation( |
572 animator_->StartAnimationWithObserver( | |
573 SessionStateAnimator::LAUNCHER, | 479 SessionStateAnimator::LAUNCHER, |
574 SessionStateAnimator::ANIMATION_FADE_IN, | 480 SessionStateAnimator::ANIMATION_FADE_IN, |
575 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 481 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
576 observer); | |
577 AnimateBackgroundHidingIfNecessary( | 482 AnimateBackgroundHidingIfNecessary( |
578 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, observer); | 483 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); |
579 observer->Unpause(); | 484 animation_sequence->EndSequence(); |
580 } | 485 } |
581 | 486 |
582 void LockStateController::LockAnimationCancelled() { | 487 void LockStateController::LockAnimationCancelled() { |
583 can_cancel_lock_animation_ = false; | 488 can_cancel_lock_animation_ = false; |
584 RestoreUnlockedProperties(); | 489 RestoreUnlockedProperties(); |
585 } | 490 } |
586 | 491 |
587 void LockStateController::PreLockAnimationFinished(bool request_lock) { | 492 void LockStateController::PreLockAnimationFinished(bool request_lock) { |
588 VLOG(1) << "PreLockAnimationFinished"; | 493 VLOG(1) << "PreLockAnimationFinished"; |
589 can_cancel_lock_animation_ = false; | 494 can_cancel_lock_animation_ = false; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 // Restore background visibility. | 566 // Restore background visibility. |
662 animator_->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, | 567 animator_->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, |
663 SessionStateAnimator::ANIMATION_FADE_IN, | 568 SessionStateAnimator::ANIMATION_FADE_IN, |
664 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 569 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
665 } | 570 } |
666 unlocked_properties_.reset(); | 571 unlocked_properties_.reset(); |
667 } | 572 } |
668 | 573 |
669 void LockStateController::AnimateBackgroundAppearanceIfNecessary( | 574 void LockStateController::AnimateBackgroundAppearanceIfNecessary( |
670 SessionStateAnimator::AnimationSpeed speed, | 575 SessionStateAnimator::AnimationSpeed speed, |
671 ui::LayerAnimationObserver* observer) { | 576 SessionStateAnimator::AnimationSequence* animation_sequence) { |
672 if (unlocked_properties_.get() && | 577 if (unlocked_properties_.get() && |
673 unlocked_properties_->background_is_hidden) { | 578 unlocked_properties_->background_is_hidden) { |
674 animator_->StartAnimationWithObserver( | 579 animation_sequence->StartAnimation( |
675 SessionStateAnimator::DESKTOP_BACKGROUND, | 580 SessionStateAnimator::DESKTOP_BACKGROUND, |
676 SessionStateAnimator::ANIMATION_FADE_IN, | 581 SessionStateAnimator::ANIMATION_FADE_IN, |
677 speed, | 582 speed); |
678 observer); | |
679 } | 583 } |
680 } | 584 } |
681 | 585 |
682 void LockStateController::AnimateBackgroundHidingIfNecessary( | 586 void LockStateController::AnimateBackgroundHidingIfNecessary( |
683 SessionStateAnimator::AnimationSpeed speed, | 587 SessionStateAnimator::AnimationSpeed speed, |
684 ui::LayerAnimationObserver* observer) { | 588 SessionStateAnimator::AnimationSequence* animation_sequence) { |
685 if (unlocked_properties_.get() && | 589 if (unlocked_properties_.get() && |
686 unlocked_properties_->background_is_hidden) { | 590 unlocked_properties_->background_is_hidden) { |
687 animator_->StartAnimationWithObserver( | 591 animation_sequence->StartAnimation( |
688 SessionStateAnimator::DESKTOP_BACKGROUND, | 592 SessionStateAnimator::DESKTOP_BACKGROUND, |
689 SessionStateAnimator::ANIMATION_FADE_OUT, | 593 SessionStateAnimator::ANIMATION_FADE_OUT, |
690 speed, | 594 speed); |
691 observer); | |
692 } | 595 } |
693 } | 596 } |
694 | 597 |
695 } // namespace ash | 598 } // namespace ash |
OLD | NEW |