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" | |
23 #include "ui/compositor/scoped_layer_animation_settings.h" | |
24 #include "ui/views/controls/menu/menu_controller.h" | 24 #include "ui/views/controls/menu/menu_controller.h" |
25 #include "ui/wm/core/compound_event_filter.h" | 25 #include "ui/wm/core/compound_event_filter.h" |
26 | 26 |
27 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
29 #include "media/audio/sounds/sounds_manager.h" | 29 #include "media/audio/sounds/sounds_manager.h" |
30 #endif | 30 #endif |
31 | 31 |
32 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
33 using media::SoundsManager; | 33 using media::SoundsManager; |
34 #endif | 34 #endif |
35 | 35 |
36 namespace ash { | 36 namespace ash { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
41 const int kMaxShutdownSoundDurationMs = 1500; | 41 const int kMaxShutdownSoundDurationMs = 1500; |
42 #endif | 42 #endif |
43 | 43 |
44 aura::Window* GetBackground() { | |
45 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | |
46 return Shell::GetContainer(root_window, | |
47 kShellWindowId_DesktopBackgroundContainer); | |
48 } | |
49 | |
50 bool IsBackgroundHidden() { | |
51 return !GetBackground()->IsVisible(); | |
52 } | |
53 | |
54 void ShowBackground() { | |
55 ui::ScopedLayerAnimationSettings settings( | |
56 GetBackground()->layer()->GetAnimator()); | |
57 settings.SetTransitionDuration(base::TimeDelta()); | |
58 GetBackground()->Show(); | |
59 } | |
60 | |
61 void HideBackground() { | |
62 ui::ScopedLayerAnimationSettings settings( | |
63 GetBackground()->layer()->GetAnimator()); | |
64 settings.SetTransitionDuration(base::TimeDelta()); | |
65 GetBackground()->Hide(); | |
66 } | |
67 | |
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 | 44 } // namespace |
152 | 45 |
153 const int LockStateController::kLockTimeoutMs = 400; | 46 const int LockStateController::kLockTimeoutMs = 400; |
154 const int LockStateController::kShutdownTimeoutMs = 400; | 47 const int LockStateController::kShutdownTimeoutMs = 400; |
155 const int LockStateController::kLockFailTimeoutMs = 8000; | 48 const int LockStateController::kLockFailTimeoutMs = 8000; |
156 const int LockStateController::kLockToShutdownTimeoutMs = 150; | 49 const int LockStateController::kLockToShutdownTimeoutMs = 150; |
157 const int LockStateController::kShutdownRequestDelayMs = 50; | 50 const int LockStateController::kShutdownRequestDelayMs = 50; |
158 | 51 |
159 LockStateController::TestApi::TestApi(LockStateController* controller) | 52 LockStateController::TestApi::TestApi(LockStateController* controller) |
160 : controller_(controller) { | 53 : controller_(controller) { |
161 } | 54 } |
162 | 55 |
163 LockStateController::TestApi::~TestApi() { | 56 LockStateController::TestApi::~TestApi() { |
164 } | 57 } |
165 | 58 |
166 LockStateController::LockStateController() | 59 LockStateController::LockStateController() |
167 : animator_(new SessionStateAnimator()), | 60 : animator_(new SessionStateAnimatorImpl()), |
168 login_status_(user::LOGGED_IN_NONE), | 61 login_status_(user::LOGGED_IN_NONE), |
169 system_is_locked_(false), | 62 system_is_locked_(false), |
170 shutting_down_(false), | 63 shutting_down_(false), |
171 shutdown_after_lock_(false), | 64 shutdown_after_lock_(false), |
172 animating_lock_(false), | 65 animating_lock_(false), |
173 can_cancel_lock_animation_(false), | 66 can_cancel_lock_animation_(false), |
174 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
175 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); | 68 Shell::GetPrimaryRootWindow()->GetHost()->AddObserver(this); |
176 } | 69 } |
177 | 70 |
178 LockStateController::~LockStateController() { | 71 LockStateController::~LockStateController() { |
179 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); | 72 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); |
180 } | 73 } |
181 | 74 |
182 void LockStateController::SetDelegate(LockStateControllerDelegate* delegate) { | 75 void LockStateController::SetDelegate( |
183 delegate_.reset(delegate); | 76 scoped_ptr<LockStateControllerDelegate> delegate) { |
| 77 delegate_ = delegate.Pass(); |
184 } | 78 } |
185 | 79 |
186 void LockStateController::AddObserver(LockStateObserver* observer) { | 80 void LockStateController::AddObserver(LockStateObserver* observer) { |
187 observers_.AddObserver(observer); | 81 observers_.AddObserver(observer); |
188 } | 82 } |
189 | 83 |
190 void LockStateController::RemoveObserver(LockStateObserver* observer) { | 84 void LockStateController::RemoveObserver(LockStateObserver* observer) { |
191 observers_.RemoveObserver(observer); | 85 observers_.RemoveObserver(observer); |
192 } | 86 } |
193 | 87 |
194 bool LockStateController::HasObserver(LockStateObserver* observer) { | 88 bool LockStateController::HasObserver(LockStateObserver* observer) { |
195 return observers_.HasObserver(observer); | 89 return observers_.HasObserver(observer); |
196 } | 90 } |
197 | 91 |
198 void LockStateController::StartLockAnimation( | 92 void LockStateController::StartLockAnimation( |
199 bool shutdown_after_lock) { | 93 bool shutdown_after_lock) { |
200 if (animating_lock_) | 94 if (animating_lock_) |
201 return; | 95 return; |
202 shutdown_after_lock_ = shutdown_after_lock; | 96 shutdown_after_lock_ = shutdown_after_lock; |
203 can_cancel_lock_animation_ = true; | 97 can_cancel_lock_animation_ = true; |
204 | 98 |
205 StartCancellablePreLockAnimation(); | 99 StartCancellablePreLockAnimation(); |
206 } | 100 } |
207 | 101 |
208 void LockStateController::StartShutdownAnimation() { | 102 void LockStateController::StartShutdownAnimation() { |
209 StartCancellableShutdownAnimation(); | 103 StartCancellableShutdownAnimation(); |
210 } | 104 } |
211 | 105 |
212 void LockStateController::StartLockAnimationAndLockImmediately() { | 106 void LockStateController::StartLockAnimationAndLockImmediately( |
| 107 bool shutdown_after_lock) { |
213 if (animating_lock_) | 108 if (animating_lock_) |
214 return; | 109 return; |
| 110 shutdown_after_lock_ = shutdown_after_lock; |
215 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); | 111 StartImmediatePreLockAnimation(true /* request_lock_on_completion */); |
216 } | 112 } |
217 | 113 |
218 bool LockStateController::LockRequested() { | 114 bool LockStateController::LockRequested() { |
219 return lock_fail_timer_.IsRunning(); | 115 return lock_fail_timer_.IsRunning(); |
220 } | 116 } |
221 | 117 |
222 bool LockStateController::ShutdownRequested() { | 118 bool LockStateController::ShutdownRequested() { |
223 return shutting_down_; | 119 return shutting_down_; |
224 } | 120 } |
(...skipping 21 matching lines...) Expand all Loading... |
246 return; | 142 return; |
247 if (lock_to_shutdown_timer_.IsRunning()) { | 143 if (lock_to_shutdown_timer_.IsRunning()) { |
248 lock_to_shutdown_timer_.Stop(); | 144 lock_to_shutdown_timer_.Stop(); |
249 return; | 145 return; |
250 } | 146 } |
251 if (shutdown_after_lock_) { | 147 if (shutdown_after_lock_) { |
252 shutdown_after_lock_ = false; | 148 shutdown_after_lock_ = false; |
253 return; | 149 return; |
254 } | 150 } |
255 | 151 |
256 animator_->StartGlobalAnimation( | 152 animator_->StartAnimation( |
| 153 SessionStateAnimator::ROOT_CONTAINER, |
257 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS, | 154 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS, |
258 SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); | 155 SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); |
259 pre_shutdown_timer_.Stop(); | 156 pre_shutdown_timer_.Stop(); |
260 } | 157 } |
261 | 158 |
262 void LockStateController::OnStartingLock() { | 159 void LockStateController::OnStartingLock() { |
263 if (shutting_down_ || system_is_locked_) | 160 if (shutting_down_ || system_is_locked_) |
264 return; | 161 return; |
265 if (animating_lock_) | 162 if (animating_lock_) |
266 return; | 163 return; |
267 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); | 164 StartImmediatePreLockAnimation(false /* request_lock_on_completion */); |
268 } | 165 } |
269 | 166 |
270 void LockStateController::RequestShutdown() { | 167 void LockStateController::RequestShutdown() { |
271 if (shutting_down_) | 168 if (shutting_down_) |
272 return; | 169 return; |
273 | 170 |
274 shutting_down_ = true; | 171 shutting_down_ = true; |
275 | 172 |
276 Shell* shell = ash::Shell::GetInstance(); | 173 Shell* shell = ash::Shell::GetInstance(); |
277 shell->cursor_manager()->HideCursor(); | 174 shell->cursor_manager()->HideCursor(); |
278 shell->cursor_manager()->LockCursor(); | 175 shell->cursor_manager()->LockCursor(); |
279 | 176 |
280 animator_->StartGlobalAnimation( | 177 animator_->StartAnimation( |
| 178 SessionStateAnimator::ROOT_CONTAINER, |
281 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 179 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
282 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 180 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
283 StartRealShutdownTimer(true); | 181 StartRealShutdownTimer(true); |
284 } | 182 } |
285 | 183 |
286 void LockStateController::OnLockScreenHide( | 184 void LockStateController::OnLockScreenHide( |
287 base::Callback<void(void)>& callback) { | 185 base::Callback<void(void)>& callback) { |
288 StartUnlockAnimationBeforeUIDestroyed(callback); | 186 StartUnlockAnimationBeforeUIDestroyed(callback); |
289 } | 187 } |
290 | 188 |
(...skipping 16 matching lines...) Expand all Loading... |
307 | 205 |
308 void LockStateController::OnAppTerminating() { | 206 void LockStateController::OnAppTerminating() { |
309 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 207 // 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. | 208 // 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. | 209 // This is also the case when the user signs off. |
312 if (!shutting_down_) { | 210 if (!shutting_down_) { |
313 shutting_down_ = true; | 211 shutting_down_ = true; |
314 Shell* shell = ash::Shell::GetInstance(); | 212 Shell* shell = ash::Shell::GetInstance(); |
315 shell->cursor_manager()->HideCursor(); | 213 shell->cursor_manager()->HideCursor(); |
316 shell->cursor_manager()->LockCursor(); | 214 shell->cursor_manager()->LockCursor(); |
317 animator_->StartAnimation(SessionStateAnimator::kAllContainersMask, | 215 animator_->StartAnimation(SessionStateAnimator::kAllNonRootContainersMask, |
318 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 216 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
319 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 217 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
320 } | 218 } |
321 } | 219 } |
322 | 220 |
323 void LockStateController::OnLockStateChanged(bool locked) { | 221 void LockStateController::OnLockStateChanged(bool locked) { |
324 VLOG(1) << "OnLockStateChanged " << locked; | 222 VLOG(1) << "OnLockStateChanged " << locked; |
325 if (shutting_down_ || (system_is_locked_ == locked)) | 223 if (shutting_down_ || (system_is_locked_ == locked)) |
326 return; | 224 return; |
327 | 225 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 309 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
412 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); | 310 UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); |
413 delegate_->RequestShutdown(); | 311 delegate_->RequestShutdown(); |
414 } | 312 } |
415 | 313 |
416 void LockStateController::StartCancellableShutdownAnimation() { | 314 void LockStateController::StartCancellableShutdownAnimation() { |
417 Shell* shell = ash::Shell::GetInstance(); | 315 Shell* shell = ash::Shell::GetInstance(); |
418 // Hide cursor, but let it reappear if the mouse moves. | 316 // Hide cursor, but let it reappear if the mouse moves. |
419 shell->cursor_manager()->HideCursor(); | 317 shell->cursor_manager()->HideCursor(); |
420 | 318 |
421 animator_->StartGlobalAnimation( | 319 animator_->StartAnimation( |
| 320 SessionStateAnimator::ROOT_CONTAINER, |
422 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 321 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
423 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 322 SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
424 StartPreShutdownAnimationTimer(); | 323 StartPreShutdownAnimationTimer(); |
425 } | 324 } |
426 | 325 |
427 void LockStateController::StartImmediatePreLockAnimation( | 326 void LockStateController::StartImmediatePreLockAnimation( |
428 bool request_lock_on_completion) { | 327 bool request_lock_on_completion) { |
429 VLOG(1) << "StartImmediatePreLockAnimation " << request_lock_on_completion; | 328 VLOG(1) << "StartImmediatePreLockAnimation " << request_lock_on_completion; |
430 animating_lock_ = true; | 329 animating_lock_ = true; |
431 StoreUnlockedProperties(); | 330 StoreUnlockedProperties(); |
432 | 331 |
433 base::Closure next_animation_starter = | 332 base::Closure next_animation_starter = |
434 base::Bind(&LockStateController::PreLockAnimationFinished, | 333 base::Bind(&LockStateController::PreLockAnimationFinished, |
435 weak_ptr_factory_.GetWeakPtr(), | 334 weak_ptr_factory_.GetWeakPtr(), |
436 request_lock_on_completion); | 335 request_lock_on_completion); |
437 AnimationFinishedObserver* observer = | 336 SessionStateAnimator::AnimationSequence* animation_sequence = |
438 new AnimationFinishedObserver(next_animation_starter); | 337 animator_->BeginAnimationSequence(next_animation_starter); |
439 | 338 |
440 observer->Pause(); | 339 animation_sequence->StartAnimation( |
441 | |
442 animator_->StartAnimationWithObserver( | |
443 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 340 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
444 SessionStateAnimator::ANIMATION_LIFT, | 341 SessionStateAnimator::ANIMATION_LIFT, |
445 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 342 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
446 observer); | 343 animation_sequence->StartAnimation( |
447 animator_->StartAnimationWithObserver( | |
448 SessionStateAnimator::LAUNCHER, | 344 SessionStateAnimator::LAUNCHER, |
449 SessionStateAnimator::ANIMATION_FADE_OUT, | 345 SessionStateAnimator::ANIMATION_FADE_OUT, |
450 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 346 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
451 observer); | |
452 // Hide the screen locker containers so we can raise them later. | 347 // Hide the screen locker containers so we can raise them later. |
453 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 348 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
454 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 349 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
455 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 350 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
456 AnimateBackgroundAppearanceIfNecessary( | 351 AnimateBackgroundAppearanceIfNecessary( |
457 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, observer); | 352 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); |
458 | 353 |
459 observer->Unpause(); | 354 animation_sequence->EndSequence(); |
460 | 355 |
461 DispatchCancelMode(); | 356 DispatchCancelMode(); |
462 FOR_EACH_OBSERVER(LockStateObserver, observers_, | 357 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
463 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED)); | 358 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED)); |
464 } | 359 } |
465 | 360 |
466 void LockStateController::StartCancellablePreLockAnimation() { | 361 void LockStateController::StartCancellablePreLockAnimation() { |
467 animating_lock_ = true; | 362 animating_lock_ = true; |
468 StoreUnlockedProperties(); | 363 StoreUnlockedProperties(); |
469 VLOG(1) << "StartCancellablePreLockAnimation"; | 364 VLOG(1) << "StartCancellablePreLockAnimation"; |
470 base::Closure next_animation_starter = | 365 base::Closure next_animation_starter = |
471 base::Bind(&LockStateController::PreLockAnimationFinished, | 366 base::Bind(&LockStateController::PreLockAnimationFinished, |
472 weak_ptr_factory_.GetWeakPtr(), | 367 weak_ptr_factory_.GetWeakPtr(), |
473 true /* request_lock */); | 368 true /* request_lock */); |
474 AnimationFinishedObserver* observer = | 369 SessionStateAnimator::AnimationSequence* animation_sequence = |
475 new AnimationFinishedObserver(next_animation_starter); | 370 animator_->BeginAnimationSequence(next_animation_starter); |
476 | 371 |
477 observer->Pause(); | 372 animation_sequence->StartAnimation( |
478 | |
479 animator_->StartAnimationWithObserver( | |
480 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 373 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
481 SessionStateAnimator::ANIMATION_LIFT, | 374 SessionStateAnimator::ANIMATION_LIFT, |
482 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 375 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
483 observer); | 376 animation_sequence->StartAnimation( |
484 animator_->StartAnimationWithObserver( | |
485 SessionStateAnimator::LAUNCHER, | 377 SessionStateAnimator::LAUNCHER, |
486 SessionStateAnimator::ANIMATION_FADE_OUT, | 378 SessionStateAnimator::ANIMATION_FADE_OUT, |
487 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, | 379 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
488 observer); | |
489 // Hide the screen locker containers so we can raise them later. | 380 // Hide the screen locker containers so we can raise them later. |
490 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 381 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
491 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 382 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
492 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 383 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
493 AnimateBackgroundAppearanceIfNecessary( | 384 AnimateBackgroundAppearanceIfNecessary( |
494 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, observer); | 385 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence); |
495 | 386 |
496 DispatchCancelMode(); | 387 DispatchCancelMode(); |
497 FOR_EACH_OBSERVER(LockStateObserver, observers_, | 388 FOR_EACH_OBSERVER(LockStateObserver, observers_, |
498 OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); | 389 OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); |
499 observer->Unpause(); | 390 animation_sequence->EndSequence(); |
500 } | 391 } |
501 | 392 |
502 void LockStateController::CancelPreLockAnimation() { | 393 void LockStateController::CancelPreLockAnimation() { |
503 VLOG(1) << "CancelPreLockAnimation"; | 394 VLOG(1) << "CancelPreLockAnimation"; |
504 base::Closure next_animation_starter = | 395 base::Closure next_animation_starter = |
505 base::Bind(&LockStateController::LockAnimationCancelled, | 396 base::Bind(&LockStateController::LockAnimationCancelled, |
506 weak_ptr_factory_.GetWeakPtr()); | 397 weak_ptr_factory_.GetWeakPtr()); |
507 AnimationFinishedObserver* observer = | 398 SessionStateAnimator::AnimationSequence* animation_sequence = |
508 new AnimationFinishedObserver(next_animation_starter); | 399 animator_->BeginAnimationSequence(next_animation_starter); |
509 | 400 |
510 observer->Pause(); | 401 animation_sequence->StartAnimation( |
511 | |
512 animator_->StartAnimationWithObserver( | |
513 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 402 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
514 SessionStateAnimator::ANIMATION_UNDO_LIFT, | 403 SessionStateAnimator::ANIMATION_UNDO_LIFT, |
515 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 404 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); |
516 observer); | 405 animation_sequence->StartAnimation( |
517 animator_->StartAnimationWithObserver( | |
518 SessionStateAnimator::LAUNCHER, | 406 SessionStateAnimator::LAUNCHER, |
519 SessionStateAnimator::ANIMATION_FADE_IN, | 407 SessionStateAnimator::ANIMATION_FADE_IN, |
| 408 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); |
| 409 AnimateBackgroundHidingIfNecessary( |
520 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, | 410 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, |
521 observer); | 411 animation_sequence); |
522 AnimateBackgroundHidingIfNecessary( | |
523 SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, observer); | |
524 | 412 |
525 observer->Unpause(); | 413 animation_sequence->EndSequence(); |
526 } | 414 } |
527 | 415 |
528 void LockStateController::StartPostLockAnimation() { | 416 void LockStateController::StartPostLockAnimation() { |
529 VLOG(1) << "StartPostLockAnimation"; | 417 VLOG(1) << "StartPostLockAnimation"; |
530 base::Closure next_animation_starter = | 418 base::Closure next_animation_starter = |
531 base::Bind(&LockStateController::PostLockAnimationFinished, | 419 base::Bind(&LockStateController::PostLockAnimationFinished, |
532 weak_ptr_factory_.GetWeakPtr()); | 420 weak_ptr_factory_.GetWeakPtr()); |
| 421 SessionStateAnimator::AnimationSequence* animation_sequence = |
| 422 animator_->BeginAnimationSequence(next_animation_starter); |
533 | 423 |
534 AnimationFinishedObserver* observer = | 424 animation_sequence->StartAnimation( |
535 new AnimationFinishedObserver(next_animation_starter); | |
536 | |
537 observer->Pause(); | |
538 animator_->StartAnimationWithObserver( | |
539 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 425 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
540 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, | 426 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, |
541 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 427 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
542 observer); | 428 animation_sequence->EndSequence(); |
543 observer->Unpause(); | |
544 } | 429 } |
545 | 430 |
546 void LockStateController::StartUnlockAnimationBeforeUIDestroyed( | 431 void LockStateController::StartUnlockAnimationBeforeUIDestroyed( |
547 base::Closure& callback) { | 432 base::Closure& callback) { |
548 VLOG(1) << "StartUnlockAnimationBeforeUIDestroyed"; | 433 VLOG(1) << "StartUnlockAnimationBeforeUIDestroyed"; |
549 animator_->StartAnimationWithCallback( | 434 animator_->StartAnimationWithCallback( |
550 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 435 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
551 SessionStateAnimator::ANIMATION_LIFT, | 436 SessionStateAnimator::ANIMATION_LIFT, |
552 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 437 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
553 callback); | 438 callback); |
554 } | 439 } |
555 | 440 |
556 void LockStateController::StartUnlockAnimationAfterUIDestroyed() { | 441 void LockStateController::StartUnlockAnimationAfterUIDestroyed() { |
557 VLOG(1) << "StartUnlockAnimationAfterUIDestroyed"; | 442 VLOG(1) << "StartUnlockAnimationAfterUIDestroyed"; |
558 base::Closure next_animation_starter = | 443 base::Closure next_animation_starter = |
559 base::Bind(&LockStateController::UnlockAnimationAfterUIDestroyedFinished, | 444 base::Bind(&LockStateController::UnlockAnimationAfterUIDestroyedFinished, |
560 weak_ptr_factory_.GetWeakPtr()); | 445 weak_ptr_factory_.GetWeakPtr()); |
| 446 SessionStateAnimator::AnimationSequence* animation_sequence = |
| 447 animator_->BeginAnimationSequence(next_animation_starter); |
561 | 448 |
562 AnimationFinishedObserver* observer = | 449 animation_sequence->StartAnimation( |
563 new AnimationFinishedObserver(next_animation_starter); | |
564 | |
565 observer->Pause(); | |
566 | |
567 animator_->StartAnimationWithObserver( | |
568 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 450 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
569 SessionStateAnimator::ANIMATION_DROP, | 451 SessionStateAnimator::ANIMATION_DROP, |
570 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 452 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
571 observer); | 453 animation_sequence->StartAnimation( |
572 animator_->StartAnimationWithObserver( | |
573 SessionStateAnimator::LAUNCHER, | 454 SessionStateAnimator::LAUNCHER, |
574 SessionStateAnimator::ANIMATION_FADE_IN, | 455 SessionStateAnimator::ANIMATION_FADE_IN, |
575 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 456 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
576 observer); | |
577 AnimateBackgroundHidingIfNecessary( | 457 AnimateBackgroundHidingIfNecessary( |
578 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, observer); | 458 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); |
579 observer->Unpause(); | 459 animation_sequence->EndSequence(); |
580 } | 460 } |
581 | 461 |
582 void LockStateController::LockAnimationCancelled() { | 462 void LockStateController::LockAnimationCancelled() { |
583 can_cancel_lock_animation_ = false; | 463 can_cancel_lock_animation_ = false; |
584 RestoreUnlockedProperties(); | 464 RestoreUnlockedProperties(); |
585 } | 465 } |
586 | 466 |
587 void LockStateController::PreLockAnimationFinished(bool request_lock) { | 467 void LockStateController::PreLockAnimationFinished(bool request_lock) { |
588 VLOG(1) << "PreLockAnimationFinished"; | 468 VLOG(1) << "PreLockAnimationFinished"; |
589 can_cancel_lock_animation_ = false; | 469 can_cancel_lock_animation_ = false; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 } | 515 } |
636 } | 516 } |
637 | 517 |
638 void LockStateController::UnlockAnimationAfterUIDestroyedFinished() { | 518 void LockStateController::UnlockAnimationAfterUIDestroyedFinished() { |
639 RestoreUnlockedProperties(); | 519 RestoreUnlockedProperties(); |
640 } | 520 } |
641 | 521 |
642 void LockStateController::StoreUnlockedProperties() { | 522 void LockStateController::StoreUnlockedProperties() { |
643 if (!unlocked_properties_) { | 523 if (!unlocked_properties_) { |
644 unlocked_properties_.reset(new UnlockedStateProperties()); | 524 unlocked_properties_.reset(new UnlockedStateProperties()); |
645 unlocked_properties_->background_is_hidden = IsBackgroundHidden(); | 525 unlocked_properties_->background_is_hidden = |
| 526 animator_->IsBackgroundHidden(); |
646 } | 527 } |
647 if (unlocked_properties_->background_is_hidden) { | 528 if (unlocked_properties_->background_is_hidden) { |
648 // Hide background so that it can be animated later. | 529 // Hide background so that it can be animated later. |
649 animator_->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, | 530 animator_->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, |
650 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 531 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
651 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 532 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
652 ShowBackground(); | 533 animator_->ShowBackground(); |
653 } | 534 } |
654 } | 535 } |
655 | 536 |
656 void LockStateController::RestoreUnlockedProperties() { | 537 void LockStateController::RestoreUnlockedProperties() { |
657 if (!unlocked_properties_) | 538 if (!unlocked_properties_) |
658 return; | 539 return; |
659 if (unlocked_properties_->background_is_hidden) { | 540 if (unlocked_properties_->background_is_hidden) { |
660 HideBackground(); | 541 animator_->HideBackground(); |
661 // Restore background visibility. | 542 // Restore background visibility. |
662 animator_->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, | 543 animator_->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, |
663 SessionStateAnimator::ANIMATION_FADE_IN, | 544 SessionStateAnimator::ANIMATION_FADE_IN, |
664 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 545 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
665 } | 546 } |
666 unlocked_properties_.reset(); | 547 unlocked_properties_.reset(); |
667 } | 548 } |
668 | 549 |
669 void LockStateController::AnimateBackgroundAppearanceIfNecessary( | 550 void LockStateController::AnimateBackgroundAppearanceIfNecessary( |
670 SessionStateAnimator::AnimationSpeed speed, | 551 SessionStateAnimator::AnimationSpeed speed, |
671 ui::LayerAnimationObserver* observer) { | 552 SessionStateAnimator::AnimationSequence* animation_sequence) { |
672 if (unlocked_properties_.get() && | 553 if (unlocked_properties_.get() && |
673 unlocked_properties_->background_is_hidden) { | 554 unlocked_properties_->background_is_hidden) { |
674 animator_->StartAnimationWithObserver( | 555 animation_sequence->StartAnimation( |
675 SessionStateAnimator::DESKTOP_BACKGROUND, | 556 SessionStateAnimator::DESKTOP_BACKGROUND, |
676 SessionStateAnimator::ANIMATION_FADE_IN, | 557 SessionStateAnimator::ANIMATION_FADE_IN, |
677 speed, | 558 speed); |
678 observer); | |
679 } | 559 } |
680 } | 560 } |
681 | 561 |
682 void LockStateController::AnimateBackgroundHidingIfNecessary( | 562 void LockStateController::AnimateBackgroundHidingIfNecessary( |
683 SessionStateAnimator::AnimationSpeed speed, | 563 SessionStateAnimator::AnimationSpeed speed, |
684 ui::LayerAnimationObserver* observer) { | 564 SessionStateAnimator::AnimationSequence* animation_sequence) { |
685 if (unlocked_properties_.get() && | 565 if (unlocked_properties_.get() && |
686 unlocked_properties_->background_is_hidden) { | 566 unlocked_properties_->background_is_hidden) { |
687 animator_->StartAnimationWithObserver( | 567 animation_sequence->StartAnimation( |
688 SessionStateAnimator::DESKTOP_BACKGROUND, | 568 SessionStateAnimator::DESKTOP_BACKGROUND, |
689 SessionStateAnimator::ANIMATION_FADE_OUT, | 569 SessionStateAnimator::ANIMATION_FADE_OUT, |
690 speed, | 570 speed); |
691 observer); | |
692 } | 571 } |
693 } | 572 } |
694 | 573 |
695 } // namespace ash | 574 } // namespace ash |
OLD | NEW |