Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / ash / wm / power_button_controller.h
blob5d05e527466fb7539803a0085ae20a5677db27d2
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/accelerators/accelerator_controller.h"
9 #include "ash/accelerators/accelerator_table.h"
10 #include "ash/ash_export.h"
11 #include "ash/wm/session_state_animator.h"
12 #include "base/basictypes.h"
13 #include "ui/base/accelerators/accelerator.h"
14 #include "ui/events/event_handler.h"
16 #if defined(OS_CHROMEOS)
17 #include "ui/display/chromeos/display_configurator.h"
18 #endif
20 namespace gfx {
21 class Rect;
22 class Size;
25 namespace ui {
26 class Layer;
29 namespace ash {
31 namespace test {
32 class PowerButtonControllerTest;
35 class LockStateController;
37 // Handles power & lock button events which may result in the locking or
38 // shutting down of the system as well as taking screen shots while in maximize
39 // mode.
40 class ASH_EXPORT PowerButtonController : ui::EventHandler
41 // TODO(derat): Remove these ifdefs after DisplayConfigurator becomes
42 // cross-platform.
43 #if defined(OS_CHROMEOS)
44 , public ui::DisplayConfigurator::Observer
45 #endif
47 public:
48 explicit PowerButtonController(LockStateController* controller);
49 ~PowerButtonController() override;
51 void set_has_legacy_power_button_for_test(bool legacy) {
52 has_legacy_power_button_ = legacy;
55 void set_enable_quick_lock_for_test(bool enable_quick_lock) {
56 enable_quick_lock_ = enable_quick_lock;
59 // Called when the current screen brightness changes.
60 void OnScreenBrightnessChanged(double percent);
62 // Called when the power or lock buttons are pressed or released.
63 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
64 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp);
66 // ui::EventHandler:
67 void OnKeyEvent(ui::KeyEvent* event) override;
69 #if defined(OS_CHROMEOS)
70 // Overriden from ui::DisplayConfigurator::Observer:
71 void OnDisplayModeChanged(
72 const ui::DisplayConfigurator::DisplayStateList& outputs) override;
73 #endif
75 private:
76 friend class test::PowerButtonControllerTest;
78 // Are the power or lock buttons currently held?
79 bool power_button_down_;
80 bool lock_button_down_;
82 // True when the volume down button is being held down.
83 bool volume_down_pressed_;
85 // Has the screen brightness been reduced to 0%?
86 bool brightness_is_zero_;
88 // True if an internal display is off while an external display is on (e.g.
89 // for Chrome OS's docked mode, where a Chromebook's lid is closed while an
90 // external display is connected).
91 bool internal_display_off_and_external_display_on_;
93 // Was a command-line switch set telling us that we're running on hardware
94 // that misreports power button releases?
95 bool has_legacy_power_button_;
97 // Enables quick, non-cancellable locking of the screen when in maximize mode.
98 bool enable_quick_lock_;
100 LockStateController* controller_; // Not owned.
102 DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
105 } // namespace ash
107 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_