| 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 |
| 11 #include "ash/accelerators/exit_warning_handler.h" | 11 #include "ash/accelerators/exit_warning_handler.h" |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "ui/base/accelerators/accelerator.h" | 17 #include "ui/base/accelerators/accelerator.h" |
| 18 #include "ui/base/accelerators/accelerator_history.h" |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 class AcceleratorManager; | 21 class AcceleratorManager; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 | 25 |
| 25 struct AcceleratorData; | 26 struct AcceleratorData; |
| 26 class BrightnessControlDelegate; | 27 class BrightnessControlDelegate; |
| 27 class ExitWarningHandler; | 28 class ExitWarningHandler; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ScreenshotDelegate* screenshot_delegate() { | 112 ScreenshotDelegate* screenshot_delegate() { |
| 112 return screenshot_delegate_.get(); | 113 return screenshot_delegate_.get(); |
| 113 } | 114 } |
| 114 | 115 |
| 115 // Provides access to the ExitWarningHandler for testing. | 116 // Provides access to the ExitWarningHandler for testing. |
| 116 ExitWarningHandler* GetExitWarningHandlerForTest() { | 117 ExitWarningHandler* GetExitWarningHandlerForTest() { |
| 117 return &exit_warning_handler_; | 118 return &exit_warning_handler_; |
| 118 } | 119 } |
| 119 | 120 |
| 120 const ui::Accelerator& previous_accelerator_for_test() const { | 121 const ui::Accelerator& previous_accelerator_for_test() const { |
| 121 return previous_accelerator_; | 122 return GetPreviousAccelerator(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); | 126 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); |
| 126 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, | 127 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, |
| 127 DontRepeatToggleFullscreen); | 128 DontRepeatToggleFullscreen); |
| 128 | 129 |
| 129 // Initializes the accelerators this class handles as a target. | 130 // Initializes the accelerators this class handles as a target. |
| 130 void Init(); | 131 void Init(); |
| 131 | 132 |
| 132 // Registers the specified accelerators. | 133 // Registers the specified accelerators. |
| 133 void RegisterAccelerators(const AcceleratorData accelerators[], | 134 void RegisterAccelerators(const AcceleratorData accelerators[], |
| 134 size_t accelerators_length); | 135 size_t accelerators_length); |
| 135 | 136 |
| 136 // Get the accelerator restriction for the given action. Supply an |action| | 137 // Get the accelerator restriction for the given action. Supply an |action| |
| 137 // of -1 to get restrictions that apply for the current context. | 138 // of -1 to get restrictions that apply for the current context. |
| 138 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( | 139 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( |
| 139 int action); | 140 int action); |
| 140 | 141 |
| 141 void SetKeyboardBrightnessControlDelegate( | 142 void SetKeyboardBrightnessControlDelegate( |
| 142 scoped_ptr<KeyboardBrightnessControlDelegate> | 143 scoped_ptr<KeyboardBrightnessControlDelegate> |
| 143 keyboard_brightness_control_delegate); | 144 keyboard_brightness_control_delegate); |
| 144 | 145 |
| 146 // Returns the previous accelerator that should be used depending on the most |
| 147 // recent time stamp. |
| 148 const ui::Accelerator& GetPreviousAccelerator() const; |
| 149 |
| 150 |
| 145 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 151 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
| 146 | 152 |
| 147 // TODO(derat): BrightnessControlDelegate is also used by the system tray; | 153 // TODO(derat): BrightnessControlDelegate is also used by the system tray; |
| 148 // move it outside of this class. | 154 // move it outside of this class. |
| 149 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; | 155 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; |
| 150 scoped_ptr<ImeControlDelegate> ime_control_delegate_; | 156 scoped_ptr<ImeControlDelegate> ime_control_delegate_; |
| 151 scoped_ptr<KeyboardBrightnessControlDelegate> | 157 scoped_ptr<KeyboardBrightnessControlDelegate> |
| 152 keyboard_brightness_control_delegate_; | 158 keyboard_brightness_control_delegate_; |
| 153 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 159 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; |
| 154 | 160 |
| 155 // Remember previous accelerator as some accelerator needs to be fired | 161 // Remember previous accelerator as some accelerator needs to be fired |
| 156 // with a specific sequence. | 162 // with a specific sequence. |
| 157 ui::Accelerator previous_accelerator_; | 163 ui::AcceleratorEvent previous_accelerator_; |
| 158 | 164 |
| 159 // Handles the exit accelerator which requires a double press to exit and | 165 // Handles the exit accelerator which requires a double press to exit and |
| 160 // shows a popup with an explanation. | 166 // shows a popup with an explanation. |
| 161 ExitWarningHandler exit_warning_handler_; | 167 ExitWarningHandler exit_warning_handler_; |
| 162 | 168 |
| 163 // A map from accelerators to the AcceleratorAction values, which are used in | 169 // A map from accelerators to the AcceleratorAction values, which are used in |
| 164 // the implementation. | 170 // the implementation. |
| 165 std::map<ui::Accelerator, int> accelerators_; | 171 std::map<ui::Accelerator, int> accelerators_; |
| 166 | 172 |
| 167 // Actions allowed when the user is not signed in. | 173 // Actions allowed when the user is not signed in. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 180 std::set<int> actions_allowed_in_app_mode_; | 186 std::set<int> actions_allowed_in_app_mode_; |
| 181 // Actions disallowed if there are no windows. | 187 // Actions disallowed if there are no windows. |
| 182 std::set<int> actions_needing_window_; | 188 std::set<int> actions_needing_window_; |
| 183 | 189 |
| 184 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 190 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
| 185 }; | 191 }; |
| 186 | 192 |
| 187 } // namespace ash | 193 } // namespace ash |
| 188 | 194 |
| 189 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 195 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| OLD | NEW |