Commit aa47650e authored by derat@chromium.org's avatar derat@chromium.org

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
parent 73afecdb
...@@ -574,14 +574,15 @@ Shell::~Shell() { ...@@ -574,14 +574,15 @@ Shell::~Shell() {
// Alphabetical. // Alphabetical.
activation_controller_.reset(); activation_controller_.reset();
drag_drop_controller_.reset(); drag_drop_controller_.reset();
event_client_.reset();
magnification_controller_.reset(); magnification_controller_.reset();
monitor_controller_.reset();
power_button_controller_.reset();
resize_shadow_controller_.reset(); resize_shadow_controller_.reset();
screen_dimmer_.reset(); screen_dimmer_.reset();
shadow_controller_.reset(); shadow_controller_.reset();
window_cycle_controller_.reset();
event_client_.reset();
monitor_controller_.reset();
tooltip_controller_.reset(); tooltip_controller_.reset();
window_cycle_controller_.reset();
// Launcher widget has a InputMethodBridge that references to // Launcher widget has a InputMethodBridge that references to
// input_method_filter_'s input_method_. So explicitly release launcher_ // input_method_filter_'s input_method_. So explicitly release launcher_
......
...@@ -275,6 +275,11 @@ bool PowerButtonController::TestApi::BackgroundLayerIsVisible() const { ...@@ -275,6 +275,11 @@ bool PowerButtonController::TestApi::BackgroundLayerIsVisible() const {
controller_->background_layer_->visible(); 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() PowerButtonController::PowerButtonController()
: login_status_(user::LOGGED_IN_NONE), : login_status_(user::LOGGED_IN_NONE),
unlocked_login_status_(user::LOGGED_IN_NONE), unlocked_login_status_(user::LOGGED_IN_NONE),
...@@ -284,9 +289,11 @@ PowerButtonController::PowerButtonController() ...@@ -284,9 +289,11 @@ PowerButtonController::PowerButtonController()
has_legacy_power_button_( has_legacy_power_button_(
CommandLine::ForCurrentProcess()->HasSwitch( CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAuraLegacyPowerButton)) { switches::kAuraLegacyPowerButton)) {
Shell::GetInstance()->GetRootWindow()->AddRootWindowObserver(this);
} }
PowerButtonController::~PowerButtonController() { PowerButtonController::~PowerButtonController() {
Shell::GetInstance()->GetRootWindow()->RemoveRootWindowObserver(this);
} }
void PowerButtonController::OnLoginStateChanged(user::LoginStatus status) { void PowerButtonController::OnLoginStateChanged(user::LoginStatus status) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/aura/root_window_observer.h" #include "ui/aura/root_window_observer.h"
namespace gfx { namespace gfx {
class Rect;
class Size; class Size;
} }
...@@ -120,6 +121,10 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, ...@@ -120,6 +121,10 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
// Returns true if |background_layer_| is non-NULL and visible. // Returns true if |background_layer_| is non-NULL and visible.
bool BackgroundLayerIsVisible() const; bool BackgroundLayerIsVisible() const;
// Returns |background_layer_|'s bounds, or an empty rect if the layer is
// NULL.
gfx::Rect GetBackgroundLayerBounds() const;
private: private:
PowerButtonController* controller_; // not owned PowerButtonController* controller_; // not owned
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/time.h" #include "base/time.h"
#include "ui/aura/root_window.h" #include "ui/aura/root_window.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
namespace ash { namespace ash {
namespace test { namespace test {
...@@ -525,5 +527,17 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { ...@@ -525,5 +527,17 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) {
EXPECT_EQ(1, delegate_->num_shutdown_requests()); 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 test
} // namespace ash } // namespace ash
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment