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