| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| 6 #define ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 6 #define ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/common/shell_observer.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/time/tick_clock.h" | 14 #include "base/time/tick_clock.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "chromeos/dbus/power_manager_client.h" | 17 #include "chromeos/dbus/power_manager_client.h" |
| 18 #include "ui/events/devices/input_device_event_observer.h" | 18 #include "ui/events/devices/input_device_event_observer.h" |
| 19 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 class LockStateController; | 23 class LockStateController; |
| 24 | 24 |
| 25 // Handles power button events on convertible/tablet device. This class is | 25 // Handles power button events on convertible/tablet device. This class is |
| 26 // instantiated and used in PowerButtonController. | 26 // instantiated and used in PowerButtonController. |
| 27 class ASH_EXPORT TabletPowerButtonController | 27 class ASH_EXPORT TabletPowerButtonController |
| 28 : public chromeos::PowerManagerClient::Observer, | 28 : public chromeos::PowerManagerClient::Observer, |
| 29 public MaximizeModeController::Observer, | 29 public ShellObserver, |
| 30 public ui::EventHandler, | 30 public ui::EventHandler, |
| 31 public ui::InputDeviceEventObserver { | 31 public ui::InputDeviceEventObserver { |
| 32 public: | 32 public: |
| 33 // Helper class used by tablet power button tests to access internal state. | 33 // Helper class used by tablet power button tests to access internal state. |
| 34 class ASH_EXPORT TestApi { | 34 class ASH_EXPORT TestApi { |
| 35 public: | 35 public: |
| 36 explicit TestApi(TabletPowerButtonController* controller); | 36 explicit TestApi(TabletPowerButtonController* controller); |
| 37 ~TestApi(); | 37 ~TestApi(); |
| 38 | 38 |
| 39 // Returns true when |shutdown_timer_| is running. | 39 // Returns true when |shutdown_timer_| is running. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 bool ShouldHandlePowerButtonEvents() const; | 56 bool ShouldHandlePowerButtonEvents() const; |
| 57 | 57 |
| 58 // Handles a power button event. | 58 // Handles a power button event. |
| 59 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 59 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 60 | 60 |
| 61 // Overridden from chromeos::PowerManagerClient::Observer: | 61 // Overridden from chromeos::PowerManagerClient::Observer: |
| 62 void PowerManagerRestarted() override; | 62 void PowerManagerRestarted() override; |
| 63 void BrightnessChanged(int level, bool user_initiated) override; | 63 void BrightnessChanged(int level, bool user_initiated) override; |
| 64 void SuspendDone(const base::TimeDelta& sleep_duration) override; | 64 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 65 | 65 |
| 66 // Overridden from MaximizeModeController::Observer: | 66 // Overridden from ShellObserver: |
| 67 void OnEnterMaximizeMode() override; | 67 void OnMaximizeModeStarted() override; |
| 68 void OnLeaveMaximizeMode() override; | 68 void OnMaximizeModeEnded() override; |
| 69 | 69 |
| 70 // Overridden from ui::EventHandler: | 70 // Overridden from ui::EventHandler: |
| 71 void OnKeyEvent(ui::KeyEvent* event) override; | 71 void OnKeyEvent(ui::KeyEvent* event) override; |
| 72 void OnMouseEvent(ui::MouseEvent* event) override; | 72 void OnMouseEvent(ui::MouseEvent* event) override; |
| 73 | 73 |
| 74 // Overridden from ui::InputDeviceObserver: | 74 // Overridden from ui::InputDeviceObserver: |
| 75 void OnStylusStateChanged(ui::StylusState state) override; | 75 void OnStylusStateChanged(ui::StylusState state) override; |
| 76 | 76 |
| 77 // Overrides the tick clock used by |this| for testing. | 77 // Overrides the tick clock used by |this| for testing. |
| 78 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 78 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 LockStateController* controller_; // Not owned. | 127 LockStateController* controller_; // Not owned. |
| 128 | 128 |
| 129 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; | 129 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); | 131 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace ash | 134 } // namespace ash |
| 135 | 135 |
| 136 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 136 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| OLD | NEW |