Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: ash/wm/power_button_controller.h

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/panels/panel_window_resizer_unittest.cc ('k') | ash/wm/power_button_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "ui/events/event_handler.h"
14
15 #if defined(OS_CHROMEOS)
16 #include "chromeos/dbus/power_manager_client.h" 13 #include "chromeos/dbus/power_manager_client.h"
17 #include "ui/display/manager/chromeos/display_configurator.h" 14 #include "ui/display/manager/chromeos/display_configurator.h"
18 #endif 15 #include "ui/events/event_handler.h"
19 16
20 namespace ash { 17 namespace ash {
21 18
22 class LockStateController; 19 class LockStateController;
23 #if defined(OS_CHROMEOS)
24 class TabletPowerButtonController; 20 class TabletPowerButtonController;
25 #endif
26 21
27 // Handles power & lock button events which may result in the locking or 22 // Handles power & lock button events which may result in the locking or
28 // shutting down of the system as well as taking screen shots while in maximize 23 // shutting down of the system as well as taking screen shots while in maximize
29 // mode. 24 // mode.
30 class ASH_EXPORT PowerButtonController 25 class ASH_EXPORT PowerButtonController
31 : public ui::EventHandler 26 : public ui::EventHandler,
32 // TODO(derat): Remove these ifdefs after DisplayConfigurator becomes
33 // cross-platform.
34 #if defined(OS_CHROMEOS)
35 ,
36 public display::DisplayConfigurator::Observer, 27 public display::DisplayConfigurator::Observer,
37 public chromeos::PowerManagerClient::Observer 28 public chromeos::PowerManagerClient::Observer {
38 #endif
39 {
40 public: 29 public:
41 explicit PowerButtonController(LockStateController* controller); 30 explicit PowerButtonController(LockStateController* controller);
42 ~PowerButtonController() override; 31 ~PowerButtonController() override;
43 32
44 void set_has_legacy_power_button_for_test(bool legacy) { 33 void set_has_legacy_power_button_for_test(bool legacy) {
45 has_legacy_power_button_ = legacy; 34 has_legacy_power_button_ = legacy;
46 } 35 }
47 36
48 // Called when the current screen brightness changes. 37 // Called when the current screen brightness changes.
49 void OnScreenBrightnessChanged(double percent); 38 void OnScreenBrightnessChanged(double percent);
50 39
51 // Called when the power or lock buttons are pressed or released. 40 // Called when the power or lock buttons are pressed or released.
52 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); 41 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
53 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp); 42 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp);
54 43
55 // ui::EventHandler: 44 // ui::EventHandler:
56 void OnKeyEvent(ui::KeyEvent* event) override; 45 void OnKeyEvent(ui::KeyEvent* event) override;
57 46
58 #if defined(OS_CHROMEOS)
59 // Overriden from display::DisplayConfigurator::Observer: 47 // Overriden from display::DisplayConfigurator::Observer:
60 void OnDisplayModeChanged( 48 void OnDisplayModeChanged(
61 const display::DisplayConfigurator::DisplayStateList& outputs) override; 49 const display::DisplayConfigurator::DisplayStateList& outputs) override;
62 50
63 // Overridden from chromeos::PowerManagerClient::Observer: 51 // Overridden from chromeos::PowerManagerClient::Observer:
64 void PowerButtonEventReceived(bool down, 52 void PowerButtonEventReceived(bool down,
65 const base::TimeTicks& timestamp) override; 53 const base::TimeTicks& timestamp) override;
66 54
67 TabletPowerButtonController* tablet_power_button_controller_for_test() { 55 TabletPowerButtonController* tablet_power_button_controller_for_test() {
68 return tablet_controller_.get(); 56 return tablet_controller_.get();
69 } 57 }
70 #endif
71 58
72 private: 59 private:
73 // Are the power or lock buttons currently held? 60 // Are the power or lock buttons currently held?
74 bool power_button_down_; 61 bool power_button_down_;
75 bool lock_button_down_; 62 bool lock_button_down_;
76 63
77 // True when the volume down button is being held down. 64 // True when the volume down button is being held down.
78 bool volume_down_pressed_; 65 bool volume_down_pressed_;
79 66
80 #if defined(OS_CHROMEOS)
81 // Volume to be restored after a screenshot is taken by pressing the power 67 // Volume to be restored after a screenshot is taken by pressing the power
82 // button while holding VKEY_VOLUME_DOWN. 68 // button while holding VKEY_VOLUME_DOWN.
83 int volume_percent_before_screenshot_; 69 int volume_percent_before_screenshot_;
84 #endif
85 70
86 // Has the screen brightness been reduced to 0%? 71 // Has the screen brightness been reduced to 0%?
87 bool brightness_is_zero_; 72 bool brightness_is_zero_;
88 73
89 // True if an internal display is off while an external display is on (e.g. 74 // True if an internal display is off while an external display is on (e.g.
90 // for Chrome OS's docked mode, where a Chromebook's lid is closed while an 75 // for Chrome OS's docked mode, where a Chromebook's lid is closed while an
91 // external display is connected). 76 // external display is connected).
92 bool internal_display_off_and_external_display_on_; 77 bool internal_display_off_and_external_display_on_;
93 78
94 // Was a command-line switch set telling us that we're running on hardware 79 // Was a command-line switch set telling us that we're running on hardware
95 // that misreports power button releases? 80 // that misreports power button releases?
96 bool has_legacy_power_button_; 81 bool has_legacy_power_button_;
97 82
98 LockStateController* lock_state_controller_; // Not owned. 83 LockStateController* lock_state_controller_; // Not owned.
99 84
100 #if defined(OS_CHROMEOS)
101 // Handles events for convertible/tablet devices. 85 // Handles events for convertible/tablet devices.
102 std::unique_ptr<TabletPowerButtonController> tablet_controller_; 86 std::unique_ptr<TabletPowerButtonController> tablet_controller_;
103 #endif
104 87
105 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); 88 DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
106 }; 89 };
107 90
108 } // namespace ash 91 } // namespace ash
109 92
110 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ 93 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_resizer_unittest.cc ('k') | ash/wm/power_button_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698