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