diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-01 18:03:19 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-01 18:03:19 +0000 |
commit | aa47650ec5e6a7739a55ee391637ca4969e25a84 (patch) | |
tree | 6ca1913faa47155ce0c2a5088e504fc4ab9aabcd /ash | |
parent | 73afecdbdd26c62bc101a3c78d7c593c5871588d (diff) | |
download | chromium_src-aa47650ec5e6a7739a55ee391637ca4969e25a84.zip chromium_src-aa47650ec5e6a7739a55ee391637ca4969e25a84.tar.gz chromium_src-aa47650ec5e6a7739a55ee391637ca4969e25a84.tar.bz2 |
ash: Resize PowerButtonController background layer.
PowerButtonController wasn't getting registered as an
observer on the aura::RootWindow, so its background layer
wasn't resized to match the root window's size. I don't
think that this caused any problems in practice, as the
layer gets recreated every time it's shown.
BUG=none
TEST=added
Review URL: http://codereview.chromium.org/10263015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/shell.cc | 7 | ||||
-rw-r--r-- | ash/wm/power_button_controller.cc | 7 | ||||
-rw-r--r-- | ash/wm/power_button_controller.h | 5 | ||||
-rw-r--r-- | ash/wm/power_button_controller_unittest.cc | 14 |
4 files changed, 30 insertions, 3 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index 3aab8a5..d025e4d 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -574,14 +574,15 @@ Shell::~Shell() { // Alphabetical. activation_controller_.reset(); drag_drop_controller_.reset(); + event_client_.reset(); magnification_controller_.reset(); + monitor_controller_.reset(); + power_button_controller_.reset(); resize_shadow_controller_.reset(); screen_dimmer_.reset(); shadow_controller_.reset(); - window_cycle_controller_.reset(); - event_client_.reset(); - monitor_controller_.reset(); tooltip_controller_.reset(); + window_cycle_controller_.reset(); // Launcher widget has a InputMethodBridge that references to // input_method_filter_'s input_method_. So explicitly release launcher_ diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index 885d3dd..9478de8 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -275,6 +275,11 @@ bool PowerButtonController::TestApi::BackgroundLayerIsVisible() const { controller_->background_layer_->visible(); } +gfx::Rect PowerButtonController::TestApi::GetBackgroundLayerBounds() const { + ui::Layer* layer = controller_->background_layer_.get(); + return layer ? layer->bounds() : gfx::Rect(); +} + PowerButtonController::PowerButtonController() : login_status_(user::LOGGED_IN_NONE), unlocked_login_status_(user::LOGGED_IN_NONE), @@ -284,9 +289,11 @@ PowerButtonController::PowerButtonController() has_legacy_power_button_( CommandLine::ForCurrentProcess()->HasSwitch( switches::kAuraLegacyPowerButton)) { + Shell::GetInstance()->GetRootWindow()->AddRootWindowObserver(this); } PowerButtonController::~PowerButtonController() { + Shell::GetInstance()->GetRootWindow()->RemoveRootWindowObserver(this); } void PowerButtonController::OnLoginStateChanged(user::LoginStatus status) { diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h index 27dd66f..40719d8 100644 --- a/ash/wm/power_button_controller.h +++ b/ash/wm/power_button_controller.h @@ -15,6 +15,7 @@ #include "ui/aura/root_window_observer.h" namespace gfx { +class Rect; class Size; } @@ -120,6 +121,10 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, // Returns true if |background_layer_| is non-NULL and visible. bool BackgroundLayerIsVisible() const; + // Returns |background_layer_|'s bounds, or an empty rect if the layer is + // NULL. + gfx::Rect GetBackgroundLayerBounds() const; + private: PowerButtonController* controller_; // not owned diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc index ba6316c..81a5830 100644 --- a/ash/wm/power_button_controller_unittest.cc +++ b/ash/wm/power_button_controller_unittest.cc @@ -9,6 +9,8 @@ #include "base/memory/scoped_ptr.h" #include "base/time.h" #include "ui/aura/root_window.h" +#include "ui/gfx/rect.h" +#include "ui/gfx/size.h" namespace ash { namespace test { @@ -525,5 +527,17 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { EXPECT_EQ(1, delegate_->num_shutdown_requests()); } +// Test that the background layer is resized in response to root window resizes. +TEST_F(PowerButtonControllerTest, ResizeBackgroundLayer) { + controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); + EXPECT_EQ(Shell::GetRootWindow()->bounds().ToString(), + test_api_->GetBackgroundLayerBounds().ToString()); + + const gfx::Size kNewSize(400, 300); + Shell::GetRootWindow()->SetHostSize(kNewSize); + EXPECT_EQ(gfx::Rect(kNewSize).ToString(), + test_api_->GetBackgroundLayerBounds().ToString()); +} + } // namespace test } // namespace ash |