chromeos: Honor power button when in docked mode.
[chromium-blink-merge.git] / ash / wm / power_button_controller.h
blob5c7de09d1ecd6ff68f3da49d90d4ff4a3622a1dc
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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_POWER_BUTTON_CONTROLLER_H_
6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "ash/wm/session_state_animator.h"
10 #include "base/basictypes.h"
12 #if defined(OS_CHROMEOS) && defined(USE_X11)
13 #include "chromeos/display/output_configurator.h"
14 #endif
16 namespace gfx {
17 class Rect;
18 class Size;
21 namespace ui {
22 class Layer;
25 namespace ash {
27 namespace test {
28 class PowerButtonControllerTest;
31 class LockStateController;
33 // Displays onscreen animations and locks or suspends the system in response to
34 // the power button being pressed or released.
35 class ASH_EXPORT PowerButtonController
36 // TODO(derat): Remove these ifdefs after OutputConfigurator becomes
37 // cross-platform.
38 #if defined(OS_CHROMEOS) && defined(USE_X11)
39 : public chromeos::OutputConfigurator::Observer
40 #endif
42 public:
43 explicit PowerButtonController(LockStateController* controller);
44 virtual ~PowerButtonController();
46 void set_has_legacy_power_button_for_test(bool legacy) {
47 has_legacy_power_button_ = legacy;
50 // Called when the current screen brightness changes.
51 void OnScreenBrightnessChanged(double percent);
53 // Called when the power or lock buttons are pressed or released.
54 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
55 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp);
57 #if defined(OS_CHROMEOS) && defined(USE_X11)
58 // Overriden from chromeos::OutputConfigurator::Observer:
59 virtual void OnDisplayModeChanged(
60 const std::vector<chromeos::OutputConfigurator::OutputSnapshot>& outputs)
61 OVERRIDE;
62 #endif
64 private:
65 friend class test::PowerButtonControllerTest;
67 // Are the power or lock buttons currently held?
68 bool power_button_down_;
69 bool lock_button_down_;
71 // Has the screen brightness been reduced to 0%?
72 bool brightness_is_zero_;
74 // True if an internal display is off while an external display is on (e.g.
75 // for Chrome OS's docked mode, where a Chromebook's lid is closed while an
76 // external display is connected).
77 bool internal_display_off_and_external_display_on_;
79 // Was a command-line switch set telling us that we're running on hardware
80 // that misreports power button releases?
81 bool has_legacy_power_button_;
83 LockStateController* controller_; // Not owned.
85 DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
88 } // namespace ash
90 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_