Commit a99e783b authored by Mitsuru Oshima's avatar Mitsuru Oshima

Intorduce PowerButtonObserver API

renamed existing PowerButtonController to ShutdownDialog

BUG=None
TEST=covered by unit tests

Committed: https://crrev.com/0d921cdf45872ebff6c22da6a21c12d44054a860
Cr-Commit-Position: refs/heads/master@{#299821}

R=mukai@chromium.org

Review URL: https://codereview.chromium.org/654343002

Cr-Commit-Position: refs/heads/master@{#299873}
parent 2f457ff6
......@@ -69,6 +69,9 @@
'input/accelerator_manager_impl.cc',
'input/accelerator_manager_impl.h',
'input/input_manager_impl.cc',
'input/input_manager_impl.h',
'input/power_button_controller.cc',
'input/power_button_controller.h',
'input/public/accelerator_manager.h',
'input/public/input_manager.h',
'resource_manager/delegate/resource_manager_delegate.cc',
......@@ -87,8 +90,8 @@
'system/network_selector.h',
'system/orientation_controller.cc',
'system/orientation_controller.h',
'system/power_button_controller.cc',
'system/power_button_controller.h',
'system/shutdown_dialog.cc',
'system/shutdown_dialog.h',
'system/status_icon_container_view.cc',
'system/status_icon_container_view.h',
'system/time_view.cc',
......@@ -289,6 +292,7 @@
'home/home_card_gesture_manager_unittest.cc',
'home/home_card_unittest.cc',
'input/accelerator_manager_unittest.cc',
'input/input_manager_unittest.cc',
'resource_manager/memory_pressure_notifier_unittest.cc',
'resource_manager/resource_manager_unittest.cc',
'screen/screen_manager_unittest.cc',
......
include_rules = [
"+chromeos",
"+ui/aura",
"+ui/base",
"+ui/events",
......@@ -7,3 +8,9 @@ include_rules = [
"+ui/views",
]
specific_include_rules = {
# exported for test.
"input_manager_impl.h": [
"+athena/athena_export.h",
],
}
......@@ -43,7 +43,7 @@ class TestHandler : public AcceleratorHandler {
DISALLOW_COPY_AND_ASSIGN(TestHandler);
};
} // namespace athena
} // namespace
typedef test::AthenaTestBase InputManagerTest;
......
......@@ -2,60 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/input/public/input_manager.h"
#include "athena/input/input_manager_impl.h"
#include "athena/input/accelerator_manager_impl.h"
#include "athena/input/power_button_controller.h"
#include "base/logging.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/events/event_target.h"
namespace athena {
namespace {
InputManager* instance = NULL;
class InputManagerImpl : public InputManager,
public ui::EventTarget,
public aura::client::EventClient {
public:
InputManagerImpl();
virtual ~InputManagerImpl();
void Init();
void Shutdown();
private:
// InputManager:
virtual void OnRootWindowCreated(aura::Window* root_window) override;
virtual ui::EventTarget* GetTopmostEventTarget() override { return this; }
virtual AcceleratorManager* GetAcceleratorManager() override {
return accelerator_manager_.get();
}
// Overridden from aura::client::EventClient:
virtual bool CanProcessEventsWithinSubtree(
const aura::Window* window) const override {
return window && !window->ignore_events();
}
virtual ui::EventTarget* GetToplevelEventTarget() override { return this; }
// ui::EventTarget:
virtual bool CanAcceptEvent(const ui::Event& event) override;
virtual ui::EventTarget* GetParentTarget() override;
virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override;
virtual ui::EventTargeter* GetEventTargeter() override;
virtual void OnEvent(ui::Event* event) override;
scoped_ptr<AcceleratorManagerImpl> accelerator_manager_;
DISALLOW_COPY_AND_ASSIGN(InputManagerImpl);
};
} // namespace
InputManagerImpl::InputManagerImpl()
: accelerator_manager_(
AcceleratorManagerImpl::CreateGlobalAcceleratorManager()) {
AcceleratorManagerImpl::CreateGlobalAcceleratorManager()),
power_button_controller_(new PowerButtonController) {
DCHECK(!instance);
instance = this;
}
......@@ -68,6 +32,7 @@ InputManagerImpl::~InputManagerImpl() {
void InputManagerImpl::Init() {
accelerator_manager_->Init();
power_button_controller_->InstallAccelerators();
}
void InputManagerImpl::Shutdown() {
......@@ -79,6 +44,31 @@ void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
accelerator_manager_->OnRootWindowCreated(root_window);
}
ui::EventTarget* InputManagerImpl::GetTopmostEventTarget() {
return this;
}
AcceleratorManager* InputManagerImpl::GetAcceleratorManager() {
return accelerator_manager_.get();
}
void InputManagerImpl::AddPowerButtonObserver(PowerButtonObserver* observer) {
power_button_controller_->AddPowerButtonObserver(observer);
}
void InputManagerImpl::RemovePowerButtonObserver(
PowerButtonObserver* observer) {
power_button_controller_->RemovePowerButtonObserver(observer);
}
bool InputManagerImpl::CanProcessEventsWithinSubtree(
const aura::Window* window) const {
return window && !window->ignore_events();
}
ui::EventTarget* InputManagerImpl::GetToplevelEventTarget() {
return this;
}
bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
return true;
}
......@@ -99,7 +89,9 @@ ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
void InputManagerImpl::OnEvent(ui::Event* event) {
}
} // namespace
int InputManagerImpl::SetPowerButtonTimeoutMsForTest(int timeout) {
return power_button_controller_->SetPowerButtonTimeoutMsForTest(timeout);
}
// static
InputManager* InputManager::Create() {
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_INPUT_INPUT_MANAGER_IMPL_H_
#define ATHENA_INPUT_INPUT_MANAGER_IMPL_H_
#include "athena/input/public/input_manager.h"
#include "athena/athena_export.h"
#include "athena/input/accelerator_manager_impl.h"
#include "ui/aura/client/event_client.h"
#include "ui/events/event_target.h"
namespace athena {
class PowerButtonController;
namespace test {
class ScopedPowerButtonTimeoutShortener;
}
class ATHENA_EXPORT InputManagerImpl : public InputManager,
public ui::EventTarget,
public aura::client::EventClient {
public:
InputManagerImpl();
virtual ~InputManagerImpl();
void Init();
void Shutdown();
private:
friend class test::ScopedPowerButtonTimeoutShortener;
// InputManager:
virtual void OnRootWindowCreated(aura::Window* root_window) override;
virtual ui::EventTarget* GetTopmostEventTarget() override;
virtual AcceleratorManager* GetAcceleratorManager() override;
virtual void AddPowerButtonObserver(PowerButtonObserver* observer) override;
virtual void RemovePowerButtonObserver(
PowerButtonObserver* observer) override;
// Overridden from aura::client::EventClient:
virtual bool CanProcessEventsWithinSubtree(
const aura::Window* window) const override;
virtual ui::EventTarget* GetToplevelEventTarget() override;
// ui::EventTarget:
virtual bool CanAcceptEvent(const ui::Event& event) override;
virtual ui::EventTarget* GetParentTarget() override;
virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override;
virtual ui::EventTargeter* GetEventTargeter() override;
virtual void OnEvent(ui::Event* event) override;
int SetPowerButtonTimeoutMsForTest(int timeout);
scoped_ptr<AcceleratorManagerImpl> accelerator_manager_;
scoped_ptr<PowerButtonController> power_button_controller_;
DISALLOW_COPY_AND_ASSIGN(InputManagerImpl);
};
} // namespace athena
#endif // ATHENA_INPUT_INPUT_MANAGER_IMPL_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/input/input_manager_impl.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/test/base/athena_test_base.h"
#include "base/run_loop.h"
#include "ui/events/test/event_generator.h"
namespace athena {
namespace {
class TestPowerButtonObserver : public PowerButtonObserver {
public:
TestPowerButtonObserver() : count_(0), state_(RELEASED) {
InputManager::Get()->AddPowerButtonObserver(this);
}
virtual ~TestPowerButtonObserver() {
InputManager::Get()->RemovePowerButtonObserver(this);
}
int count() const { return count_; }
State state() const { return state_; }
bool WaitForLongPress() {
run_loop_.Run();
return state_ == LONG_PRESSED;
}
private:
virtual void OnPowerButtonStateChanged(
PowerButtonObserver::State state) override {
state_ = state;
count_++;
if (state == LONG_PRESSED) {
DCHECK(run_loop_.running());
run_loop_.Quit();
}
}
base::RunLoop run_loop_;
int count_;
State state_;
DISALLOW_COPY_AND_ASSIGN(TestPowerButtonObserver);
};
} // namespace
namespace test {
class ScopedPowerButtonTimeoutShortener {
public:
ScopedPowerButtonTimeoutShortener()
: original_timeout_(
GetInputManagerImpl()->SetPowerButtonTimeoutMsForTest(1)) {}
~ScopedPowerButtonTimeoutShortener() {
GetInputManagerImpl()->SetPowerButtonTimeoutMsForTest(original_timeout_);
}
private:
InputManagerImpl* GetInputManagerImpl() {
return static_cast<InputManagerImpl*>(InputManager::Get());
}
int original_timeout_;
DISALLOW_COPY_AND_ASSIGN(ScopedPowerButtonTimeoutShortener);
};
} // namespace test
typedef test::AthenaTestBase InputManagerTest;
TEST_F(InputManagerTest, PowerButton) {
test::ScopedPowerButtonTimeoutShortener shortener;
TestPowerButtonObserver observer;
ui::test::EventGenerator generator(root_window());
generator.PressKey(ui::VKEY_P, ui::EF_NONE);
EXPECT_EQ(0, observer.count());
// Test short press.
generator.PressKey(ui::VKEY_P, ui::EF_ALT_DOWN);
EXPECT_EQ(1, observer.count());
EXPECT_EQ(PowerButtonObserver::PRESSED, observer.state());
generator.ReleaseKey(ui::VKEY_P, ui::EF_ALT_DOWN);
EXPECT_EQ(2, observer.count());
EXPECT_EQ(PowerButtonObserver::RELEASED, observer.state());
// Test long press.
generator.PressKey(ui::VKEY_P, ui::EF_ALT_DOWN);
EXPECT_EQ(3, observer.count());
EXPECT_EQ(PowerButtonObserver::PRESSED, observer.state());
EXPECT_TRUE(observer.WaitForLongPress());
EXPECT_EQ(4, observer.count());
EXPECT_EQ(PowerButtonObserver::LONG_PRESSED, observer.state());
generator.ReleaseKey(ui::VKEY_P, ui::EF_ALT_DOWN);
EXPECT_EQ(5, observer.count());
EXPECT_EQ(PowerButtonObserver::RELEASED, observer.state());
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/input/power_button_controller.h"
#include "athena/input/public/accelerator_manager.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "ui/events/event_constants.h"
namespace athena {
namespace {
// The amount of time that the power button must be held to be
// treated as long press.
const int kLongPressTimeoutMs = 1000;
enum {
CMD_DEBUG_POWER_BUTTON_PRESSED,
CMD_DEBUG_POWER_BUTTON_RELEASED,
};
} // namespace
PowerButtonController::PowerButtonController()
: power_button_timeout_ms_(kLongPressTimeoutMs),
brightness_is_zero_(false) {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
this);
}
PowerButtonController::~PowerButtonController() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
this);
}
void PowerButtonController::AddPowerButtonObserver(
PowerButtonObserver* observer) {
observers_.AddObserver(observer);
}
void PowerButtonController::RemovePowerButtonObserver(
PowerButtonObserver* observer) {
observers_.RemoveObserver(observer);
}
void PowerButtonController::InstallAccelerators() {
const AcceleratorData accelerator_data[] = {
{TRIGGER_ON_PRESS,
ui::VKEY_P,
ui::EF_ALT_DOWN,
CMD_DEBUG_POWER_BUTTON_PRESSED,
AF_DEBUG | AF_NON_AUTO_REPEATABLE},
{TRIGGER_ON_RELEASE,
ui::VKEY_P,
ui::EF_ALT_DOWN,
CMD_DEBUG_POWER_BUTTON_RELEASED,
AF_DEBUG},
};
AcceleratorManager::Get()->RegisterAccelerators(
accelerator_data, arraysize(accelerator_data), this);
}
int PowerButtonController::SetPowerButtonTimeoutMsForTest(int timeout) {
int old_timeout = power_button_timeout_ms_;
power_button_timeout_ms_ = timeout;
return old_timeout;
}
void PowerButtonController::BrightnessChanged(int level, bool user_initiated) {
if (brightness_is_zero_)
zero_brightness_end_time_ = base::TimeTicks::Now();
brightness_is_zero_ = (level == 0);
}
void PowerButtonController::PowerButtonEventReceived(
bool down,
const base::TimeTicks& timestamp) {
// Ignore power button pressed while the screen is off
// (http://crbug.com/128451).
// TODO(oshima): This needs to be revisited for athena.
base::TimeDelta time_since_zero_brightness =
brightness_is_zero_
? base::TimeDelta()
: (base::TimeTicks::Now() - zero_brightness_end_time_);
const int kShortTimeMs = 10;
if (time_since_zero_brightness.InMilliseconds() <= kShortTimeMs)
return;
if (down) {
FOR_EACH_OBSERVER(PowerButtonObserver,
observers_,
OnPowerButtonStateChanged(PowerButtonObserver::PRESSED));
timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kLongPressTimeoutMs),
this,
&PowerButtonController::NotifyLongPress);
} else {
FOR_EACH_OBSERVER(PowerButtonObserver,
observers_,
OnPowerButtonStateChanged(PowerButtonObserver::RELEASED));
timer_.Stop();
}
}
bool PowerButtonController::IsCommandEnabled(int command_id) const {
return true;
}
bool PowerButtonController::OnAcceleratorFired(
int command_id,
const ui::Accelerator& accelerator) {
switch (command_id) {
case CMD_DEBUG_POWER_BUTTON_PRESSED:
PowerButtonEventReceived(true, base::TimeTicks());
break;
case CMD_DEBUG_POWER_BUTTON_RELEASED:
PowerButtonEventReceived(false, base::TimeTicks());
break;
}
return true;
}
void PowerButtonController::NotifyLongPress() {
FOR_EACH_OBSERVER(
PowerButtonObserver,
observers_,
OnPowerButtonStateChanged(PowerButtonObserver::LONG_PRESSED));
}
} // namespace
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_
#define ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_
#include "athena/input/public/accelerator_manager.h"
#include "athena/input/public/input_manager.h"
#include "base/observer_list.h"
#include "base/timer/timer.h"
#include "chromeos/dbus/power_manager_client.h"
namespace athena {
class PowerButtonController : public chromeos::PowerManagerClient::Observer,
public AcceleratorHandler {
public:
PowerButtonController();
virtual ~PowerButtonController();
void AddPowerButtonObserver(PowerButtonObserver* observer);
void RemovePowerButtonObserver(PowerButtonObserver* observer);
void InstallAccelerators();
// A timer callabck to notify the long press event.
int SetPowerButtonTimeoutMsForTest(int timeout);
private:
// chromeos::PowerManagerClient::Observer:
virtual void BrightnessChanged(int level, bool user_initiated) override;
virtual void PowerButtonEventReceived(
bool down,
const base::TimeTicks& timestamp) override;
// AcceleratorHandler:
virtual bool IsCommandEnabled(int command_id) const override;
virtual bool OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) override;
void NotifyLongPress();
int power_button_timeout_ms_;
ObserverList<PowerButtonObserver> observers_;
// The last time at which the screen brightness was 0%.
base::TimeTicks zero_brightness_end_time_;
bool brightness_is_zero_;
base::OneShotTimer<PowerButtonController> timer_;
DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
};
} // namespace athena
#endif // ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_
......@@ -18,6 +18,17 @@ class EventTarget;
namespace athena {
class AcceleratorManager;
class PowerButtonObserver {
public:
enum State {
PRESSED,
LONG_PRESSED,
RELEASED,
};
virtual void OnPowerButtonStateChanged(State state) = 0;
};
class ATHENA_EXPORT InputManager {
public:
// Creates and deletes the singleton object of the InputManager
......@@ -30,6 +41,10 @@ class ATHENA_EXPORT InputManager {
// with EnvObserver::WindowInitialized
virtual void OnRootWindowCreated(aura::Window* root_window) = 0;
// Add/remove power button observer.
virtual void AddPowerButtonObserver(PowerButtonObserver* observer) = 0;
virtual void RemovePowerButtonObserver(PowerButtonObserver* observer) = 0;
virtual ui::EventTarget* GetTopmostEventTarget() = 0;
virtual AcceleratorManager* GetAcceleratorManager() = 0;
......
......@@ -3,6 +3,7 @@ include_rules = [
"+athena/screen/public",
"+athena/strings/grit/athena_strings.h",
"+athena/system/public",
"+athena/input/public",
"+chromeos",
"+third_party/cros_system_api/dbus/service_constants.h",
"+third_party/skia/include",
......
......@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/system/power_button_controller.h"
#include "athena/system/shutdown_dialog.h"
#include "athena/screen/public/screen_manager.h"
#include "athena/strings/grit/athena_strings.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/font_list.h"
#include "ui/views/background.h"
......@@ -18,30 +19,22 @@
namespace athena {
namespace {
// The amount of time that the power button must be held to show the shutdown
// warning dialog.
const int kShowShutdownWarningTimeoutMs = 1000;
// The amount of time that the power button must be held to shut down the
// device.
const int kShutdownTimeoutMs = 5000;
// device after shutdown dialog is shown.
const int kShutdownTimeoutMs = 4000;
} // namespace
PowerButtonController::PowerButtonController(aura::Window* dialog_container)
: warning_message_container_(dialog_container),
brightness_is_zero_(false),
state_(STATE_OTHER) {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
this);
ShutdownDialog::ShutdownDialog(aura::Window* dialog_container)
: warning_message_container_(dialog_container), state_(STATE_OTHER) {
InputManager::Get()->AddPowerButtonObserver(this);
}
PowerButtonController::~PowerButtonController() {
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
this);
ShutdownDialog::~ShutdownDialog() {
InputManager::Get()->RemovePowerButtonObserver(this);
}
void PowerButtonController::ShowShutdownWarningDialog() {
void ShutdownDialog::ShowShutdownWarningDialog() {
state_ = STATE_SHUTDOWN_WARNING_VISIBLE;
shutdown_warning_message_.reset(new views::Widget);
......@@ -69,57 +62,41 @@ void PowerButtonController::ShowShutdownWarningDialog() {
shutdown_warning_message_->SetContentsView(container);
shutdown_warning_message_->CenterWindow(container->GetPreferredSize());
shutdown_warning_message_->Show();
timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs -
kShowShutdownWarningTimeoutMs),
base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs),
this,
&PowerButtonController::Shutdown);
&ShutdownDialog::Shutdown);
}
void PowerButtonController::Shutdown() {
void ShutdownDialog::Shutdown() {
state_ = STATE_SHUTDOWN_REQUESTED;
chromeos::DBusThreadManager::Get()
->GetPowerManagerClient()
->RequestShutdown();
}
void PowerButtonController::BrightnessChanged(int level, bool user_initiated) {
if (brightness_is_zero_)
zero_brightness_end_time_ = base::TimeTicks::Now();
brightness_is_zero_ = (level == 0);
}
void PowerButtonController::PowerButtonEventReceived(
bool down,
const base::TimeTicks& timestamp) {
void ShutdownDialog::OnPowerButtonStateChanged(
PowerButtonObserver::State state) {
if (state_ == STATE_SHUTDOWN_REQUESTED)
return;
// Avoid requesting suspend or shutdown if the power button is pressed while
// the screen is off (http://crbug.com/128451).
base::TimeDelta time_since_zero_brightness = brightness_is_zero_ ?
base::TimeDelta() : (base::TimeTicks::Now() - zero_brightness_end_time_);
const int kShortTimeMs = 10;
if (time_since_zero_brightness.InMilliseconds() <= kShortTimeMs)
return;
if (down) {
state_ = STATE_SUSPEND_ON_RELEASE;
timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kShowShutdownWarningTimeoutMs),
this,
&PowerButtonController::ShowShutdownWarningDialog);
} else {
if (state_ == STATE_SUSPEND_ON_RELEASE) {
chromeos::DBusThreadManager::Get()
->GetPowerManagerClient()
->RequestSuspend();
}
state_ = STATE_OTHER;
timer_.Stop();
shutdown_warning_message_.reset();
switch (state) {
case PRESSED:
state_ = STATE_SUSPEND_ON_RELEASE;
break;
case LONG_PRESSED:
ShowShutdownWarningDialog();
break;
case RELEASED:
if (state_ == STATE_SUSPEND_ON_RELEASE) {
chromeos::DBusThreadManager::Get()
->GetPowerManagerClient()
->RequestSuspend();
}
state_ = STATE_OTHER;
timer_.Stop();
shutdown_warning_message_.reset();
break;
}
}
......
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_
#define ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_
#ifndef ATHENA_SYSTEM_SHUTDOWN_DIALOG_H_
#define ATHENA_SYSTEM_SHUTDOWN_DIALOG_H_
#include "athena/input/public/input_manager.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chromeos/dbus/power_manager_client.h"
namespace aura {
class Window;
......@@ -21,10 +21,10 @@ class Widget;
namespace athena {
// Shuts down in response to the power button being pressed.
class PowerButtonController : public chromeos::PowerManagerClient::Observer {
class ShutdownDialog : public PowerButtonObserver {
public:
explicit PowerButtonController(aura::Window* dialog_container);
virtual ~PowerButtonController();
explicit ShutdownDialog(aura::Window* dialog_container);
virtual ~ShutdownDialog();
private:
enum State {
......@@ -47,11 +47,9 @@ class PowerButtonController : public chromeos::PowerManagerClient::Observer {
// Requests shutdown.
void Shutdown();
// chromeos::PowerManagerClient::Observer:
virtual void BrightnessChanged(int level, bool user_initiated) override;
virtual void PowerButtonEventReceived(
bool down,
const base::TimeTicks& timestamp) override;
// PowerButtonObserver:
virtual void OnPowerButtonStateChanged(
PowerButtonObserver::State state) override;
// |shutdown_warning_message_|'s parent container.
aura::Window* warning_message_container_;
......@@ -59,19 +57,13 @@ class PowerButtonController : public chromeos::PowerManagerClient::Observer {
// Shows a warning that the device is about to be shutdown.
scoped_ptr<views::Widget> shutdown_warning_message_;
// Whether the screen brightness was reduced to 0%.
bool brightness_is_zero_;
// The last time at which the screen brightness was 0%.
base::TimeTicks zero_brightness_end_time_;
State state_;
base::OneShotTimer<PowerButtonController> timer_;
base::OneShotTimer<ShutdownDialog> timer_;
DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
DISALLOW_COPY_AND_ASSIGN(ShutdownDialog);
};
} // namespace athena
#endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_
#endif // ATHENA_SYSTEM_SHUTDOWN_DIALOG_H_
......@@ -7,7 +7,7 @@
#include "athena/screen/public/screen_manager.h"
#include "athena/system/background_controller.h"
#include "athena/system/orientation_controller.h"
#include "athena/system/power_button_controller.h"
#include "athena/system/shutdown_dialog.h"
#include "athena/system/status_icon_container_view.h"
#include "athena/system/time_view.h"
#include "athena/util/container_priorities.h"
......@@ -106,8 +106,8 @@ class SystemUIImpl : public SystemUI {
// because it needs to show over the login screen.
// TODO(pkotwicz): Pick the most appropriate container based on whether the
// user has logged in.
power_button_controller_.reset(
new PowerButtonController(login_screen_system_modal_container_));
shutdown_dialog_.reset(
new ShutdownDialog(login_screen_system_modal_container_));
background_controller_.reset(
new BackgroundController(background_container_));
}
......@@ -122,7 +122,7 @@ class SystemUIImpl : public SystemUI {
private:
scoped_ptr<OrientationController> orientation_controller_;
scoped_ptr<PowerButtonController> power_button_controller_;
scoped_ptr<ShutdownDialog> shutdown_dialog_;
scoped_ptr<BackgroundController> background_controller_;
// The parent container for the background.
......
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