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

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

Issue 326813004: Added quick lock mechanism while in Touchview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ASH_EXPORT to SessionStateAnimator Created 6 years, 3 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
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 "ash/accelerators/accelerator_controller.h"
9 #include "ash/accelerators/accelerator_table.h"
8 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
9 #include "ash/wm/session_state_animator.h" 11 #include "ash/wm/session_state_animator.h"
10 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "ui/base/accelerators/accelerator.h"
14 #include "ui/events/event_handler.h"
11 15
12 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
13 #include "ui/display/chromeos/display_configurator.h" 17 #include "ui/display/chromeos/display_configurator.h"
14 #endif 18 #endif
15 19
16 namespace gfx { 20 namespace gfx {
17 class Rect; 21 class Rect;
18 class Size; 22 class Size;
19 } 23 }
20 24
21 namespace ui { 25 namespace ui {
22 class Layer; 26 class Layer;
23 } 27 }
24 28
25 namespace ash { 29 namespace ash {
26 30
27 namespace test { 31 namespace test {
28 class PowerButtonControllerTest; 32 class PowerButtonControllerTest;
29 } 33 }
30 34
31 class LockStateController; 35 class LockStateController;
32 36
33 // Displays onscreen animations and locks or suspends the system in response to 37 // Handles power & lock button events which may result in the locking or
34 // the power button being pressed or released. 38 // shutting down of the system as well as taking screen shots while in maximize
35 class ASH_EXPORT PowerButtonController 39 // mode.
40 class ASH_EXPORT PowerButtonController : ui::EventHandler
36 // TODO(derat): Remove these ifdefs after DisplayConfigurator becomes 41 // TODO(derat): Remove these ifdefs after DisplayConfigurator becomes
37 // cross-platform. 42 // cross-platform.
38 #if defined(OS_CHROMEOS) 43 #if defined(OS_CHROMEOS)
39 : public ui::DisplayConfigurator::Observer 44 , public ui::DisplayConfigurator::Observer
40 #endif 45 #endif
41 { 46 {
42 public: 47 public:
43 explicit PowerButtonController(LockStateController* controller); 48 explicit PowerButtonController(LockStateController* controller);
44 virtual ~PowerButtonController(); 49 virtual ~PowerButtonController();
45 50
46 void set_has_legacy_power_button_for_test(bool legacy) { 51 void set_has_legacy_power_button_for_test(bool legacy) {
47 has_legacy_power_button_ = legacy; 52 has_legacy_power_button_ = legacy;
48 } 53 }
49 54
55 void set_enable_quick_lock_for_test(bool enable_quick_lock) {
56 enable_quick_lock_ = enable_quick_lock;
57 }
58
50 // Called when the current screen brightness changes. 59 // Called when the current screen brightness changes.
51 void OnScreenBrightnessChanged(double percent); 60 void OnScreenBrightnessChanged(double percent);
52 61
53 // Called when the power or lock buttons are pressed or released. 62 // Called when the power or lock buttons are pressed or released.
54 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); 63 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
55 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp); 64 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp);
56 65
66 // ui::EventHandler:
67 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
68
57 #if defined(OS_CHROMEOS) 69 #if defined(OS_CHROMEOS)
58 // Overriden from ui::DisplayConfigurator::Observer: 70 // Overriden from ui::DisplayConfigurator::Observer:
59 virtual void OnDisplayModeChanged( 71 virtual void OnDisplayModeChanged(
60 const ui::DisplayConfigurator::DisplayStateList& outputs) OVERRIDE; 72 const ui::DisplayConfigurator::DisplayStateList& outputs) OVERRIDE;
61 #endif 73 #endif
62 74
63 private: 75 private:
64 friend class test::PowerButtonControllerTest; 76 friend class test::PowerButtonControllerTest;
65 77
66 // Are the power or lock buttons currently held? 78 // Are the power or lock buttons currently held?
67 bool power_button_down_; 79 bool power_button_down_;
68 bool lock_button_down_; 80 bool lock_button_down_;
69 81
82 // True when the volume down button is being held down.
83 bool volume_down_pressed_;
84
70 // Has the screen brightness been reduced to 0%? 85 // Has the screen brightness been reduced to 0%?
71 bool brightness_is_zero_; 86 bool brightness_is_zero_;
72 87
73 // True if an internal display is off while an external display is on (e.g. 88 // True if an internal display is off while an external display is on (e.g.
74 // for Chrome OS's docked mode, where a Chromebook's lid is closed while an 89 // for Chrome OS's docked mode, where a Chromebook's lid is closed while an
75 // external display is connected). 90 // external display is connected).
76 bool internal_display_off_and_external_display_on_; 91 bool internal_display_off_and_external_display_on_;
77 92
78 // Was a command-line switch set telling us that we're running on hardware 93 // Was a command-line switch set telling us that we're running on hardware
79 // that misreports power button releases? 94 // that misreports power button releases?
80 bool has_legacy_power_button_; 95 bool has_legacy_power_button_;
81 96
82 LockStateController* controller_; // Not owned. 97 // Enables quick, non-cancellable locking of the screen when in maximize mode.
98 bool enable_quick_lock_;
99
100 LockStateController* controller_; // Not owned.
83 101
84 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); 102 DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
85 }; 103 };
86 104
87 } // namespace ash 105 } // namespace ash
88 106
89 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ 107 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller_unittest.cc ('k') | ash/wm/power_button_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698