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_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 5 #ifndef ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... | |
31 class VolumeControlDelegate; | 31 class VolumeControlDelegate; |
32 | 32 |
33 // AcceleratorController provides functions for registering or unregistering | 33 // AcceleratorController provides functions for registering or unregistering |
34 // global keyboard accelerators, which are handled earlier than any windows. It | 34 // global keyboard accelerators, which are handled earlier than any windows. It |
35 // also implements several handlers as an accelerator target. | 35 // also implements several handlers as an accelerator target. |
36 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { | 36 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { |
37 public: | 37 public: |
38 AcceleratorController(); | 38 AcceleratorController(); |
39 virtual ~AcceleratorController(); | 39 virtual ~AcceleratorController(); |
40 | 40 |
41 // A list of possible ways in which an accelerator should be restricted before | |
42 // processing. | |
Finnur
2014/06/26 10:37:35
I think we should flesh out this comment a little
David Tseng
2014/06/27 00:49:11
It is a non-enforced restriction at the moment.
A
| |
43 enum AcceleratorProcessRestriction { | |
Finnur
2014/06/26 10:37:35
nit: Process is ambiguous. Processing?
David Tseng
2014/06/27 00:49:10
Yup :); getting wordy, but it does make more sense
| |
44 // Process the accelerator normally. | |
45 RESTRICTION_NONE, | |
46 | |
47 // Don't process the accelerator. | |
48 RESTRICTION_PREVENT_PROCESSING, | |
49 | |
50 // Don't process the accelerator and prevent propagation to other targets. | |
51 RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION | |
52 }; | |
53 | |
41 // Registers a global keyboard accelerator for the specified target. If | 54 // Registers a global keyboard accelerator for the specified target. If |
42 // multiple targets are registered for an accelerator, a target registered | 55 // multiple targets are registered for an accelerator, a target registered |
43 // later has higher priority. | 56 // later has higher priority. |
44 void Register(const ui::Accelerator& accelerator, | 57 void Register(const ui::Accelerator& accelerator, |
45 ui::AcceleratorTarget* target); | 58 ui::AcceleratorTarget* target); |
46 | 59 |
47 // Unregisters the specified keyboard accelerator for the specified target. | 60 // Unregisters the specified keyboard accelerator for the specified target. |
48 void Unregister(const ui::Accelerator& accelerator, | 61 void Unregister(const ui::Accelerator& accelerator, |
49 ui::AcceleratorTarget* target); | 62 ui::AcceleratorTarget* target); |
50 | 63 |
(...skipping 13 matching lines...) Expand all Loading... | |
64 | 77 |
65 // Returns true if the |accelerator| is one of the |reserved_actions_|. | 78 // Returns true if the |accelerator| is one of the |reserved_actions_|. |
66 bool IsReservedAccelerator(const ui::Accelerator& accelerator) const; | 79 bool IsReservedAccelerator(const ui::Accelerator& accelerator) const; |
67 | 80 |
68 // Performs the specified action. The |accelerator| may provide additional | 81 // Performs the specified action. The |accelerator| may provide additional |
69 // data the action needs. Returns whether an action was performed | 82 // data the action needs. Returns whether an action was performed |
70 // successfully. | 83 // successfully. |
71 bool PerformAction(int action, | 84 bool PerformAction(int action, |
72 const ui::Accelerator& accelerator); | 85 const ui::Accelerator& accelerator); |
73 | 86 |
87 // Gets any restriction for the given accelerator and action. | |
Finnur
2014/06/26 10:37:35
nit: "Returns which restriction applies to a given
David Tseng
2014/06/27 00:49:11
Done.
| |
88 AcceleratorProcessRestriction GetAcceleratorProcessRestriction( | |
Finnur
2014/06/26 10:37:35
ditto: Ambiguous word "Process".
David Tseng
2014/06/27 00:49:10
Done, everywhere.
| |
89 int action, | |
90 ui::Accelerator accelerator); | |
Finnur
2014/06/26 10:37:35
const ui::Accelerator& ?
David Tseng
2014/06/27 00:49:10
Done.
| |
91 | |
74 // Overridden from ui::AcceleratorTarget: | 92 // Overridden from ui::AcceleratorTarget: |
75 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 93 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
76 virtual bool CanHandleAccelerators() const OVERRIDE; | 94 virtual bool CanHandleAccelerators() const OVERRIDE; |
77 | 95 |
78 void SetBrightnessControlDelegate( | 96 void SetBrightnessControlDelegate( |
79 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); | 97 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); |
80 void SetImeControlDelegate( | 98 void SetImeControlDelegate( |
81 scoped_ptr<ImeControlDelegate> ime_control_delegate); | 99 scoped_ptr<ImeControlDelegate> ime_control_delegate); |
82 void SetScreenshotDelegate( | 100 void SetScreenshotDelegate( |
83 scoped_ptr<ScreenshotDelegate> screenshot_delegate); | 101 scoped_ptr<ScreenshotDelegate> screenshot_delegate); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 std::set<int> actions_allowed_in_app_mode_; | 167 std::set<int> actions_allowed_in_app_mode_; |
150 // Actions disallowed if there are no windows. | 168 // Actions disallowed if there are no windows. |
151 std::set<int> actions_needing_window_; | 169 std::set<int> actions_needing_window_; |
152 | 170 |
153 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 171 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
154 }; | 172 }; |
155 | 173 |
156 } // namespace ash | 174 } // namespace ash |
157 | 175 |
158 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 176 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |