Chromium Code Reviews| 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/shell_observer.h" | |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/tick_clock.h" | 14 #include "base/time/tick_clock.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 16 #include "chromeos/dbus/power_manager_client.h" | 17 #include "chromeos/dbus/power_manager_client.h" |
| 17 #include "ui/events/devices/input_device_event_observer.h" | 18 #include "ui/events/devices/input_device_event_observer.h" |
| 18 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 | 22 |
| 22 class LockStateController; | 23 class LockStateController; |
| 23 | 24 |
| 24 // Handles power button events on convertible/tablet device. This class is | 25 // Handles power button events on convertible/tablet device. This class is |
| 25 // instantiated and used in PowerButtonController. | 26 // instantiated and used in PowerButtonController. |
| 26 class ASH_EXPORT TabletPowerButtonController | 27 class ASH_EXPORT TabletPowerButtonController |
| 27 : public chromeos::PowerManagerClient::Observer, | 28 : public chromeos::PowerManagerClient::Observer, |
| 29 public ShellObserver, | |
| 28 public ui::EventHandler, | 30 public ui::EventHandler, |
| 29 public ui::InputDeviceEventObserver { | 31 public ui::InputDeviceEventObserver { |
| 30 public: | 32 public: |
| 31 // 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. |
| 32 class ASH_EXPORT TestApi { | 34 class ASH_EXPORT TestApi { |
| 33 public: | 35 public: |
| 34 explicit TestApi(TabletPowerButtonController* controller); | 36 explicit TestApi(TabletPowerButtonController* controller); |
| 35 ~TestApi(); | 37 ~TestApi(); |
| 36 | 38 |
| 37 // Returns true when |shutdown_timer_| is running. | 39 // Returns true when |shutdown_timer_| is running. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 54 bool ShouldHandlePowerButtonEvents() const; | 56 bool ShouldHandlePowerButtonEvents() const; |
| 55 | 57 |
| 56 // Handles a power button event. | 58 // Handles a power button event. |
| 57 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 59 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 58 | 60 |
| 59 // Overridden from chromeos::PowerManagerClient::Observer: | 61 // Overridden from chromeos::PowerManagerClient::Observer: |
| 60 void PowerManagerRestarted() override; | 62 void PowerManagerRestarted() override; |
| 61 void BrightnessChanged(int level, bool user_initiated) override; | 63 void BrightnessChanged(int level, bool user_initiated) override; |
| 62 void SuspendDone(const base::TimeDelta& sleep_duration) override; | 64 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 63 | 65 |
| 66 // Overridden from ShellObserver: | |
| 67 void OnLoginStateChanged(LoginStatus status) override; | |
|
Qiang(Joe) Xu
2016/11/30 22:09:11
This change is to fix the bug for this:
On user lo
| |
| 68 | |
| 64 // Overridden from ui::EventHandler: | 69 // Overridden from ui::EventHandler: |
| 65 void OnKeyEvent(ui::KeyEvent* event) override; | 70 void OnKeyEvent(ui::KeyEvent* event) override; |
| 66 void OnMouseEvent(ui::MouseEvent* event) override; | 71 void OnMouseEvent(ui::MouseEvent* event) override; |
| 67 | 72 |
| 68 // Overridden from ui::InputDeviceObserver: | 73 // Overridden from ui::InputDeviceObserver: |
| 69 void OnStylusStateChanged(ui::StylusState state) override; | 74 void OnStylusStateChanged(ui::StylusState state) override; |
| 70 | 75 |
| 71 // Overrides the tick clock used by |this| for testing. | 76 // Overrides the tick clock used by |this| for testing. |
| 72 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); | 77 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock); |
| 73 | 78 |
| 74 private: | 79 private: |
| 75 // Set backlights to |forced_off| if they aren't already. | 80 // Set backlights to |forced_off| and the corresponding enabled state of |
| 76 void SetBacklightsForcedOff(bool forced_off); | 81 // touchscreen if they aren't already. |
| 82 void SetDisplayForcedOff(bool forced_off); | |
| 77 | 83 |
| 78 // Sends a request to powerd to get the backlights forced off state so that | 84 // Sends a request to powerd to get the backlights forced off state so that |
| 79 // |backlights_forced_off_| can be initialized. | 85 // |backlights_forced_off_| can be initialized. |
| 80 void GetInitialBacklightsForcedOff(); | 86 void GetInitialBacklightsForcedOff(); |
| 81 | 87 |
| 82 // Initializes |backlights_forced_off_|. | 88 // Initializes |backlights_forced_off_|. |
| 83 void OnGotInitialBacklightsForcedOff(bool is_forced_off); | 89 void OnGotInitialBacklightsForcedOff(bool is_forced_off); |
| 84 | 90 |
| 85 // Starts |shutdown_timer_| when the power button is pressed while in | 91 // Starts |shutdown_timer_| when the power button is pressed while in |
| 86 // tablet mode. | 92 // tablet mode. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 116 LockStateController* controller_; // Not owned. | 122 LockStateController* controller_; // Not owned. |
| 117 | 123 |
| 118 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; | 124 base::WeakPtrFactory<TabletPowerButtonController> weak_ptr_factory_; |
| 119 | 125 |
| 120 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); | 126 DISALLOW_COPY_AND_ASSIGN(TabletPowerButtonController); |
| 121 }; | 127 }; |
| 122 | 128 |
| 123 } // namespace ash | 129 } // namespace ash |
| 124 | 130 |
| 125 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ | 131 #endif // ASH_SYSTEM_CHROMEOS_POWER_TABLET_POWER_BUTTON_CONTROLLER_H_ |
| OLD | NEW |