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

Unified Diff: ash/wm/session_state_controller_impl2.cc

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: And another one change for build on Win Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/session_state_controller_impl2.cc
diff --git a/ash/wm/session_state_controller_impl2.cc b/ash/wm/session_state_controller_impl2.cc
index 8b19827738b8c4faf5ba24b2ec5be5497c1c128f..f41ae8131ff76b5fecd2eed44c5012b271c5f77e 100644
--- a/ash/wm/session_state_controller_impl2.cc
+++ b/ash/wm/session_state_controller_impl2.cc
@@ -11,7 +11,10 @@
#include "ash/wm/session_state_animator.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
+#include "base/timer.h"
#include "ui/aura/root_window.h"
+#include "ui/compositor/layer_animation_sequence.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/views/corewm/compound_event_filter.h"
#if defined(OS_CHROMEOS)
@@ -20,6 +23,114 @@
namespace ash {
+namespace {
+
+aura::Window* GetBackground() {
+ aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
+ return Shell::GetContainer(root_window,
+ internal::kShellWindowId_DesktopBackgroundContainer);
+}
+
+bool IsBackgroundHidden() {
+ return !GetBackground()->IsVisible();
+}
+
+void ShowBackground() {
+ ui::ScopedLayerAnimationSettings settings(
+ GetBackground()->layer()->GetAnimator());
+ settings.SetTransitionDuration(base::TimeDelta());
+ GetBackground()->Show();
+}
+
+void HideBackground() {
+ ui::ScopedLayerAnimationSettings settings(
+ GetBackground()->layer()->GetAnimator());
+ settings.SetTransitionDuration(base::TimeDelta());
+ GetBackground()->Hide();
+}
+
+// This observer is intended to use in cases when some action have to be taken
+// once some animation successfully completes (i.e. it was not aborted).
+// Observer will count a number of sequences it is attached to, and a number of
+// finished sequences (either Ended or Aborted). Once these two numbers are
+// equal, observer will delete itself, calling callback passed to constructor if
+// there was no aborted animations.
+// This way it can be either used to wait for some animation to be finished in
+// multiple layers, to wait once a sequence of animations is finished in one
+// layer or the mixture of both.
+class AnimationFinishedObserver : public ui::LayerAnimationObserver {
+ public:
+ explicit AnimationFinishedObserver(base::Closure &callback)
+ : callback_(callback),
+ sequences_attached_(0),
+ sequences_completed_(0),
+ paused_(false) {
+ }
+
+ virtual ~AnimationFinishedObserver() {
+ }
sky 2012/12/12 20:35:56 Can you make this private so it's clear AnimationF
Denis Kuznetsov (DE-MUC) 2012/12/13 17:59:50 Done.
+
+ // Pauses observer: no checks will be made while paused. It can be used when
+ // sequence have some immediate animations in the beginning.
+ void Pause() {
+ paused_ = true;
+ }
+
+ // Unpauses observer. It does a check ant calls callback if conditions are
sky 2012/12/12 20:35:56 ant -> and
Denis Kuznetsov (DE-MUC) 2012/12/13 17:59:50 Done.
+ // met.
+ void Unpause() {
+ if (!paused_)
+ return;
+ paused_ = false;
+ if (sequences_completed_ == sequences_attached_) {
+ callback_.Run();
+ delete this;
+ }
+ }
+
+ private:
+ // LayerAnimationObserver implementation
+ virtual void OnLayerAnimationEnded(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {
+ sequences_completed_++;
+ if ((sequences_completed_ == sequences_attached_) && !paused_) {
+ callback_.Run();
+ delete this;
+ }
+ }
+
+ virtual void OnLayerAnimationAborted(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {
+ sequences_completed_++;
+ if ((sequences_completed_ == sequences_attached_) && !paused_)
+ delete this;
+ }
+
+ virtual void OnLayerAnimationScheduled(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {
+ };
sky 2012/12/12 20:35:56 remove ;
Denis Kuznetsov (DE-MUC) 2012/12/13 17:59:50 Done.
+
+ virtual void OnAttachedToSequence(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {
+ LayerAnimationObserver::OnAttachedToSequence(sequence);
+ sequences_attached_++;
+ }
+ // Callback to be called.
sky 2012/12/12 20:35:56 nit: newline between 117/118.
Denis Kuznetsov (DE-MUC) 2012/12/13 17:59:50 Done.
+ base::Closure callback_;
+
+ // Number of sequences this observer was attached to.
+ int sequences_attached_;
+
+ // Number of sequences either ended or aborted.
+ int sequences_completed_;
+
+ bool paused_;
+
+ DISALLOW_COPY_AND_ASSIGN(AnimationFinishedObserver);
+};
+
+} // namespace
+
SessionStateControllerImpl2::TestApi::TestApi(
SessionStateControllerImpl2* controller)
: controller_(controller) {
@@ -32,7 +143,9 @@ SessionStateControllerImpl2::SessionStateControllerImpl2()
: login_status_(user::LOGGED_IN_NONE),
system_is_locked_(false),
shutting_down_(false),
- shutdown_after_lock_(false) {
+ shutdown_after_lock_(false),
+ animating_lock_(false),
+ undoable_lock_animation_(false) {
Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this);
}
@@ -50,6 +163,7 @@ void SessionStateControllerImpl2::OnLoginStateChanged(
void SessionStateControllerImpl2::OnAppTerminating() {
// If we hear that Chrome is exiting but didn't request it ourselves, all we
// can really hope for is that we'll have time to clear the screen.
+ // This is also a case when user signs off.
if (!shutting_down_) {
shutting_down_ = true;
Shell* shell = ash::Shell::GetInstance();
@@ -69,22 +183,10 @@ void SessionStateControllerImpl2::OnLockStateChanged(bool locked) {
system_is_locked_ = locked;
if (locked) {
- base::Callback<void(void)> callback =
- base::Bind(&SessionStateControllerImpl2::OnLockScreenAnimationFinished,
- base::Unretained(this));
- animator_->StartAnimationWithCallback(
- internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN,
- internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
- callback);
- lock_timer_.Stop();
+ StartLockAnimationPhaseTwo();
lock_fail_timer_.Stop();
} else {
- animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_DROP,
- internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
+ StartUnlockAnimationPhaseTwo();
}
}
@@ -93,68 +195,27 @@ void SessionStateControllerImpl2::SetLockScreenDisplayedCallback(
lock_screen_displayed_callback_ = callback;
}
-void SessionStateControllerImpl2::OnLockScreenAnimationFinished() {
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(
- SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED));
- if (!lock_screen_displayed_callback_.is_null()) {
- lock_screen_displayed_callback_.Run();
- lock_screen_displayed_callback_.Reset();
- }
- if (shutdown_after_lock_) {
- shutdown_after_lock_ = false;
- StartLockToShutdownTimer();
- }
-}
-
void SessionStateControllerImpl2::OnStartingLock() {
if (shutting_down_ || system_is_locked_)
return;
-
- animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_LIFT,
- internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
- // Hide the screen locker containers so we can raise them later.
- animator_->StartAnimation(
- internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
- internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
+ if (animating_lock_)
+ return;
+ StartImmediateLockAnimationPhaseOne();
}
void SessionStateControllerImpl2::StartLockAnimationAndLockImmediately() {
- animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_LIFT,
- internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
- OnLockTimeout();
+ if (animating_lock_)
+ return;
+ StartImmediateLockAnimationPhaseOne();
}
void SessionStateControllerImpl2::StartLockAnimation(bool shutdown_after_lock) {
+ if (animating_lock_)
+ return;
shutdown_after_lock_ = shutdown_after_lock;
+ undoable_lock_animation_ = true;
- animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_LIFT,
- internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE);
- FOR_EACH_OBSERVER(SessionStateObserver, observers_,
- OnSessionStateEvent(
- SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
- StartLockTimer();
-}
-
-void SessionStateControllerImpl2::StartShutdownAnimation() {
- animator_->StartGlobalAnimation(
- internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
- internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
- StartPreShutdownAnimationTimer();
+ StartUndoableLockAnimationPhaseOne();
}
bool SessionStateControllerImpl2::LockRequested() {
@@ -166,19 +227,15 @@ bool SessionStateControllerImpl2::ShutdownRequested() {
}
bool SessionStateControllerImpl2::CanCancelLockAnimation() {
- return lock_timer_.IsRunning();
+ return undoable_lock_animation_;
}
void SessionStateControllerImpl2::CancelLockAnimation() {
if (!CanCancelLockAnimation())
return;
shutdown_after_lock_ = false;
- animator_->StartAnimation(
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS |
- internal::SessionStateAnimator::LAUNCHER,
- internal::SessionStateAnimator::ANIMATION_DROP,
- internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
- lock_timer_.Stop();
+ animating_lock_ = false;
+ UndoLockAnimationPhaseOne();
}
bool SessionStateControllerImpl2::CanCancelShutdownAnimation() {
@@ -187,6 +244,10 @@ bool SessionStateControllerImpl2::CanCancelShutdownAnimation() {
lock_to_shutdown_timer_.IsRunning();
}
+void SessionStateControllerImpl2::StartShutdownAnimation() {
+ StartCancellableShutdownAnimation();
+}
+
void SessionStateControllerImpl2::CancelShutdownAnimation() {
if (!CanCancelShutdownAnimation())
return;
@@ -217,10 +278,7 @@ void SessionStateControllerImpl2::RequestShutdownImpl() {
shell->env_filter()->set_cursor_hidden_by_filter(false);
shell->cursor_manager()->ShowCursor(false);
- animator_->StartGlobalAnimation(
- internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
- internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
- StartRealShutdownTimer();
+ StartShutdownAnimationImpl();
}
void SessionStateControllerImpl2::OnRootWindowHostCloseRequested(
@@ -228,31 +286,10 @@ void SessionStateControllerImpl2::OnRootWindowHostCloseRequested(
Shell::GetInstance()->delegate()->Exit();
}
-void SessionStateControllerImpl2::StartLockTimer() {
- lock_timer_.Stop();
- lock_timer_.Start(
- FROM_HERE,
- animator_->GetDuration(
- internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE),
- this, &SessionStateControllerImpl2::OnLockTimeout);
-}
-
-void SessionStateControllerImpl2::OnLockTimeout() {
- delegate_->RequestLockScreen();
- lock_fail_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs),
- this, &SessionStateControllerImpl2::OnLockFailTimeout);
-}
-
void SessionStateControllerImpl2::OnLockFailTimeout() {
DCHECK(!system_is_locked_);
// Undo lock animation.
- animator_->StartAnimation(
- internal::SessionStateAnimator::LAUNCHER |
- internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
- internal::SessionStateAnimator::ANIMATION_DROP,
- internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
+ StartUnlockAnimationPhaseTwo();
}
void SessionStateControllerImpl2::StartLockToShutdownTimer() {
@@ -264,30 +301,52 @@ void SessionStateControllerImpl2::StartLockToShutdownTimer() {
this, &SessionStateControllerImpl2::OnLockToShutdownTimeout);
}
-
void SessionStateControllerImpl2::OnLockToShutdownTimeout() {
DCHECK(system_is_locked_);
- StartShutdownAnimation();
+ StartCancellableShutdownAnimation();
+}
+
+void SessionStateControllerImpl2::StartCancellableShutdownAnimation() {
+ animator_->StartGlobalAnimation(
+ internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
+ internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
+ StartPreShutdownAnimationTimer();
+}
+
+void SessionStateControllerImpl2::StartShutdownAnimationImpl() {
+ animator_->StartGlobalAnimation(
+ internal::SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS,
+ internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
+ StartRealShutdownTimer(true);
}
void SessionStateControllerImpl2::StartPreShutdownAnimationTimer() {
pre_shutdown_timer_.Stop();
pre_shutdown_timer_.Start(
FROM_HERE,
- base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs),
+ animator_->
+ GetDuration(internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN),
this, &SessionStateControllerImpl2::OnPreShutdownAnimationTimeout);
}
void SessionStateControllerImpl2::OnPreShutdownAnimationTimeout() {
- if (!shutting_down_)
- RequestShutdownImpl();
+ shutting_down_ = true;
+
+ Shell* shell = ash::Shell::GetInstance();
+ shell->env_filter()->set_cursor_hidden_by_filter(false);
+ shell->cursor_manager()->ShowCursor(false);
+
+ StartRealShutdownTimer(false);
}
-void SessionStateControllerImpl2::StartRealShutdownTimer() {
+
+void SessionStateControllerImpl2::StartRealShutdownTimer(bool animation_time) {
base::TimeDelta duration =
base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs);
- duration += animator_->GetDuration(
- internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
+ if (animation_time) {
+ duration += animator_->GetDuration(
+ internal::SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
+ }
real_shutdown_timer_.Start(
FROM_HERE,
duration,
@@ -310,6 +369,165 @@ void SessionStateControllerImpl2::OnRealShutdownTimeout() {
void SessionStateControllerImpl2::OnLockScreenHide(
base::Callback<void(void)>& callback) {
+ StartUnlockAnimationPhaseOne(callback);
+}
+
+void SessionStateControllerImpl2::LockAnimationUndone() {
+ undoable_lock_animation_ = false;
+ RestoreUnlockedProperties();
+}
+
+void SessionStateControllerImpl2::LockAnimationPhaseOneCompleted() {
+ undoable_lock_animation_ = false;
+
+ delegate_->RequestLockScreen();
+ lock_fail_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs),
+ this, &SessionStateControllerImpl2::OnLockFailTimeout);
+}
+
+void SessionStateControllerImpl2::LockAnimationPhaseTwoCompleted() {
+ animating_lock_ = false;
+
+ FOR_EACH_OBSERVER(SessionStateObserver, observers_,
+ OnSessionStateEvent(
+ SessionStateObserver::EVENT_LOCK_ANIMATION_FINISHED));
+ if (!lock_screen_displayed_callback_.is_null()) {
+ lock_screen_displayed_callback_.Run();
+ lock_screen_displayed_callback_.Reset();
+ }
+ if (shutdown_after_lock_) {
+ shutdown_after_lock_ = false;
+ StartLockToShutdownTimer();
+ }
+}
+
+void SessionStateControllerImpl2::UnlockAnimationPhaseTwoCompleted() {
+ RestoreUnlockedProperties();
+}
+
+void SessionStateControllerImpl2::StartImmediateLockAnimationPhaseOne() {
+ animating_lock_ = true;
+
+ StoreUnlockedProperties();
+
+ base::Closure next_animation_starter =
+ base::Bind(&SessionStateControllerImpl2::LockAnimationPhaseOneCompleted,
+ base::Unretained(this));
+ ui::LayerAnimationObserver* observer =
+ new AnimationFinishedObserver(next_animation_starter);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_LIFT,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::LAUNCHER,
+ internal::SessionStateAnimator::ANIMATION_FADE_OUT,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ // Hide the screen locker containers so we can raise them later.
+ animator_->StartAnimation(
+ internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
+ internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
+
+ AnimateBackgroundAppearanceIfNecessary(
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ FOR_EACH_OBSERVER(SessionStateObserver, observers_,
+ OnSessionStateEvent(SessionStateObserver::EVENT_LOCK_ANIMATION_STARTED));
+}
+
+void SessionStateControllerImpl2::StartUndoableLockAnimationPhaseOne() {
+ animating_lock_ = true;
+ StoreUnlockedProperties();
+
+ base::Closure next_animation_starter =
+ base::Bind(&SessionStateControllerImpl2::LockAnimationPhaseOneCompleted,
+ base::Unretained(this));
+ AnimationFinishedObserver* observer =
+ new AnimationFinishedObserver(next_animation_starter);
+
+ observer->Pause();
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_LIFT,
+ internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE,
+ observer);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::LAUNCHER,
+ internal::SessionStateAnimator::ANIMATION_FADE_OUT,
+ internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE,
+ observer);
+
+ // Hide the screen locker containers so we can raise them later.
+ animator_->StartAnimation(
+ internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
+ internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
+
+ AnimateBackgroundAppearanceIfNecessary(
+ internal::SessionStateAnimator::ANIMATION_SPEED_UNDOABLE,
+ observer);
+
+ FOR_EACH_OBSERVER(SessionStateObserver, observers_,
+ OnSessionStateEvent(
+ SessionStateObserver::EVENT_PRELOCK_ANIMATION_STARTED));
+ observer->Unpause();
+}
+
+void SessionStateControllerImpl2::UndoLockAnimationPhaseOne() {
+ base::Closure next_animation_starter =
+ base::Bind(&SessionStateControllerImpl2::LockAnimationUndone,
+ base::Unretained(this));
+ AnimationFinishedObserver* observer =
+ new AnimationFinishedObserver(next_animation_starter);
+
+ observer->Pause();
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_UNDO_LIFT,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::LAUNCHER,
+ internal::SessionStateAnimator::ANIMATION_FADE_IN,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ AnimateBackgroundHidingIfNecessary(
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+ observer->Unpause();
+}
+
+void SessionStateControllerImpl2::StartLockAnimationPhaseTwo() {
+ base::Closure next_animation_starter =
+ base::Bind(&SessionStateControllerImpl2::LockAnimationPhaseTwoCompleted,
+ base::Unretained(this));
+
+ ui::LayerAnimationObserver* observer =
+ new AnimationFinishedObserver(next_animation_starter);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+}
+
+void SessionStateControllerImpl2::StartUnlockAnimationPhaseOne(
+ base::Closure& callback) {
animator_->StartAnimationWithCallback(
internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
internal::SessionStateAnimator::ANIMATION_LIFT,
@@ -317,4 +535,84 @@ void SessionStateControllerImpl2::OnLockScreenHide(
callback);
}
+void SessionStateControllerImpl2::StartUnlockAnimationPhaseTwo() {
+ base::Closure next_animation_starter =
+ base::Bind(&SessionStateControllerImpl2::UnlockAnimationPhaseTwoCompleted,
+ base::Unretained(this));
+
+ ui::LayerAnimationObserver* observer =
+ new AnimationFinishedObserver(next_animation_starter);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
+ internal::SessionStateAnimator::ANIMATION_DROP,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::LAUNCHER,
+ internal::SessionStateAnimator::ANIMATION_FADE_IN,
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+
+ AnimateBackgroundHidingIfNecessary(
+ internal::SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS,
+ observer);
+}
+
+void SessionStateControllerImpl2::StoreUnlockedProperties() {
+ if (!unlocked_properties_.get()) {
+ unlocked_properties_.reset(new UnlockedStateProperties());
+ unlocked_properties_->background_is_hidden = IsBackgroundHidden();
+ }
+ if (unlocked_properties_->background_is_hidden) {
+ // Hide background so that it can be animated later.
+ animator_->StartAnimation(
+ internal::SessionStateAnimator::DESKTOP_BACKGROUND,
+ internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY,
+ internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
+ ShowBackground();
+ }
+}
+
+void SessionStateControllerImpl2::RestoreUnlockedProperties() {
+ if (!unlocked_properties_.get())
+ return;
+ if (unlocked_properties_->background_is_hidden) {
+ HideBackground();
+ // Restore background visibility.
+ animator_->StartAnimation(
+ internal::SessionStateAnimator::DESKTOP_BACKGROUND,
+ internal::SessionStateAnimator::ANIMATION_FADE_IN,
+ internal::SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE);
+ }
+ unlocked_properties_.reset();
+}
+
+void SessionStateControllerImpl2::AnimateBackgroundAppearanceIfNecessary(
+ internal::SessionStateAnimator::AnimationSpeed speed,
+ ui::LayerAnimationObserver* observer) {
+ if (unlocked_properties_.get() &&
+ unlocked_properties_->background_is_hidden) {
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::DESKTOP_BACKGROUND,
+ internal::SessionStateAnimator::ANIMATION_FADE_IN,
+ speed,
+ observer);
+ }
+}
+
+void SessionStateControllerImpl2::AnimateBackgroundHidingIfNecessary(
+ internal::SessionStateAnimator::AnimationSpeed speed,
+ ui::LayerAnimationObserver* observer) {
+ if (unlocked_properties_.get() &&
+ unlocked_properties_->background_is_hidden) {
+ animator_->StartAnimationWithObserver(
+ internal::SessionStateAnimator::DESKTOP_BACKGROUND,
+ internal::SessionStateAnimator::ANIMATION_FADE_OUT,
+ speed,
+ observer);
+ }
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698