Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1689)

Side by Side Diff: ash/wm/lock_state_controller.cc

Issue 2166043003: mash: Migrate ShelfLockingManager to ash/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move ShelfLockingManager test access to Shelf. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 LockStateController::~LockStateController() { 91 LockStateController::~LockStateController() {
92 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this); 92 Shell::GetPrimaryRootWindow()->GetHost()->RemoveObserver(this);
93 } 93 }
94 94
95 void LockStateController::SetDelegate( 95 void LockStateController::SetDelegate(
96 std::unique_ptr<LockStateControllerDelegate> delegate) { 96 std::unique_ptr<LockStateControllerDelegate> delegate) {
97 delegate_ = std::move(delegate); 97 delegate_ = std::move(delegate);
98 } 98 }
99 99
100 void LockStateController::AddObserver(LockStateObserver* observer) {
101 observers_.AddObserver(observer);
102 }
103
104 void LockStateController::RemoveObserver(LockStateObserver* observer) {
105 observers_.RemoveObserver(observer);
106 }
107
108 bool LockStateController::HasObserver(const LockStateObserver* observer) const {
109 return observers_.HasObserver(observer);
110 }
111
112 void LockStateController::StartLockAnimation(bool shutdown_after_lock) { 100 void LockStateController::StartLockAnimation(bool shutdown_after_lock) {
113 if (animating_lock_) 101 if (animating_lock_)
114 return; 102 return;
115 shutdown_after_lock_ = shutdown_after_lock; 103 shutdown_after_lock_ = shutdown_after_lock;
116 can_cancel_lock_animation_ = true; 104 can_cancel_lock_animation_ = true;
117 105
118 StartCancellablePreLockAnimation(); 106 StartCancellablePreLockAnimation();
119 } 107 }
120 108
121 void LockStateController::StartShutdownAnimation() { 109 void LockStateController::StartShutdownAnimation() {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Hide the screen locker containers so we can raise them later. 363 // Hide the screen locker containers so we can raise them later.
376 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, 364 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
377 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, 365 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
378 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 366 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
379 AnimateBackgroundAppearanceIfNecessary( 367 AnimateBackgroundAppearanceIfNecessary(
380 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence); 368 SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, animation_sequence);
381 369
382 animation_sequence->EndSequence(); 370 animation_sequence->EndSequence();
383 371
384 DispatchCancelMode(); 372 DispatchCancelMode();
385 FOR_EACH_OBSERVER( 373 WmShell::Get()->OnLockStateEvent(
386 LockStateObserver, observers_, 374 LockStateObserver::EVENT_LOCK_ANIMATION_STARTED);
387 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_STARTED));
388 } 375 }
389 376
390 void LockStateController::StartCancellablePreLockAnimation() { 377 void LockStateController::StartCancellablePreLockAnimation() {
391 animating_lock_ = true; 378 animating_lock_ = true;
392 StoreUnlockedProperties(); 379 StoreUnlockedProperties();
393 VLOG(1) << "StartCancellablePreLockAnimation"; 380 VLOG(1) << "StartCancellablePreLockAnimation";
394 base::Closure next_animation_starter = 381 base::Closure next_animation_starter =
395 base::Bind(&LockStateController::PreLockAnimationFinished, 382 base::Bind(&LockStateController::PreLockAnimationFinished,
396 weak_ptr_factory_.GetWeakPtr(), true /* request_lock */); 383 weak_ptr_factory_.GetWeakPtr(), true /* request_lock */);
397 SessionStateAnimator::AnimationSequence* animation_sequence = 384 SessionStateAnimator::AnimationSequence* animation_sequence =
398 animator_->BeginAnimationSequence(next_animation_starter); 385 animator_->BeginAnimationSequence(next_animation_starter);
399 386
400 animation_sequence->StartAnimation( 387 animation_sequence->StartAnimation(
401 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, 388 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
402 SessionStateAnimator::ANIMATION_LIFT, 389 SessionStateAnimator::ANIMATION_LIFT,
403 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 390 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
404 animation_sequence->StartAnimation( 391 animation_sequence->StartAnimation(
405 SessionStateAnimator::LAUNCHER, SessionStateAnimator::ANIMATION_FADE_OUT, 392 SessionStateAnimator::LAUNCHER, SessionStateAnimator::ANIMATION_FADE_OUT,
406 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); 393 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
407 // Hide the screen locker containers so we can raise them later. 394 // Hide the screen locker containers so we can raise them later.
408 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS, 395 animator_->StartAnimation(SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
409 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, 396 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
410 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); 397 SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
411 AnimateBackgroundAppearanceIfNecessary( 398 AnimateBackgroundAppearanceIfNecessary(
412 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence); 399 SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, animation_sequence);
413 400
414 DispatchCancelMode(); 401 DispatchCancelMode();
415 FOR_EACH_OBSERVER( 402 WmShell::Get()->OnLockStateEvent(
416 LockStateObserver, observers_, 403 LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED);
417 OnLockStateEvent(LockStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
418 animation_sequence->EndSequence(); 404 animation_sequence->EndSequence();
419 } 405 }
420 406
421 void LockStateController::CancelPreLockAnimation() { 407 void LockStateController::CancelPreLockAnimation() {
422 VLOG(1) << "CancelPreLockAnimation"; 408 VLOG(1) << "CancelPreLockAnimation";
423 base::Closure next_animation_starter = 409 base::Closure next_animation_starter =
424 base::Bind(&LockStateController::LockAnimationCancelled, 410 base::Bind(&LockStateController::LockAnimationCancelled,
425 weak_ptr_factory_.GetWeakPtr()); 411 weak_ptr_factory_.GetWeakPtr());
426 SessionStateAnimator::AnimationSequence* animation_sequence = 412 SessionStateAnimator::AnimationSequence* animation_sequence =
427 animator_->BeginAnimationSequence(next_animation_starter); 413 animator_->BeginAnimationSequence(next_animation_starter);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 #endif 512 #endif
527 lock_fail_timer_.Start(FROM_HERE, timeout, this, 513 lock_fail_timer_.Start(FROM_HERE, timeout, this,
528 &LockStateController::OnLockFailTimeout); 514 &LockStateController::OnLockFailTimeout);
529 515
530 lock_duration_timer_.reset(new base::ElapsedTimer()); 516 lock_duration_timer_.reset(new base::ElapsedTimer());
531 } 517 }
532 518
533 void LockStateController::PostLockAnimationFinished() { 519 void LockStateController::PostLockAnimationFinished() {
534 animating_lock_ = false; 520 animating_lock_ = false;
535 VLOG(1) << "PostLockAnimationFinished"; 521 VLOG(1) << "PostLockAnimationFinished";
536 FOR_EACH_OBSERVER( 522 WmShell::Get()->OnLockStateEvent(
537 LockStateObserver, observers_, 523 LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED);
538 OnLockStateEvent(LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED));
539 if (!lock_screen_displayed_callback_.is_null()) { 524 if (!lock_screen_displayed_callback_.is_null()) {
540 lock_screen_displayed_callback_.Run(); 525 lock_screen_displayed_callback_.Run();
541 lock_screen_displayed_callback_.Reset(); 526 lock_screen_displayed_callback_.Reset();
542 } 527 }
543 CHECK(!views::MenuController::GetActiveInstance()); 528 CHECK(!views::MenuController::GetActiveInstance());
544 if (shutdown_after_lock_) { 529 if (shutdown_after_lock_) {
545 shutdown_after_lock_ = false; 530 shutdown_after_lock_ = false;
546 StartLockToShutdownTimer(); 531 StartLockToShutdownTimer();
547 } 532 }
548 } 533 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 SessionStateAnimator::AnimationSequence* animation_sequence) { 580 SessionStateAnimator::AnimationSequence* animation_sequence) {
596 if (unlocked_properties_.get() && 581 if (unlocked_properties_.get() &&
597 unlocked_properties_->background_is_hidden) { 582 unlocked_properties_->background_is_hidden) {
598 animation_sequence->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND, 583 animation_sequence->StartAnimation(SessionStateAnimator::DESKTOP_BACKGROUND,
599 SessionStateAnimator::ANIMATION_FADE_OUT, 584 SessionStateAnimator::ANIMATION_FADE_OUT,
600 speed); 585 speed);
601 } 586 }
602 } 587 }
603 588
604 } // namespace ash 589 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698