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

Unified Diff: ash/wm/power_button_controller.h

Issue 10914016: ash: Extract animator from PowerButtonController (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Naming fixes Created 8 years, 4 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.h
diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h
index eee5f1cd9ee832ca9cd4509402e9f008eeddec70..941e6ca8d129d7f01cd08000a52977873c14a5fe 100644
--- a/ash/wm/power_button_controller.h
+++ b/ash/wm/power_button_controller.h
@@ -7,6 +7,7 @@
#include "ash/ash_export.h"
#include "ash/shell_observer.h"
+#include "ash/wm/session_state_animator.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
@@ -42,31 +43,16 @@ class ASH_EXPORT PowerButtonControllerDelegate {
class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
public ShellObserver {
public:
- // Animations that can be applied to groups of containers.
- // Exposed here for TestApi::ContainerGroupIsAnimated().
- enum AnimationType {
- ANIMATION_SLOW_CLOSE = 0,
- ANIMATION_UNDO_SLOW_CLOSE,
- ANIMATION_FAST_CLOSE,
- ANIMATION_FADE_IN,
- ANIMATION_HIDE,
- ANIMATION_RESTORE,
- };
-
- // Groups of containers that can be animated.
- // Exposed here for TestApi::ContainerGroupIsAnimated().
- enum ContainerGroup {
- ALL_CONTAINERS = 0,
- SCREEN_LOCKER_CONTAINERS,
- SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- };
-
// Helper class used by tests to access internal state.
class ASH_EXPORT TestApi {
public:
explicit TestApi(PowerButtonController* controller)
- : controller_(controller) {}
+ : controller_(controller),
+ animator_api_(new SessionStateAnimator::TestApi(
+ controller->animator_)) {}
+ virtual ~TestApi() {
+ delete animator_api_;
+ }
bool lock_timer_is_running() const {
return controller_->lock_timer_.IsRunning();
@@ -84,7 +70,7 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
return controller_->real_shutdown_timer_.IsRunning();
}
bool hide_background_layer_timer_is_running() const {
- return controller_->hide_background_layer_timer_.IsRunning();
+ return animator_api_->hide_background_layer_timer_is_running();
}
void trigger_lock_timeout() {
@@ -108,24 +94,31 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
controller_->real_shutdown_timer_.Stop();
}
void trigger_hide_background_layer_timeout() {
- controller_->HideBackgroundLayer();
- controller_->hide_background_layer_timer_.Stop();
+ animator_api_->trigger_hide_background_layer_timeout();
}
// Returns true if the given set of containers was last animated with
// |type| (probably; the analysis is fairly ad-hoc).
- bool ContainerGroupIsAnimated(ContainerGroup group,
- AnimationType type) const;
+ bool ContainerGroupIsAnimated(
+ SessionStateAnimator::ContainerGroup group,
+ SessionStateAnimator::AnimationType type) const {
+ return animator_api_->ContainerGroupIsAnimated(group, type);
+ }
// Returns true if |background_layer_| is non-NULL and visible.
- bool BackgroundLayerIsVisible() const;
+ bool BackgroundLayerIsVisible() const {
+ return animator_api_->BackgroundLayerIsVisible();
+ }
// Returns |background_layer_|'s bounds, or an empty rect if the layer is
// NULL.
- gfx::Rect GetBackgroundLayerBounds() const;
+ gfx::Rect GetBackgroundLayerBounds() const {
+ return animator_api_->GetBackgroundLayerBounds();
+ }
private:
PowerButtonController* controller_; // not owned
+ SessionStateAnimator::TestApi* animator_api_; // owned
Daniel Erat 2012/08/31 17:02:12 any reason not to use scoped_ptr instead?
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
DISALLOW_COPY_AND_ASSIGN(TestApi);
};
@@ -155,8 +148,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
void RequestShutdown();
// aura::RootWindowObserver overrides:
- virtual void OnRootWindowResized(const aura::RootWindow* root,
- const gfx::Size& old_size) OVERRIDE;
virtual void OnRootWindowHostCloseRequested(
const aura::RootWindow* root) OVERRIDE;
@@ -190,11 +181,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
// Displays the shutdown animation and starts |real_shutdown_timer_|.
void StartShutdownAnimationAndRequestShutdown();
- // Shows or hides |background_layer_|. The show method creates and
- // initializes the layer if it doesn't already exist.
- void ShowBackgroundLayer();
- void HideBackgroundLayer();
-
scoped_ptr<PowerButtonControllerDelegate> delegate_;
// The current login status.
@@ -221,13 +207,6 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
// that misreports power button releases?
bool has_legacy_power_button_;
- // Layer that's stacked under all of the root window's children to provide a
- // black background when we're scaling all of the other windows down.
- // TODO(derat): Remove this in favor of having the compositor only clear the
- // viewport when there are regions not covered by a layer:
- // http://crbug.com/113445
- scoped_ptr<ui::Layer> background_layer_;
-
// Started when the user first presses the power button while in a
// logged-in-as-a-non-guest-user, unlocked state. When it fires, we lock the
// screen.
@@ -251,10 +230,7 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
// etc. are shut down.
base::OneShotTimer<PowerButtonController> real_shutdown_timer_;
- // Started when we abort the pre-lock state. When it fires, we hide
- // |background_layer_|, as the desktop background is now covering the whole
- // screen.
- base::OneShotTimer<PowerButtonController> hide_background_layer_timer_;
+ SessionStateAnimator* animator_;
Daniel Erat 2012/08/31 17:02:12 use scoped_ptr. in general, please use it every t
Denis Kuznetsov (DE-MUC) 2012/09/28 11:52:43 Done.
DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
};

Powered by Google App Engine
This is Rietveld 408576698