OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WM_POWER_BUTTON_CONTROLLER_H_ | 5 #ifndef ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "ui/events/event_handler.h" | 11 #include "ui/events/event_handler.h" |
12 | 12 |
13 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
14 #include "chromeos/dbus/power_manager_client.h" | 14 #include "chromeos/dbus/power_manager_client.h" |
15 #include "ui/display/chromeos/display_configurator.h" | 15 #include "ui/display/chromeos/display_configurator.h" |
16 #endif | 16 #endif |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class Rect; | 19 class Rect; |
20 class Size; | 20 class Size; |
21 } | 21 } |
22 | 22 |
23 namespace ui { | 23 namespace ui { |
24 class Layer; | 24 class Layer; |
25 } | 25 } |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 | 28 |
| 29 class LockStateController; |
| 30 #if defined(OS_CHROMEOS) |
| 31 class TabletPowerButtonController; |
| 32 #endif |
| 33 |
29 namespace test { | 34 namespace test { |
30 class PowerButtonControllerTest; | 35 class TabletPowerButtonControllerTest; |
31 } | 36 } |
32 | 37 |
33 class LockStateController; | |
34 | |
35 // Handles power & lock button events which may result in the locking or | 38 // Handles power & lock button events which may result in the locking or |
36 // shutting down of the system as well as taking screen shots while in maximize | 39 // shutting down of the system as well as taking screen shots while in maximize |
37 // mode. | 40 // mode. |
38 class ASH_EXPORT PowerButtonController | 41 class ASH_EXPORT PowerButtonController |
39 : public ui::EventHandler | 42 : public ui::EventHandler |
40 // TODO(derat): Remove these ifdefs after DisplayConfigurator becomes | 43 // TODO(derat): Remove these ifdefs after DisplayConfigurator becomes |
41 // cross-platform. | 44 // cross-platform. |
42 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
43 , | 46 , |
44 public ui::DisplayConfigurator::Observer, | 47 public ui::DisplayConfigurator::Observer, |
(...skipping 26 matching lines...) Expand all Loading... |
71 // Overriden from ui::DisplayConfigurator::Observer: | 74 // Overriden from ui::DisplayConfigurator::Observer: |
72 void OnDisplayModeChanged( | 75 void OnDisplayModeChanged( |
73 const ui::DisplayConfigurator::DisplayStateList& outputs) override; | 76 const ui::DisplayConfigurator::DisplayStateList& outputs) override; |
74 | 77 |
75 // Overridden from chromeos::PowerManagerClient::Observer: | 78 // Overridden from chromeos::PowerManagerClient::Observer: |
76 void PowerButtonEventReceived(bool down, | 79 void PowerButtonEventReceived(bool down, |
77 const base::TimeTicks& timestamp) override; | 80 const base::TimeTicks& timestamp) override; |
78 #endif | 81 #endif |
79 | 82 |
80 private: | 83 private: |
81 friend class test::PowerButtonControllerTest; | 84 friend class test::TabletPowerButtonControllerTest; |
82 | 85 |
83 // Are the power or lock buttons currently held? | 86 // Are the power or lock buttons currently held? |
84 bool power_button_down_; | 87 bool power_button_down_; |
85 bool lock_button_down_; | 88 bool lock_button_down_; |
86 | 89 |
87 // True when the volume down button is being held down. | 90 // True when the volume down button is being held down. |
88 bool volume_down_pressed_; | 91 bool volume_down_pressed_; |
89 | 92 |
90 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
91 // Volume to be restored after a screenshot is taken by pressing the power | 94 // Volume to be restored after a screenshot is taken by pressing the power |
(...skipping 11 matching lines...) Expand all Loading... |
103 | 106 |
104 // Was a command-line switch set telling us that we're running on hardware | 107 // Was a command-line switch set telling us that we're running on hardware |
105 // that misreports power button releases? | 108 // that misreports power button releases? |
106 bool has_legacy_power_button_; | 109 bool has_legacy_power_button_; |
107 | 110 |
108 // Enables quick, non-cancellable locking of the screen when in maximize mode. | 111 // Enables quick, non-cancellable locking of the screen when in maximize mode. |
109 bool enable_quick_lock_; | 112 bool enable_quick_lock_; |
110 | 113 |
111 LockStateController* controller_; // Not owned. | 114 LockStateController* controller_; // Not owned. |
112 | 115 |
| 116 #if defined(OS_CHROMEOS) |
| 117 // When device is convertible/tablet, pass the OnPowerButtonEvent to |
| 118 // |tablet_controller_| when it should be handled there. |
| 119 std::unique_ptr<TabletPowerButtonController> tablet_controller_; |
| 120 #endif |
| 121 |
113 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | 122 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
114 }; | 123 }; |
115 | 124 |
116 } // namespace ash | 125 } // namespace ash |
117 | 126 |
118 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 127 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
OLD | NEW |