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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace ui { | 26 namespace ui { |
27 class AcceleratorManager; | 27 class AcceleratorManager; |
28 class AcceleratorManagerDelegate; | 28 class AcceleratorManagerDelegate; |
29 } | 29 } |
30 | 30 |
31 namespace ash { | 31 namespace ash { |
32 | 32 |
33 struct AcceleratorData; | 33 struct AcceleratorData; |
34 class AcceleratorControllerDelegate; | 34 class AcceleratorControllerDelegate; |
35 class ExitWarningHandler; | 35 class ExitWarningHandler; |
36 class ImeControlDelegate; | |
37 | 36 |
38 // AcceleratorController provides functions for registering or unregistering | 37 // AcceleratorController provides functions for registering or unregistering |
39 // global keyboard accelerators, which are handled earlier than any windows. It | 38 // global keyboard accelerators, which are handled earlier than any windows. It |
40 // also implements several handlers as an accelerator target. | 39 // also implements several handlers as an accelerator target. |
41 class ASH_EXPORT AcceleratorController | 40 class ASH_EXPORT AcceleratorController |
42 : public ui::AcceleratorTarget, | 41 : public ui::AcceleratorTarget, |
43 NON_EXPORTED_BASE(public mojom::AcceleratorController) { | 42 NON_EXPORTED_BASE(public mojom::AcceleratorController) { |
44 public: | 43 public: |
45 AcceleratorController(AcceleratorControllerDelegate* delegate, | 44 AcceleratorController(AcceleratorControllerDelegate* delegate, |
46 ui::AcceleratorManagerDelegate* manager_delegate); | 45 ui::AcceleratorManagerDelegate* manager_delegate); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // can be consumed by web contents if needed. | 100 // can be consumed by web contents if needed. |
102 bool IsDeprecated(const ui::Accelerator& accelerator) const; | 101 bool IsDeprecated(const ui::Accelerator& accelerator) const; |
103 | 102 |
104 // Performs the specified action if it is enabled. Returns whether the action | 103 // Performs the specified action if it is enabled. Returns whether the action |
105 // was performed successfully. | 104 // was performed successfully. |
106 bool PerformActionIfEnabled(AcceleratorAction action); | 105 bool PerformActionIfEnabled(AcceleratorAction action); |
107 | 106 |
108 // Returns the restriction for the current context. | 107 // Returns the restriction for the current context. |
109 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); | 108 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); |
110 | 109 |
111 void SetImeControlDelegate( | |
112 std::unique_ptr<ImeControlDelegate> ime_control_delegate); | |
113 | |
114 // Provides access to the ExitWarningHandler for testing. | 110 // Provides access to the ExitWarningHandler for testing. |
115 ExitWarningHandler* GetExitWarningHandlerForTest() { | 111 ExitWarningHandler* GetExitWarningHandlerForTest() { |
116 return &exit_warning_handler_; | 112 return &exit_warning_handler_; |
117 } | 113 } |
118 | 114 |
119 // Returns true if the menu should close in order to perform the accelerator. | 115 // Returns true if the menu should close in order to perform the accelerator. |
120 bool ShouldCloseMenuAndRepostAccelerator( | 116 bool ShouldCloseMenuAndRepostAccelerator( |
121 const ui::Accelerator& accelerator) const; | 117 const ui::Accelerator& accelerator) const; |
122 | 118 |
123 ui::AcceleratorHistory* accelerator_history() { | 119 ui::AcceleratorHistory* accelerator_history() { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 AcceleratorAction action, | 176 AcceleratorAction action, |
181 const ui::Accelerator& accelerator) const; | 177 const ui::Accelerator& accelerator) const; |
182 | 178 |
183 AcceleratorControllerDelegate* delegate_; | 179 AcceleratorControllerDelegate* delegate_; |
184 | 180 |
185 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; | 181 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; |
186 | 182 |
187 // A tracker for the current and previous accelerators. | 183 // A tracker for the current and previous accelerators. |
188 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; | 184 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; |
189 | 185 |
190 std::unique_ptr<ImeControlDelegate> ime_control_delegate_; | |
191 | |
192 // Handles the exit accelerator which requires a double press to exit and | 186 // Handles the exit accelerator which requires a double press to exit and |
193 // shows a popup with an explanation. | 187 // shows a popup with an explanation. |
194 ExitWarningHandler exit_warning_handler_; | 188 ExitWarningHandler exit_warning_handler_; |
195 | 189 |
196 // A map from accelerators to the AcceleratorAction values, which are used in | 190 // A map from accelerators to the AcceleratorAction values, which are used in |
197 // the implementation. | 191 // the implementation. |
198 std::map<ui::Accelerator, AcceleratorAction> accelerators_; | 192 std::map<ui::Accelerator, AcceleratorAction> accelerators_; |
199 | 193 |
200 std::map<AcceleratorAction, const DeprecatedAcceleratorData*> | 194 std::map<AcceleratorAction, const DeprecatedAcceleratorData*> |
201 actions_with_deprecations_; | 195 actions_with_deprecations_; |
(...skipping 26 matching lines...) Expand all Loading... |
228 std::set<int> actions_needing_window_; | 222 std::set<int> actions_needing_window_; |
229 // Actions that can be performed without closing the menu (if one is present). | 223 // Actions that can be performed without closing the menu (if one is present). |
230 std::set<int> actions_keeping_menu_open_; | 224 std::set<int> actions_keeping_menu_open_; |
231 | 225 |
232 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 226 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
233 }; | 227 }; |
234 | 228 |
235 } // namespace ash | 229 } // namespace ash |
236 | 230 |
237 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 231 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |