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

Unified Diff: ash/wm/power_button_controller.cc

Issue 10909008: Improve existing lock transition - remove black splash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/power_button_controller.cc
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index 55d59931ee8f75ef047a408b53b320f0f9914044..a3fac854fff013a155f8521a2baa21da152e2808 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -159,48 +159,43 @@ void RestoreWindow(aura::Window* window) {
window->layer()->SetOpacity(1.0);
}
-// Fills |containers| with the containers described by |group|.
-void GetContainers(PowerButtonController::ContainerGroup group,
- aura::Window::Windows* containers) {
+// Fills |containers| with the containers described by |container_mask|.
+void GetContainers(int container_mask, aura::Window::Windows* containers) {
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
-
- aura::Window* non_lock_screen_containers = Shell::GetContainer(
- root_window,
- internal::kShellWindowId_NonLockScreenContainersContainer);
- aura::Window* lock_screen_containers = Shell::GetContainer(
- root_window,
- internal::kShellWindowId_LockScreenContainersContainer);
- aura::Window* lock_screen_related_containers = Shell::GetContainer(
- root_window,
- internal::kShellWindowId_LockScreenRelatedContainersContainer);
-
containers->clear();
- switch (group) {
- case PowerButtonController::ALL_CONTAINERS:
- containers->push_back(non_lock_screen_containers);
- containers->push_back(lock_screen_containers);
- containers->push_back(lock_screen_related_containers);
- break;
- case PowerButtonController::SCREEN_LOCKER_CONTAINERS:
- containers->push_back(lock_screen_containers);
- break;
- case PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS:
- containers->push_back(lock_screen_containers);
- containers->push_back(lock_screen_related_containers);
- break;
- case PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS:
- containers->push_back(non_lock_screen_containers);
- break;
- default:
- NOTREACHED() << "Unhandled container group " << group;
+
+ if (container_mask & PowerButtonController::DESKTOP_WALLPAPER) {
+ containers->push_back(Shell::GetContainer(
+ root_window,
+ internal::kShellWindowId_DesktopBackgroundContainer));
+ }
+ if (container_mask & PowerButtonController::NON_LOCK_SCREEN_CONTAINERS) {
+ containers->push_back(Shell::GetContainer(
+ root_window,
+ internal::kShellWindowId_NonLockScreenContainersContainer));
+ }
+ if (container_mask & PowerButtonController::LOCK_SCREEN_WALLPAPER) {
+ containers->push_back(Shell::GetContainer(
+ root_window,
+ internal::kShellWindowId_LockScreenBackgroundContainer));
+ }
+ if (container_mask & PowerButtonController::LOCK_SCREEN_CONTAINERS) {
+ containers->push_back(Shell::GetContainer(
+ root_window,
+ internal::kShellWindowId_LockScreenContainersContainer));
+ }
+ if (container_mask & PowerButtonController::LOCK_SCREEN_RELATED_CONTAINERS) {
+ containers->push_back(Shell::GetContainer(
+ root_window,
+ internal::kShellWindowId_LockScreenRelatedContainersContainer));
}
}
-// Apply animation |type| to all containers described by |group|.
-void StartAnimation(PowerButtonController::ContainerGroup group,
+// Apply animation |type| to all containers described by |container_mask|.
+void StartAnimation(int container_mask,
PowerButtonController::AnimationType type) {
aura::Window::Windows containers;
- GetContainers(group, &containers);
+ GetContainers(container_mask, &containers);
for (aura::Window::Windows::const_iterator it = containers.begin();
it != containers.end(); ++it) {
@@ -233,9 +228,9 @@ void StartAnimation(PowerButtonController::ContainerGroup group,
} // namespace
bool PowerButtonController::TestApi::ContainerGroupIsAnimated(
- ContainerGroup group, AnimationType type) const {
+ int container_mask, AnimationType type) const {
aura::Window::Windows containers;
- GetContainers(group, &containers);
+ GetContainers(container_mask, &containers);
for (aura::Window::Windows::const_iterator it = containers.begin();
it != containers.end(); ++it) {
aura::Window* window = *it;
@@ -285,6 +280,20 @@ gfx::Rect PowerButtonController::TestApi::GetBackgroundLayerBounds() const {
return layer ? layer->bounds() : gfx::Rect();
}
+// static
+int PowerButtonController::GetAllContainersMask() {
+ return PowerButtonController::DESKTOP_WALLPAPER |
+ PowerButtonController::NON_LOCK_SCREEN_CONTAINERS |
+ GetAllScreenLockContainersMask();
+}
+
+// static
+int PowerButtonController::GetAllScreenLockContainersMask() {
+ return PowerButtonController::LOCK_SCREEN_WALLPAPER |
+ PowerButtonController::LOCK_SCREEN_CONTAINERS |
+ PowerButtonController::LOCK_SCREEN_RELATED_CONTAINERS;
+}
+
PowerButtonController::PowerButtonController()
: login_status_(user::LOGGED_IN_NONE),
unlocked_login_status_(user::LOGGED_IN_NONE),
@@ -316,7 +325,7 @@ void PowerButtonController::OnAppTerminating() {
shell->env_filter()->set_update_cursor_visibility(false);
shell->cursor_manager()->ShowCursor(false);
ShowBackgroundLayer();
- StartAnimation(ALL_CONTAINERS, ANIMATION_HIDE);
+ StartAnimation(GetAllContainersMask(), ANIMATION_HIDE);
}
}
@@ -333,7 +342,7 @@ void PowerButtonController::OnLockStateChanged(bool locked) {
}
if (locked) {
- StartAnimation(SCREEN_LOCKER_CONTAINERS, ANIMATION_FADE_IN);
+ StartAnimation(LOCK_SCREEN_CONTAINERS, ANIMATION_FADE_IN);
lock_timer_.Stop();
lock_fail_timer_.Stop();
@@ -345,8 +354,7 @@ void PowerButtonController::OnLockStateChanged(bool locked) {
this, &PowerButtonController::OnLockToShutdownTimeout);
}
} else {
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_RESTORE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_RESTORE);
HideBackgroundLayer();
}
}
@@ -364,11 +372,10 @@ void PowerButtonController::OnStartingLock() {
// slow-close animation.
ShowBackgroundLayer();
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_FAST_CLOSE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_FAST_CLOSE);
// Hide the screen locker containers so we can make them fade in later.
- StartAnimation(SCREEN_LOCKER_CONTAINERS, ANIMATION_HIDE);
+ StartAnimation(LOCK_SCREEN_CONTAINERS, ANIMATION_HIDE);
}
void PowerButtonController::OnPowerButtonEvent(
@@ -390,8 +397,7 @@ void PowerButtonController::OnPowerButtonEvent(
if (down) {
ShowBackgroundLayer();
if (LoggedInAsNonGuest() && login_status_ != user::LOGGED_IN_LOCKED) {
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_SLOW_CLOSE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_SLOW_CLOSE);
OnLockTimeout();
} else {
OnShutdownTimeout();
@@ -411,7 +417,7 @@ void PowerButtonController::OnPowerButtonEvent(
if (lock_timer_.IsRunning() || shutdown_timer_.IsRunning())
StartAnimation(
(login_status_ == user::LOGGED_IN_LOCKED) ?
- SCREEN_LOCKER_AND_RELATED_CONTAINERS : ALL_CONTAINERS,
+ GetAllScreenLockContainersMask() : GetAllContainersMask(),
ANIMATION_UNDO_SLOW_CLOSE);
// Drop the background layer after the undo animation finishes.
@@ -450,8 +456,7 @@ void PowerButtonController::OnLockButtonEvent(
StartLockTimer();
} else {
if (lock_timer_.IsRunning()) {
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_UNDO_SLOW_CLOSE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_UNDO_SLOW_CLOSE);
hide_background_layer_timer_.Stop();
hide_background_layer_timer_.Start(
FROM_HERE,
@@ -499,8 +504,7 @@ void PowerButtonController::OnLockTimeout() {
void PowerButtonController::OnLockFailTimeout() {
DCHECK_NE(login_status_, user::LOGGED_IN_LOCKED);
LOG(ERROR) << "Screen lock request timed out";
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_RESTORE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_RESTORE);
HideBackgroundLayer();
}
@@ -521,8 +525,7 @@ void PowerButtonController::OnRealShutdownTimeout() {
void PowerButtonController::StartLockTimer() {
ShowBackgroundLayer();
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_SLOW_CLOSE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_SLOW_CLOSE);
lock_timer_.Stop();
lock_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kSlowCloseAnimMs),
@@ -531,7 +534,7 @@ void PowerButtonController::StartLockTimer() {
void PowerButtonController::StartShutdownTimer() {
ShowBackgroundLayer();
- StartAnimation(ALL_CONTAINERS, ANIMATION_SLOW_CLOSE);
+ StartAnimation(GetAllContainersMask(), ANIMATION_SLOW_CLOSE);
shutdown_timer_.Stop();
shutdown_timer_.Start(
FROM_HERE,
@@ -552,11 +555,10 @@ void PowerButtonController::StartShutdownAnimationAndRequestShutdown() {
// Hide the other containers before starting the animation.
// ANIMATION_FAST_CLOSE will make the screen locker windows partially
// transparent, and we don't want the other windows to show through.
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_HIDE);
- StartAnimation(SCREEN_LOCKER_AND_RELATED_CONTAINERS, ANIMATION_FAST_CLOSE);
+ StartAnimation(NON_LOCK_SCREEN_CONTAINERS, ANIMATION_HIDE);
+ StartAnimation(GetAllScreenLockContainersMask(), ANIMATION_FAST_CLOSE);
} else {
- StartAnimation(ALL_CONTAINERS, ANIMATION_FAST_CLOSE);
+ StartAnimation(GetAllContainersMask(), ANIMATION_FAST_CLOSE);
}
real_shutdown_timer_.Start(

Powered by Google App Engine
This is Rietveld 408576698