| 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/accelerator_table.h" | 11 #include "ash/accelerators/accelerator_table.h" |
| 12 #include "ash/accelerators/exit_warning_handler.h" | 12 #include "ash/accelerators/exit_warning_handler.h" |
| 13 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "ui/base/accelerators/accelerator.h" | 18 #include "ui/base/accelerators/accelerator.h" |
| 19 #include "ui/base/accelerators/accelerator_history.h" |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 class AcceleratorManager; | 22 class AcceleratorManager; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| 25 | 26 |
| 26 struct AcceleratorData; | 27 struct AcceleratorData; |
| 27 class BrightnessControlDelegate; | 28 class BrightnessControlDelegate; |
| 28 class ExitWarningHandler; | 29 class ExitWarningHandler; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 106 } |
| 106 ScreenshotDelegate* screenshot_delegate() { | 107 ScreenshotDelegate* screenshot_delegate() { |
| 107 return screenshot_delegate_.get(); | 108 return screenshot_delegate_.get(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 // Provides access to the ExitWarningHandler for testing. | 111 // Provides access to the ExitWarningHandler for testing. |
| 111 ExitWarningHandler* GetExitWarningHandlerForTest() { | 112 ExitWarningHandler* GetExitWarningHandlerForTest() { |
| 112 return &exit_warning_handler_; | 113 return &exit_warning_handler_; |
| 113 } | 114 } |
| 114 | 115 |
| 115 const ui::Accelerator& previous_accelerator_for_test() const { | 116 ui::AcceleratorHistory* accelerator_history() { |
| 116 return previous_accelerator_; | 117 return accelerator_history_.get(); |
| 117 } | 118 } |
| 118 | 119 |
| 119 // Overridden from ui::AcceleratorTarget: | 120 // Overridden from ui::AcceleratorTarget: |
| 120 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 121 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 121 bool CanHandleAccelerators() const override; | 122 bool CanHandleAccelerators() const override; |
| 122 | 123 |
| 123 private: | 124 private: |
| 124 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); | 125 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); |
| 125 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, | 126 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, |
| 126 DontRepeatToggleFullscreen); | 127 DontRepeatToggleFullscreen); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 142 // of -1 to get restrictions that apply for the current context. | 143 // of -1 to get restrictions that apply for the current context. |
| 143 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( | 144 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( |
| 144 int action); | 145 int action); |
| 145 | 146 |
| 146 void SetKeyboardBrightnessControlDelegate( | 147 void SetKeyboardBrightnessControlDelegate( |
| 147 scoped_ptr<KeyboardBrightnessControlDelegate> | 148 scoped_ptr<KeyboardBrightnessControlDelegate> |
| 148 keyboard_brightness_control_delegate); | 149 keyboard_brightness_control_delegate); |
| 149 | 150 |
| 150 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 151 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
| 151 | 152 |
| 153 // A tracker for the current and previous accelerators. |
| 154 scoped_ptr<ui::AcceleratorHistory> accelerator_history_; |
| 155 |
| 152 // TODO(derat): BrightnessControlDelegate is also used by the system tray; | 156 // TODO(derat): BrightnessControlDelegate is also used by the system tray; |
| 153 // move it outside of this class. | 157 // move it outside of this class. |
| 154 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; | 158 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; |
| 155 scoped_ptr<ImeControlDelegate> ime_control_delegate_; | 159 scoped_ptr<ImeControlDelegate> ime_control_delegate_; |
| 156 scoped_ptr<KeyboardBrightnessControlDelegate> | 160 scoped_ptr<KeyboardBrightnessControlDelegate> |
| 157 keyboard_brightness_control_delegate_; | 161 keyboard_brightness_control_delegate_; |
| 158 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 162 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; |
| 159 | 163 |
| 160 // Remember previous accelerator as some accelerator needs to be fired | |
| 161 // with a specific sequence. | |
| 162 ui::Accelerator previous_accelerator_; | |
| 163 | |
| 164 // Handles the exit accelerator which requires a double press to exit and | 164 // Handles the exit accelerator which requires a double press to exit and |
| 165 // shows a popup with an explanation. | 165 // shows a popup with an explanation. |
| 166 ExitWarningHandler exit_warning_handler_; | 166 ExitWarningHandler exit_warning_handler_; |
| 167 | 167 |
| 168 // A map from accelerators to the AcceleratorAction values, which are used in | 168 // A map from accelerators to the AcceleratorAction values, which are used in |
| 169 // the implementation. | 169 // the implementation. |
| 170 std::map<ui::Accelerator, AcceleratorAction> accelerators_; | 170 std::map<ui::Accelerator, AcceleratorAction> accelerators_; |
| 171 | 171 |
| 172 // Actions allowed when the user is not signed in. | 172 // Actions allowed when the user is not signed in. |
| 173 std::set<int> actions_allowed_at_login_screen_; | 173 std::set<int> actions_allowed_at_login_screen_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 185 std::set<int> actions_allowed_in_app_mode_; | 185 std::set<int> actions_allowed_in_app_mode_; |
| 186 // Actions disallowed if there are no windows. | 186 // Actions disallowed if there are no windows. |
| 187 std::set<int> actions_needing_window_; | 187 std::set<int> actions_needing_window_; |
| 188 | 188 |
| 189 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 189 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 } // namespace ash | 192 } // namespace ash |
| 193 | 193 |
| 194 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 194 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
| OLD | NEW |