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 <set> | 12 #include <set> |
12 | 13 |
13 #include "ash/accelerators/accelerator_table.h" | 14 #include "ash/accelerators/accelerator_table.h" |
14 #include "ash/accelerators/exit_warning_handler.h" | 15 #include "ash/accelerators/exit_warning_handler.h" |
15 #include "ash/ash_export.h" | 16 #include "ash/ash_export.h" |
16 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
17 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/memory/scoped_ptr.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; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool IsDeprecated(const ui::Accelerator& accelerator) const; | 95 bool IsDeprecated(const ui::Accelerator& accelerator) const; |
96 | 96 |
97 // Performs the specified action if it is enabled. Returns whether the action | 97 // Performs the specified action if it is enabled. Returns whether the action |
98 // was performed successfully. | 98 // was performed successfully. |
99 bool PerformActionIfEnabled(AcceleratorAction action); | 99 bool PerformActionIfEnabled(AcceleratorAction action); |
100 | 100 |
101 // Returns the restriction for the current context. | 101 // Returns the restriction for the current context. |
102 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); | 102 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); |
103 | 103 |
104 void SetBrightnessControlDelegate( | 104 void SetBrightnessControlDelegate( |
105 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); | 105 std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate); |
106 void SetImeControlDelegate( | 106 void SetImeControlDelegate( |
107 scoped_ptr<ImeControlDelegate> ime_control_delegate); | 107 std::unique_ptr<ImeControlDelegate> ime_control_delegate); |
108 void SetScreenshotDelegate( | 108 void SetScreenshotDelegate( |
109 scoped_ptr<ScreenshotDelegate> screenshot_delegate); | 109 std::unique_ptr<ScreenshotDelegate> screenshot_delegate); |
110 BrightnessControlDelegate* brightness_control_delegate() const { | 110 BrightnessControlDelegate* brightness_control_delegate() const { |
111 return brightness_control_delegate_.get(); | 111 return brightness_control_delegate_.get(); |
112 } | 112 } |
113 ScreenshotDelegate* screenshot_delegate() { | 113 ScreenshotDelegate* screenshot_delegate() { |
114 return screenshot_delegate_.get(); | 114 return screenshot_delegate_.get(); |
115 } | 115 } |
116 | 116 |
117 // Provides access to the ExitWarningHandler for testing. | 117 // Provides access to the ExitWarningHandler for testing. |
118 ExitWarningHandler* GetExitWarningHandlerForTest() { | 118 ExitWarningHandler* GetExitWarningHandlerForTest() { |
119 return &exit_warning_handler_; | 119 return &exit_warning_handler_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 // Returns whether performing |action| should consume the key event. | 161 // Returns whether performing |action| should consume the key event. |
162 bool ShouldActionConsumeKeyEvent(AcceleratorAction action); | 162 bool ShouldActionConsumeKeyEvent(AcceleratorAction action); |
163 | 163 |
164 // Get the accelerator restriction for the given action. Supply an |action| | 164 // Get the accelerator restriction for the given action. Supply an |action| |
165 // of -1 to get restrictions that apply for the current context. | 165 // of -1 to get restrictions that apply for the current context. |
166 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( | 166 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( |
167 int action); | 167 int action); |
168 | 168 |
169 void SetKeyboardBrightnessControlDelegate( | 169 void SetKeyboardBrightnessControlDelegate( |
170 scoped_ptr<KeyboardBrightnessControlDelegate> | 170 std::unique_ptr<KeyboardBrightnessControlDelegate> |
171 keyboard_brightness_control_delegate); | 171 keyboard_brightness_control_delegate); |
172 | 172 |
173 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 173 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; |
174 | 174 |
175 // A tracker for the current and previous accelerators. | 175 // A tracker for the current and previous accelerators. |
176 scoped_ptr<ui::AcceleratorHistory> accelerator_history_; | 176 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; |
177 | 177 |
178 // TODO(derat): BrightnessControlDelegate is also used by the system tray; | 178 // TODO(derat): BrightnessControlDelegate is also used by the system tray; |
179 // move it outside of this class. | 179 // move it outside of this class. |
180 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; | 180 std::unique_ptr<BrightnessControlDelegate> brightness_control_delegate_; |
181 scoped_ptr<ImeControlDelegate> ime_control_delegate_; | 181 std::unique_ptr<ImeControlDelegate> ime_control_delegate_; |
182 scoped_ptr<KeyboardBrightnessControlDelegate> | 182 std::unique_ptr<KeyboardBrightnessControlDelegate> |
183 keyboard_brightness_control_delegate_; | 183 keyboard_brightness_control_delegate_; |
184 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 184 std::unique_ptr<ScreenshotDelegate> screenshot_delegate_; |
185 | 185 |
186 // 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 |
187 // shows a popup with an explanation. | 187 // shows a popup with an explanation. |
188 ExitWarningHandler exit_warning_handler_; | 188 ExitWarningHandler exit_warning_handler_; |
189 | 189 |
190 // 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 |
191 // the implementation. | 191 // the implementation. |
192 std::map<ui::Accelerator, AcceleratorAction> accelerators_; | 192 std::map<ui::Accelerator, AcceleratorAction> accelerators_; |
193 | 193 |
194 std::map<AcceleratorAction, const DeprecatedAcceleratorData*> | 194 std::map<AcceleratorAction, const DeprecatedAcceleratorData*> |
(...skipping 18 matching lines...) Expand all Loading... |
213 std::set<int> actions_needing_window_; | 213 std::set<int> actions_needing_window_; |
214 // Actions that can be performed without closing the menu (if one is present). | 214 // Actions that can be performed without closing the menu (if one is present). |
215 std::set<int> actions_keeping_menu_open_; | 215 std::set<int> actions_keeping_menu_open_; |
216 | 216 |
217 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 217 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
218 }; | 218 }; |
219 | 219 |
220 } // namespace ash | 220 } // namespace ash |
221 | 221 |
222 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 222 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |