Chromium Code Reviews| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 | 13 |
| 14 #include "ash/accelerators/accelerator_table.h" | 14 #include "ash/accelerators/accelerator_table.h" |
| 15 #include "ash/accelerators/exit_warning_handler.h" | 15 #include "ash/accelerators/exit_warning_handler.h" |
| 16 #include "ash/ash_export.h" | 16 #include "ash/ash_export.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "ui/base/accelerators/accelerator.h" | 20 #include "ui/base/accelerators/accelerator.h" |
| 21 #include "ui/base/accelerators/accelerator_history.h" | 21 #include "ui/base/accelerators/accelerator_history.h" |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 class AcceleratorManager; | 24 class AcceleratorManager; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 | 28 |
| 29 struct AcceleratorData; | 29 struct AcceleratorData; |
| 30 class BrightnessControlDelegate; | |
| 31 class ExitWarningHandler; | 30 class ExitWarningHandler; |
| 32 class ImeControlDelegate; | 31 class ImeControlDelegate; |
| 33 class KeyboardBrightnessControlDelegate; | 32 class KeyboardBrightnessControlDelegate; |
| 34 class ScreenshotDelegate; | 33 class ScreenshotDelegate; |
| 35 class VolumeControlDelegate; | 34 class VolumeControlDelegate; |
| 36 | 35 |
| 37 // AcceleratorController provides functions for registering or unregistering | 36 // AcceleratorController provides functions for registering or unregistering |
| 38 // global keyboard accelerators, which are handled earlier than any windows. It | 37 // global keyboard accelerators, which are handled earlier than any windows. It |
| 39 // also implements several handlers as an accelerator target. | 38 // also implements several handlers as an accelerator target. |
| 40 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { | 39 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 // can be consumed by web contents if needed. | 93 // can be consumed by web contents if needed. |
| 95 bool IsDeprecated(const ui::Accelerator& accelerator) const; | 94 bool IsDeprecated(const ui::Accelerator& accelerator) const; |
| 96 | 95 |
| 97 // Performs the specified action if it is enabled. Returns whether the action | 96 // Performs the specified action if it is enabled. Returns whether the action |
| 98 // was performed successfully. | 97 // was performed successfully. |
| 99 bool PerformActionIfEnabled(AcceleratorAction action); | 98 bool PerformActionIfEnabled(AcceleratorAction action); |
| 100 | 99 |
| 101 // Returns the restriction for the current context. | 100 // Returns the restriction for the current context. |
| 102 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); | 101 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); |
| 103 | 102 |
| 104 void SetBrightnessControlDelegate( | |
| 105 std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate); | |
| 106 void SetImeControlDelegate( | 103 void SetImeControlDelegate( |
| 107 std::unique_ptr<ImeControlDelegate> ime_control_delegate); | 104 std::unique_ptr<ImeControlDelegate> ime_control_delegate); |
| 108 void SetScreenshotDelegate( | 105 void SetScreenshotDelegate( |
| 109 std::unique_ptr<ScreenshotDelegate> screenshot_delegate); | 106 std::unique_ptr<ScreenshotDelegate> screenshot_delegate); |
| 110 BrightnessControlDelegate* brightness_control_delegate() const { | |
| 111 return brightness_control_delegate_.get(); | |
| 112 } | |
| 113 ScreenshotDelegate* screenshot_delegate() { | 107 ScreenshotDelegate* screenshot_delegate() { |
| 114 return screenshot_delegate_.get(); | 108 return screenshot_delegate_.get(); |
| 115 } | 109 } |
| 116 | 110 |
| 117 // Provides access to the ExitWarningHandler for testing. | 111 // Provides access to the ExitWarningHandler for testing. |
| 118 ExitWarningHandler* GetExitWarningHandlerForTest() { | 112 ExitWarningHandler* GetExitWarningHandlerForTest() { |
| 119 return &exit_warning_handler_; | 113 return &exit_warning_handler_; |
| 120 } | 114 } |
| 121 | 115 |
| 122 // Returns true if the menu should close in order to perform the accelerator. | 116 // Returns true if the menu should close in order to perform the accelerator. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 | 162 |
| 169 void SetKeyboardBrightnessControlDelegate( | 163 void SetKeyboardBrightnessControlDelegate( |
| 170 std::unique_ptr<KeyboardBrightnessControlDelegate> | 164 std::unique_ptr<KeyboardBrightnessControlDelegate> |
| 171 keyboard_brightness_control_delegate); | 165 keyboard_brightness_control_delegate); |
| 172 | 166 |
| 173 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; | 167 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; |
| 174 | 168 |
| 175 // A tracker for the current and previous accelerators. | 169 // A tracker for the current and previous accelerators. |
| 176 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; | 170 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; |
| 177 | 171 |
| 178 // TODO(derat): BrightnessControlDelegate is also used by the system tray; | |
| 179 // move it outside of this class. | |
| 180 std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_; | |
| 181 std::unique_ptr<ImeControlDelegate> ime_control_delegate_; | 172 std::unique_ptr<ImeControlDelegate> ime_control_delegate_; |
| 182 std::unique_ptr<KeyboardBrightnessControlDelegate> | 173 std::unique_ptr<KeyboardBrightnessControlDelegate> |
| 183 keyboard_brightness_control_delegate_; | 174 keyboard_brightness_control_delegate_; |
|
msw
2016/07/07 22:41:59
I could also move this to WmShell for consistency,
James Cook
2016/07/07 23:08:49
Yeah, I would move it. It exists for tests and to
msw
2016/07/08 01:40:48
Done.
| |
| 184 std::unique_ptr<ScreenshotDelegate> screenshot_delegate_; | 175 std::unique_ptr<ScreenshotDelegate> screenshot_delegate_; |
| 185 | 176 |
| 186 // Handles the exit accelerator which requires a double press to exit and | 177 // Handles the exit accelerator which requires a double press to exit and |
| 187 // shows a popup with an explanation. | 178 // shows a popup with an explanation. |
| 188 ExitWarningHandler exit_warning_handler_; | 179 ExitWarningHandler exit_warning_handler_; |
| 189 | 180 |
| 190 // A map from accelerators to the AcceleratorAction values, which are used in | 181 // A map from accelerators to the AcceleratorAction values, which are used in |
| 191 // the implementation. | 182 // the implementation. |
| 192 std::map<ui::Accelerator, AcceleratorAction> accelerators_; | 183 std::map<ui::Accelerator, AcceleratorAction> accelerators_; |
| 193 | 184 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 215 std::set<int> actions_needing_window_; | 206 std::set<int> actions_needing_window_; |
| 216 // Actions that can be performed without closing the menu (if one is present). | 207 // Actions that can be performed without closing the menu (if one is present). |
| 217 std::set<int> actions_keeping_menu_open_; | 208 std::set<int> actions_keeping_menu_open_; |
| 218 | 209 |
| 219 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 210 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
| 220 }; | 211 }; |
| 221 | 212 |
| 222 } // namespace ash | 213 } // namespace ash |
| 223 | 214 |
| 224 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 215 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| OLD | NEW |