| 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_impl2.h" | 5 #include "ash/wm/session_state_controller_impl2.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" |
| 11 #include "ash/wm/session_state_animator.h" | 11 #include "ash/wm/session_state_animator.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/timer.h" |
| 14 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 15 #include "ui/views/corewm/compound_event_filter.h" | 17 #include "ui/views/corewm/compound_event_filter.h" |
| 16 | 18 |
| 17 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
| 18 #include "base/chromeos/chromeos_version.h" | 20 #include "base/chromeos/chromeos_version.h" |
| 19 #endif | 21 #endif |
| 20 | 22 |
| 21 namespace ash { | 23 namespace ash { |
| 22 | 24 |
| 25 namespace { |
| 26 |
| 27 aura::Window* GetBackground() { |
| 28 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
| 29 return Shell::GetContainer(root_window, |
| 30 internal::kShellWindowId_DesktopBackgroundContainer); |
| 31 } |
| 32 |
| 33 bool IsBackgroundHidden() { |
| 34 return !GetBackground()->IsVisible(); |
| 35 } |
| 36 |
| 37 void ShowBackground() { |
| 38 ui::ScopedLayerAnimationSettings settings( |
| 39 GetBackground()->layer()->GetAnimator()); |
| 40 settings.SetTransitionDuration(base::TimeDelta()); |
| 41 GetBackground()->Show(); |
| 42 } |
| 43 |
| 44 void HideBackground() { |
| 45 ui::ScopedLayerAnimationSettings settings( |
| 46 GetBackground()->layer()->GetAnimator()); |
| 47 settings.SetTransitionDuration(base::TimeDelta()); |
| 48 GetBackground()->Hide(); |
| 49 } |
| 50 |
| 51 } // namespace |
| 52 |
| 23 SessionStateControllerImpl2::TestApi::TestApi( | 53 SessionStateControllerImpl2::TestApi::TestApi( |
| 24 SessionStateControllerImpl2* controller) | 54 SessionStateControllerImpl2* controller) |
| 25 : controller_(controller) { | 55 : controller_(controller) { |
| 26 } | 56 } |
| 27 | 57 |
| 28 SessionStateControllerImpl2::TestApi::~TestApi() { | 58 SessionStateControllerImpl2::TestApi::~TestApi() { |
| 29 } | 59 } |
| 30 | 60 |
| 31 SessionStateControllerImpl2::SessionStateControllerImpl2() | 61 SessionStateControllerImpl2::SessionStateControllerImpl2() |
| 32 : login_status_(user::LOGGED_IN_NONE), | 62 : login_status_(user::LOGGED_IN_NONE), |
| 33 system_is_locked_(false), | 63 system_is_locked_(false), |
| 34 shutting_down_(false), | 64 shutting_down_(false), |
| 35 shutdown_after_lock_(false) { | 65 shutdown_after_lock_(false), |
| 66 animating_lock_(false), |
| 67 undoable_lock_animation_(false) { |
| 36 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); | 68 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); |
| 37 } | 69 } |
| 38 | 70 |
| 39 SessionStateControllerImpl2::~SessionStateControllerImpl2() { | 71 SessionStateControllerImpl2::~SessionStateControllerImpl2() { |
| 40 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); | 72 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); |
| 41 } | 73 } |
| 42 | 74 |
| 43 void SessionStateControllerImpl2::OnLoginStateChanged( | 75 void SessionStateControllerImpl2::OnLoginStateChanged( |
| 44 user::LoginStatus status) { | 76 user::LoginStatus status) { |
| 45 if (status != user::LOGGED_IN_LOCKED) | 77 if (status != user::LOGGED_IN_LOCKED) |
| 46 login_status_ = status; | 78 login_status_ = status; |
| 47 system_is_locked_ = (status == user::LOGGED_IN_LOCKED); | 79 system_is_locked_ = (status == user::LOGGED_IN_LOCKED); |
| 48 } | 80 } |
| 49 | 81 |
| 50 void SessionStateControllerImpl2::OnAppTerminating() { | 82 void SessionStateControllerImpl2::OnAppTerminating() { |
| 51 // If we hear that Chrome is exiting but didn't request it ourselves, all we | 83 // If we hear that Chrome is exiting but didn't request it ourselves, all we |
| 52 // can really hope for is that we'll have time to clear the screen. | 84 // can really hope for is that we'll have time to clear the screen. |
| 85 // This is also a case when user signs off. |
| 53 if (!shutting_down_) { | 86 if (!shutting_down_) { |
| 54 shutting_down_ = true; | 87 shutting_down_ = true; |
| 55 Shell* shell = ash::Shell::GetInstance(); | 88 Shell* shell = ash::Shell::GetInstance(); |
| 56 shell->env_filter()->set_cursor_hidden_by_filter(false); | 89 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 57 shell->cursor_manager()->ShowCursor(false); | 90 shell->cursor_manager()->ShowCursor(false); |
| 58 animator_->StartAnimation( | 91 animator_->StartAnimation( |
| 59 internal::SessionStateAnimator::kAllContainersMask, | 92 internal::SessionStateAnimator::kAllContainersMask, |
| 60 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | 93 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 61 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 94 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 62 } | 95 } |
| 63 } | 96 } |
| 64 | 97 |
| 65 void SessionStateControllerImpl2::OnLockStateChanged(bool locked) { | 98 void SessionStateControllerImpl2::OnLockStateChanged(bool locked) { |
| 66 if (shutting_down_ || (system_is_locked_ == locked)) | 99 if (shutting_down_ || (system_is_locked_ == locked)) |
| 67 return; | 100 return; |
| 68 | 101 |
| 69 system_is_locked_ = locked; | 102 system_is_locked_ = locked; |
| 70 | 103 |
| 71 if (locked) { | 104 if (locked) { |
| 72 base::Callback<void(void)> callback = | 105 StartLockAnimationPhaseTwo(); |
| 73 base::Bind(&SessionStateControllerImpl2::OnLockScreenAnimationFinished, | |
| 74 base::Unretained(this)); | |
| 75 animator_->StartAnimationWithCallback( | |
| 76 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | |
| 77 internal::SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, | |
| 78 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | |
| 79 callback); | |
| 80 lock_timer_.Stop(); | |
| 81 lock_fail_timer_.Stop(); | 106 lock_fail_timer_.Stop(); |
| 82 } else { | 107 } else { |
| 83 animator_->StartAnimation( | 108 StartUnlockAnimationPhaseTwo(); |
| 84 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | |
| 85 internal::SessionStateAnimator::LAUNCHER, | |
| 86 internal::SessionStateAnimator::ANIMATION_DROP, | |
| 87 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | |
| 88 } | 109 } |
| 89 } | 110 } |
| 90 | 111 |
| 91 void SessionStateControllerImpl2::SetLockScreenDisplayedCallback( | 112 void SessionStateControllerImpl2::SetLockScreenDisplayedCallback( |
| 92 base::Closure& callback) { | 113 base::Closure& callback) { |
| 93 lock_screen_displayed_callback_ = callback; | 114 lock_screen_displayed_callback_ = callback; |
| 94 } | 115 } |
| 95 | 116 |
| 96 void SessionStateControllerImpl2::OnLockScreenAnimationFinished() { | |
| 97 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | |
| 98 OnSessionStateEvent( | |
| 99 SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); | |
| 100 if (!lock_screen_displayed_callback_.is_null()) { | |
| 101 lock_screen_displayed_callback_.Run(); | |
| 102 lock_screen_displayed_callback_.Reset(); | |
| 103 } | |
| 104 if (shutdown_after_lock_) { | |
| 105 shutdown_after_lock_ = false; | |
| 106 StartLockToShutdownTimer(); | |
| 107 } | |
| 108 } | |
| 109 | |
| 110 void SessionStateControllerImpl2::OnStartingLock() { | 117 void SessionStateControllerImpl2::OnStartingLock() { |
| 111 if (shutting_down_ || system_is_locked_) | 118 if (shutting_down_ || system_is_locked_) |
| 112 return; | 119 return; |
| 113 | 120 if (animating_lock_) |
| 114 animator_->StartAnimation( | 121 return; |
| 115 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | 122 StartImmediateLockAnimationPhaseOne(); |
| 116 internal::SessionStateAnimator::LAUNCHER, | |
| 117 internal::SessionStateAnimator::ANIMATION_LIFT, | |
| 118 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | |
| 119 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | |
| 120 OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED)); | |
| 121 // Hide the screen locker containers so we can raise them later. | |
| 122 animator_->StartAnimation( | |
| 123 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | |
| 124 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, | |
| 125 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | |
| 126 } | 123 } |
| 127 | 124 |
| 128 void SessionStateControllerImpl2::StartLockAnimationAndLockImmediately() { | 125 void SessionStateControllerImpl2::StartLockAnimationAndLockImmediately() { |
| 129 animator_->StartAnimation( | 126 if (animating_lock_) |
| 130 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | 127 return; |
| 131 internal::SessionStateAnimator::LAUNCHER, | 128 StartImmediateLockAnimationPhaseOne(); |
| 132 internal::SessionStateAnimator::ANIMATION_LIFT, | |
| 133 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | |
| 134 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | |
| 135 OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED)); | |
| 136 OnLockTimeout(); | |
| 137 } | 129 } |
| 138 | 130 |
| 139 void SessionStateControllerImpl2::StartLockAnimation(bool shutdown_after_lock) { | 131 void SessionStateControllerImpl2::StartLockAnimation(bool shutdown_after_lock) { |
| 132 if (animating_lock_) |
| 133 return; |
| 140 shutdown_after_lock_ = shutdown_after_lock; | 134 shutdown_after_lock_ = shutdown_after_lock; |
| 135 undoable_lock_animation_ = true; |
| 141 | 136 |
| 142 animator_->StartAnimation( | 137 StartUndoableLockAnimationPhaseOne(); |
| 143 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | |
| 144 internal::SessionStateAnimator::LAUNCHER, | |
| 145 internal::SessionStateAnimator::ANIMATION_LIFT, | |
| 146 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | |
| 147 FOR_EACH_OBSERVER(SessionStateObserver, observers_, | |
| 148 OnSessionStateEvent( | |
| 149 SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); | |
| 150 StartLockTimer(); | |
| 151 } | |
| 152 | |
| 153 void SessionStateControllerImpl2::StartShutdownAnimation() { | |
| 154 animator_->StartGlobalAnimation( | |
| 155 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | |
| 156 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | |
| 157 StartPreShutdownAnimationTimer(); | |
| 158 } | 138 } |
| 159 | 139 |
| 160 bool SessionStateControllerImpl2::LockRequested() { | 140 bool SessionStateControllerImpl2::LockRequested() { |
| 161 return lock_fail_timer_.IsRunning(); | 141 return lock_fail_timer_.IsRunning(); |
| 162 } | 142 } |
| 163 | 143 |
| 164 bool SessionStateControllerImpl2::ShutdownRequested() { | 144 bool SessionStateControllerImpl2::ShutdownRequested() { |
| 165 return shutting_down_; | 145 return shutting_down_; |
| 166 } | 146 } |
| 167 | 147 |
| 168 bool SessionStateControllerImpl2::CanCancelLockAnimation() { | 148 bool SessionStateControllerImpl2::CanCancelLockAnimation() { |
| 169 return lock_timer_.IsRunning(); | 149 return undoable_lock_animation_; |
| 170 } | 150 } |
| 171 | 151 |
| 172 void SessionStateControllerImpl2::CancelLockAnimation() { | 152 void SessionStateControllerImpl2::CancelLockAnimation() { |
| 173 if (!CanCancelLockAnimation()) | 153 if (!CanCancelLockAnimation()) |
| 174 return; | 154 return; |
| 175 shutdown_after_lock_ = false; | 155 shutdown_after_lock_ = false; |
| 176 animator_->StartAnimation( | 156 animating_lock_ = false; |
| 177 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS | | 157 UndoLockAnimationPhaseOne(); |
| 178 internal::SessionStateAnimator::LAUNCHER, | |
| 179 internal::SessionStateAnimator::ANIMATION_DROP, | |
| 180 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | |
| 181 lock_timer_.Stop(); | |
| 182 } | 158 } |
| 183 | 159 |
| 184 bool SessionStateControllerImpl2::CanCancelShutdownAnimation() { | 160 bool SessionStateControllerImpl2::CanCancelShutdownAnimation() { |
| 185 return pre_shutdown_timer_.IsRunning() || | 161 return pre_shutdown_timer_.IsRunning() || |
| 186 shutdown_after_lock_ || | 162 shutdown_after_lock_ || |
| 187 lock_to_shutdown_timer_.IsRunning(); | 163 lock_to_shutdown_timer_.IsRunning(); |
| 188 } | 164 } |
| 189 | 165 |
| 166 void SessionStateControllerImpl2::StartShutdownAnimation() { |
| 167 animator_->StartGlobalAnimation( |
| 168 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 169 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 170 StartPreShutdownAnimationTimer(); |
| 171 } |
| 172 |
| 190 void SessionStateControllerImpl2::CancelShutdownAnimation() { | 173 void SessionStateControllerImpl2::CancelShutdownAnimation() { |
| 191 if (!CanCancelShutdownAnimation()) | 174 if (!CanCancelShutdownAnimation()) |
| 192 return; | 175 return; |
| 193 if (lock_to_shutdown_timer_.IsRunning()) { | 176 if (lock_to_shutdown_timer_.IsRunning()) { |
| 194 lock_to_shutdown_timer_.Stop(); | 177 lock_to_shutdown_timer_.Stop(); |
| 195 return; | 178 return; |
| 196 } | 179 } |
| 197 if (shutdown_after_lock_) { | 180 if (shutdown_after_lock_) { |
| 198 shutdown_after_lock_ = false; | 181 shutdown_after_lock_ = false; |
| 199 return; | 182 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 213 DCHECK(!shutting_down_); | 196 DCHECK(!shutting_down_); |
| 214 shutting_down_ = true; | 197 shutting_down_ = true; |
| 215 | 198 |
| 216 Shell* shell = ash::Shell::GetInstance(); | 199 Shell* shell = ash::Shell::GetInstance(); |
| 217 shell->env_filter()->set_cursor_hidden_by_filter(false); | 200 shell->env_filter()->set_cursor_hidden_by_filter(false); |
| 218 shell->cursor_manager()->ShowCursor(false); | 201 shell->cursor_manager()->ShowCursor(false); |
| 219 | 202 |
| 220 animator_->StartGlobalAnimation( | 203 animator_->StartGlobalAnimation( |
| 221 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, | 204 internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS, |
| 222 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 205 internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 206 |
| 223 StartRealShutdownTimer(); | 207 StartRealShutdownTimer(); |
| 224 } | 208 } |
| 225 | 209 |
| 226 void SessionStateControllerImpl2::OnRootWindowHostCloseRequested( | 210 void SessionStateControllerImpl2::OnRootWindowHostCloseRequested( |
| 227 const aura::RootWindow*) { | 211 const aura::RootWindow*) { |
| 228 Shell::GetInstance()->delegate()->Exit(); | 212 Shell::GetInstance()->delegate()->Exit(); |
| 229 } | 213 } |
| 230 | 214 |
| 231 void SessionStateControllerImpl2::StartLockTimer() { | |
| 232 lock_timer_.Stop(); | |
| 233 lock_timer_.Start( | |
| 234 FROM_HERE, | |
| 235 animator_->GetDuration( | |
| 236 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE), | |
| 237 this, &SessionStateControllerImpl2::OnLockTimeout); | |
| 238 } | |
| 239 | |
| 240 void SessionStateControllerImpl2::OnLockTimeout() { | |
| 241 delegate_->RequestLockScreen(); | |
| 242 lock_fail_timer_.Start( | |
| 243 FROM_HERE, | |
| 244 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), | |
| 245 this, &SessionStateControllerImpl2::OnLockFailTimeout); | |
| 246 } | |
| 247 | |
| 248 void SessionStateControllerImpl2::OnLockFailTimeout() { | 215 void SessionStateControllerImpl2::OnLockFailTimeout() { |
| 249 DCHECK(!system_is_locked_); | 216 DCHECK(!system_is_locked_); |
| 250 // Undo lock animation. | 217 // Undo lock animation. |
| 251 animator_->StartAnimation( | 218 StartUnlockAnimationPhaseTwo(); |
| 252 internal::SessionStateAnimator::LAUNCHER | | |
| 253 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | |
| 254 internal::SessionStateAnimator::ANIMATION_DROP, | |
| 255 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | |
| 256 } | 219 } |
| 257 | 220 |
| 258 void SessionStateControllerImpl2::StartLockToShutdownTimer() { | 221 void SessionStateControllerImpl2::StartLockToShutdownTimer() { |
| 259 shutdown_after_lock_ = false; | 222 shutdown_after_lock_ = false; |
| 260 lock_to_shutdown_timer_.Stop(); | 223 lock_to_shutdown_timer_.Stop(); |
| 261 lock_to_shutdown_timer_.Start( | 224 lock_to_shutdown_timer_.Start( |
| 262 FROM_HERE, | 225 FROM_HERE, |
| 263 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), | 226 base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs), |
| 264 this, &SessionStateControllerImpl2::OnLockToShutdownTimeout); | 227 this, &SessionStateControllerImpl2::OnLockToShutdownTimeout); |
| 265 } | 228 } |
| 266 | 229 |
| 267 | |
| 268 void SessionStateControllerImpl2::OnLockToShutdownTimeout() { | 230 void SessionStateControllerImpl2::OnLockToShutdownTimeout() { |
| 269 DCHECK(system_is_locked_); | 231 DCHECK(system_is_locked_); |
| 270 StartShutdownAnimation(); | 232 StartShutdownAnimation(); |
| 271 } | 233 } |
| 272 | 234 |
| 273 void SessionStateControllerImpl2::StartPreShutdownAnimationTimer() { | 235 void SessionStateControllerImpl2::StartPreShutdownAnimationTimer() { |
| 274 pre_shutdown_timer_.Stop(); | 236 pre_shutdown_timer_.Stop(); |
| 275 pre_shutdown_timer_.Start( | 237 pre_shutdown_timer_.Start( |
| 276 FROM_HERE, | 238 FROM_HERE, |
| 277 base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs), | 239 base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 303 delegate->Exit(); | 265 delegate->Exit(); |
| 304 return; | 266 return; |
| 305 } | 267 } |
| 306 } | 268 } |
| 307 #endif | 269 #endif |
| 308 delegate_->RequestShutdown(); | 270 delegate_->RequestShutdown(); |
| 309 } | 271 } |
| 310 | 272 |
| 311 void SessionStateControllerImpl2::OnLockScreenHide( | 273 void SessionStateControllerImpl2::OnLockScreenHide( |
| 312 base::Callback<void(void)>& callback) { | 274 base::Callback<void(void)>& callback) { |
| 275 StartUnlockAnimationPhaseOne(callback); |
| 276 } |
| 277 |
| 278 void SessionStateControllerImpl2::LockAnimationUndone() { |
| 279 undoable_lock_animation_ = false; |
| 280 RestoreUnlockedProperties(); |
| 281 } |
| 282 |
| 283 void SessionStateControllerImpl2::LockAnimationPhaseOneCompleted() { |
| 284 undoable_lock_animation_ = false; |
| 285 |
| 286 delegate_->RequestLockScreen(); |
| 287 lock_fail_timer_.Start( |
| 288 FROM_HERE, |
| 289 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs), |
| 290 this, &SessionStateControllerImpl2::OnLockFailTimeout); |
| 291 } |
| 292 |
| 293 void SessionStateControllerImpl2::LockAnimationPhaseTwoCompleted() { |
| 294 animating_lock_ = false; |
| 295 |
| 296 FOR_EACH_OBSERVER(SessionStateObserver, observers_, |
| 297 OnSessionStateEvent( |
| 298 SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED)); |
| 299 if (!lock_screen_displayed_callback_.is_null()) { |
| 300 lock_screen_displayed_callback_.Run(); |
| 301 lock_screen_displayed_callback_.Reset(); |
| 302 } |
| 303 if (shutdown_after_lock_) { |
| 304 shutdown_after_lock_ = false; |
| 305 StartLockToShutdownTimer(); |
| 306 } |
| 307 } |
| 308 |
| 309 void SessionStateControllerImpl2::UnlockAnimationPhaseTwoCompleted() { |
| 310 RestoreUnlockedProperties(); |
| 311 } |
| 312 |
| 313 void SessionStateControllerImpl2::StartImmediateLockAnimationPhaseOne() { |
| 314 animating_lock_ = true; |
| 315 |
| 316 StoreUnlockedProperties(); |
| 317 |
| 318 base::Closure next_animation_starter = |
| 319 base::Bind(&SessionStateControllerImpl2::LockAnimationPhaseOneCompleted, |
| 320 base::Unretained(this)); |
| 321 ui::LayerAnimationObserver* observer = |
| 322 new ui::AnimationFinishedObserver(next_animation_starter); |
| 323 |
| 324 animator_->StartAnimationWithObserver( |
| 325 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 326 internal::SessionStateAnimator::ANIMATION_LIFT, |
| 327 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 328 observer); |
| 329 |
| 330 animator_->StartAnimationWithObserver( |
| 331 internal::SessionStateAnimator::LAUNCHER, |
| 332 internal::SessionStateAnimator::ANIMATION_FADE_OUT, |
| 333 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 334 observer); |
| 335 |
| 336 // Hide the screen locker containers so we can raise them later. |
| 337 animator_->StartAnimation( |
| 338 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 339 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 340 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 341 |
| 342 AnimateBackgroundAppearanceIfNecessary( |
| 343 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 344 observer); |
| 345 |
| 346 FOR_EACH_OBSERVER(SessionStateObserver, observers_, |
| 347 OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED)); |
| 348 } |
| 349 |
| 350 void SessionStateControllerImpl2::StartUndoableLockAnimationPhaseOne() { |
| 351 animating_lock_ = true; |
| 352 StoreUnlockedProperties(); |
| 353 |
| 354 base::Closure next_animation_starter = |
| 355 base::Bind(&SessionStateControllerImpl2::LockAnimationPhaseOneCompleted, |
| 356 base::Unretained(this)); |
| 357 ui::LayerAnimationObserver* observer = |
| 358 new ui::AnimationFinishedObserver(next_animation_starter); |
| 359 |
| 360 animator_->StartAnimationWithObserver( |
| 361 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 362 internal::SessionStateAnimator::ANIMATION_LIFT, |
| 363 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 364 observer); |
| 365 |
| 366 animator_->StartAnimationWithObserver( |
| 367 internal::SessionStateAnimator::LAUNCHER, |
| 368 internal::SessionStateAnimator::ANIMATION_FADE_OUT, |
| 369 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 370 observer); |
| 371 |
| 372 // Hide the screen locker containers so we can raise them later. |
| 373 animator_->StartAnimation( |
| 374 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 375 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 376 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 377 |
| 378 AnimateBackgroundAppearanceIfNecessary( |
| 379 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 380 observer); |
| 381 |
| 382 FOR_EACH_OBSERVER(SessionStateObserver, observers_, |
| 383 OnSessionStateEvent( |
| 384 SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED)); |
| 385 } |
| 386 |
| 387 void SessionStateControllerImpl2::UndoLockAnimationPhaseOne() { |
| 388 base::Closure next_animation_starter = |
| 389 base::Bind(&SessionStateControllerImpl2::LockAnimationUndone, |
| 390 base::Unretained(this)); |
| 391 ui::AnimationFinishedObserver* observer = |
| 392 new ui::AnimationFinishedObserver(next_animation_starter); |
| 393 |
| 394 observer->Pause(); |
| 395 |
| 396 animator_->StartAnimationWithObserver( |
| 397 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 398 internal::SessionStateAnimator::ANIMATION_DROP, |
| 399 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 400 observer); |
| 401 |
| 402 animator_->StartAnimationWithObserver( |
| 403 internal::SessionStateAnimator::LAUNCHER, |
| 404 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 405 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 406 observer); |
| 407 |
| 408 AnimateBackgroundHidingIfNecessary( |
| 409 internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, |
| 410 observer); |
| 411 |
| 412 observer->Unpause(); |
| 413 } |
| 414 |
| 415 void SessionStateControllerImpl2::StartLockAnimationPhaseTwo() { |
| 416 base::Closure next_animation_starter = |
| 417 base::Bind(&SessionStateControllerImpl2::LockAnimationPhaseTwoCompleted, |
| 418 base::Unretained(this)); |
| 419 |
| 420 ui::LayerAnimationObserver* observer = |
| 421 new ui::AnimationFinishedObserver(next_animation_starter); |
| 422 |
| 423 animator_->StartAnimationWithObserver( |
| 424 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 425 internal::SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN, |
| 426 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 427 observer); |
| 428 } |
| 429 |
| 430 void SessionStateControllerImpl2::StartUnlockAnimationPhaseOne( |
| 431 base::Closure& callback) { |
| 313 animator_->StartAnimationWithCallback( | 432 animator_->StartAnimationWithCallback( |
| 314 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 433 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 315 internal::SessionStateAnimator::ANIMATION_LIFT, | 434 internal::SessionStateAnimator::ANIMATION_LIFT, |
| 316 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, | 435 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 317 callback); | 436 callback); |
| 318 } | 437 } |
| 319 | 438 |
| 439 void SessionStateControllerImpl2::StartUnlockAnimationPhaseTwo() { |
| 440 base::Closure next_animation_starter = |
| 441 base::Bind(&SessionStateControllerImpl2::UnlockAnimationPhaseTwoCompleted, |
| 442 base::Unretained(this)); |
| 443 |
| 444 ui::LayerAnimationObserver* observer = |
| 445 new ui::AnimationFinishedObserver(next_animation_starter); |
| 446 |
| 447 animator_->StartAnimationWithObserver( |
| 448 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 449 internal::SessionStateAnimator::ANIMATION_DROP, |
| 450 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 451 observer); |
| 452 |
| 453 animator_->StartAnimationWithObserver( |
| 454 internal::SessionStateAnimator::LAUNCHER, |
| 455 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 456 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 457 observer); |
| 458 |
| 459 AnimateBackgroundHidingIfNecessary( |
| 460 internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, |
| 461 observer); |
| 462 } |
| 463 |
| 464 void SessionStateControllerImpl2::StoreUnlockedProperties() { |
| 465 if (!unlocked_properties_.get()) { |
| 466 unlocked_properties_.reset(new UnlockedStateProperties()); |
| 467 unlocked_properties_->background_is_hidden = IsBackgroundHidden(); |
| 468 } |
| 469 if (unlocked_properties_->background_is_hidden) { |
| 470 // Hide background so that it can be animated later. |
| 471 animator_->StartAnimation( |
| 472 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 473 internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, |
| 474 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 475 ShowBackground(); |
| 476 } |
| 477 } |
| 478 |
| 479 void SessionStateControllerImpl2::RestoreUnlockedProperties() { |
| 480 if (!unlocked_properties_.get()) |
| 481 return; |
| 482 if (unlocked_properties_->background_is_hidden) { |
| 483 HideBackground(); |
| 484 // Restore background visibility. |
| 485 animator_->StartAnimation( |
| 486 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 487 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 488 internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 489 } |
| 490 unlocked_properties_.reset(); |
| 491 } |
| 492 |
| 493 void SessionStateControllerImpl2::AnimateBackgroundAppearanceIfNecessary( |
| 494 internal::SessionStateAnimator::AnimationSpeed speed, |
| 495 ui::LayerAnimationObserver* observer) { |
| 496 if (unlocked_properties_.get() && |
| 497 unlocked_properties_->background_is_hidden) { |
| 498 animator_->StartAnimationWithObserver( |
| 499 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 500 internal::SessionStateAnimator::ANIMATION_FADE_IN, |
| 501 speed, |
| 502 observer); |
| 503 } |
| 504 } |
| 505 |
| 506 void SessionStateControllerImpl2::AnimateBackgroundHidingIfNecessary( |
| 507 internal::SessionStateAnimator::AnimationSpeed speed, |
| 508 ui::LayerAnimationObserver* observer) { |
| 509 if (unlocked_properties_.get() && |
| 510 unlocked_properties_->background_is_hidden) { |
| 511 animator_->StartAnimationWithObserver( |
| 512 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
| 513 internal::SessionStateAnimator::ANIMATION_FADE_OUT, |
| 514 speed, |
| 515 observer); |
| 516 } |
| 517 } |
| 518 |
| 320 } // namespace ash | 519 } // namespace ash |
| OLD | NEW |