Chromium Code Reviews| Index: ash/wm/power_button_controller.h |
| diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h |
| index 7043966f92a9d439ef664804e47343fab0d6804c..29f7c28515e9f7466dadd53aa759d38ccdbf7523 100644 |
| --- a/ash/wm/power_button_controller.h |
| +++ b/ash/wm/power_button_controller.h |
| @@ -8,6 +8,7 @@ |
| #include "ash/ash_export.h" |
| #include "base/macros.h" |
| #include "base/time/time.h" |
| +#include "base/timer/timer.h" |
| #include "ui/events/event_handler.h" |
| #if defined(OS_CHROMEOS) |
| @@ -26,10 +27,6 @@ class Layer; |
| namespace ash { |
| -namespace test { |
| -class PowerButtonControllerTest; |
| -} |
| - |
| class LockStateController; |
| // Handles power & lock button events which may result in the locking or |
| @@ -46,6 +43,22 @@ class ASH_EXPORT PowerButtonController |
| #endif |
| { |
| public: |
| + // Helper class used by tablet power button tests to access internal state. |
| + class ASH_EXPORT TestApi { |
| + public: |
| + explicit TestApi(PowerButtonController* controller); |
| + virtual ~TestApi(); |
| + |
| + bool TabletPowerButtonTimerIsRunning() const; |
|
Daniel Erat
2016/11/04 20:18:34
nit: add comments to both of these documenting wha
Qiang(Joe) Xu
2016/11/04 23:18:21
Done.
|
| + |
| + void TriggerTabletPowerButtonTimeout(); |
| + |
| + private: |
| + PowerButtonController* controller_; // Not owned. |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestApi); |
| + }; |
| + |
| explicit PowerButtonController(LockStateController* controller); |
| ~PowerButtonController() override; |
| @@ -66,6 +79,7 @@ class ASH_EXPORT PowerButtonController |
| // ui::EventHandler: |
| void OnKeyEvent(ui::KeyEvent* event) override; |
| + void OnMouseEvent(ui::MouseEvent* event) override; |
| #if defined(OS_CHROMEOS) |
| // Overriden from ui::DisplayConfigurator::Observer: |
| @@ -78,7 +92,37 @@ class ASH_EXPORT PowerButtonController |
| #endif |
| private: |
| - friend class test::PowerButtonControllerTest; |
| + // Called by OnPowerButtonEvent on convertible/tablet devices. |
| + void OnTabletPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| + |
| + // Set backlights to |forced_off| if needed. |
| + void SetBacklightsForcedOff(bool forced_off); |
| + |
| + // Sends a request to powerd to get the backlights forced off state so that |
| + // |backlights_forced_off_| can be initialized. |
| + void GetInitialBacklightsForcedOff(); |
| + |
| + // Initializes |backlights_forced_off_|. |
| + void OnGotInitialBacklightsForcedOff(bool is_forced_off); |
| + |
| + // Starts |tablet_power_button_timer_| when the power button is pressed while |
| + // in tablet mode. |
| + void StartTabletPowerButtonTimer(); |
| + |
| + // Called by |tablet_power_button_timer_| to start the pre-shutdown animation. |
| + void OnTabletPowerButtonTimeout(); |
| + |
| + // Locks the screen if the "require password to wake from sleep" pref is set |
| + // and locking is possible. |
| + void LockScreenIfRequired(); |
| + |
| + // Returns true if device is a convertible/tablet device or has |
| + // kAshEnableTouchViewTesting in test, otherwise false. |
| + bool IsTabletModeSupported() const; |
| + |
| + // Returns true if device is currently in tablet/maximize mode, otherwise |
| + // false. |
| + bool IsTabletModeActive() const; |
| // Are the power or lock buttons currently held? |
| bool power_button_down_; |
| @@ -110,6 +154,16 @@ class ASH_EXPORT PowerButtonController |
| LockStateController* controller_; // Not owned. |
| + // True if the screen was off when the power button was pressed. |
| + bool power_button_down_while_screen_off_; |
| + |
| + // Current forced-off state of backlights. |
| + bool backlights_forced_off_; |
| + |
| + // Started when the tablet power button is pressed and stopped when it's |
| + // released. Runs OnTabletPowerButtonTimeout() to start shutdown. |
| + base::OneShotTimer tablet_power_button_timer_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
| }; |