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 "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "ash/ash_export.h" | 14 #include "ash/ash_export.h" |
15 #include "ui/base/accelerators/accelerator.h" | 15 #include "ui/base/accelerators/accelerator.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 class AcceleratorManager; | 18 class AcceleratorManager; |
19 } | 19 } |
20 | 20 |
21 namespace ash { | 21 namespace ash { |
22 | 22 |
23 struct AcceleratorData; | 23 struct AcceleratorData; |
24 class BrightnessControlDelegate; | 24 class BrightnessControlDelegate; |
25 class CapsLockDelegate; | |
26 class ImeControlDelegate; | 25 class ImeControlDelegate; |
27 class KeyboardBrightnessControlDelegate; | 26 class KeyboardBrightnessControlDelegate; |
28 class ScreenshotDelegate; | 27 class ScreenshotDelegate; |
29 class VolumeControlDelegate; | 28 class VolumeControlDelegate; |
30 | 29 |
31 // AcceleratorController provides functions for registering or unregistering | 30 // AcceleratorController provides functions for registering or unregistering |
32 // global keyboard accelerators, which are handled earlier than any windows. It | 31 // global keyboard accelerators, which are handled earlier than any windows. It |
33 // also implements several handlers as an accelerator target. | 32 // also implements several handlers as an accelerator target. |
34 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { | 33 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { |
35 public: | 34 public: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // successfully. | 67 // successfully. |
69 bool PerformAction(int action, | 68 bool PerformAction(int action, |
70 const ui::Accelerator& accelerator); | 69 const ui::Accelerator& accelerator); |
71 | 70 |
72 // Overridden from ui::AcceleratorTarget: | 71 // Overridden from ui::AcceleratorTarget: |
73 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 72 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
74 virtual bool CanHandleAccelerators() const OVERRIDE; | 73 virtual bool CanHandleAccelerators() const OVERRIDE; |
75 | 74 |
76 void SetBrightnessControlDelegate( | 75 void SetBrightnessControlDelegate( |
77 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); | 76 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); |
78 void SetCapsLockDelegate(scoped_ptr<CapsLockDelegate> caps_lock_delegate); | |
79 void SetImeControlDelegate( | 77 void SetImeControlDelegate( |
80 scoped_ptr<ImeControlDelegate> ime_control_delegate); | 78 scoped_ptr<ImeControlDelegate> ime_control_delegate); |
81 void SetKeyboardBrightnessControlDelegate( | 79 void SetKeyboardBrightnessControlDelegate( |
82 scoped_ptr<KeyboardBrightnessControlDelegate> | 80 scoped_ptr<KeyboardBrightnessControlDelegate> |
83 keyboard_brightness_control_delegate); | 81 keyboard_brightness_control_delegate); |
84 void SetScreenshotDelegate( | 82 void SetScreenshotDelegate( |
85 scoped_ptr<ScreenshotDelegate> screenshot_delegate); | 83 scoped_ptr<ScreenshotDelegate> screenshot_delegate); |
86 BrightnessControlDelegate* brightness_control_delegate() const { | 84 BrightnessControlDelegate* brightness_control_delegate() const { |
87 return brightness_control_delegate_.get(); | 85 return brightness_control_delegate_.get(); |
88 } | 86 } |
89 | 87 |
90 private: | 88 private: |
91 // Initializes the accelerators this class handles as a target. | 89 // Initializes the accelerators this class handles as a target. |
92 void Init(); | 90 void Init(); |
93 | 91 |
94 // Switches to a 0-indexed (in order of creation) window. | 92 // Switches to a 0-indexed (in order of creation) window. |
95 // A negative index switches to the last window in the list. | 93 // A negative index switches to the last window in the list. |
96 void SwitchToWindow(int window); | 94 void SwitchToWindow(int window); |
97 | 95 |
98 // Registers the specified accelerators. | 96 // Registers the specified accelerators. |
99 void RegisterAccelerators(const AcceleratorData accelerators[], | 97 void RegisterAccelerators(const AcceleratorData accelerators[], |
100 size_t accelerators_length); | 98 size_t accelerators_length); |
101 | 99 |
102 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 100 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
103 | 101 |
104 // TODO(derat): BrightnessControlDelegate is also used by the system tray; | 102 // TODO(derat): BrightnessControlDelegate is also used by the system tray; |
105 // move it outside of this class. | 103 // move it outside of this class. |
106 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; | 104 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_; |
107 scoped_ptr<CapsLockDelegate> caps_lock_delegate_; | |
108 scoped_ptr<ImeControlDelegate> ime_control_delegate_; | 105 scoped_ptr<ImeControlDelegate> ime_control_delegate_; |
109 scoped_ptr<KeyboardBrightnessControlDelegate> | 106 scoped_ptr<KeyboardBrightnessControlDelegate> |
110 keyboard_brightness_control_delegate_; | 107 keyboard_brightness_control_delegate_; |
111 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 108 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; |
112 | 109 |
113 // A map from accelerators to the AcceleratorAction values, which are used in | 110 // A map from accelerators to the AcceleratorAction values, which are used in |
114 // the implementation. | 111 // the implementation. |
115 std::map<ui::Accelerator, int> accelerators_; | 112 std::map<ui::Accelerator, int> accelerators_; |
116 | 113 |
117 // Actions allowed when the user is not signed in. | 114 // Actions allowed when the user is not signed in. |
118 std::set<int> actions_allowed_at_login_screen_; | 115 std::set<int> actions_allowed_at_login_screen_; |
119 // Actions allowed when the screen is locked. | 116 // Actions allowed when the screen is locked. |
120 std::set<int> actions_allowed_at_lock_screen_; | 117 std::set<int> actions_allowed_at_lock_screen_; |
121 // Reserved actions. See accelerator_table.h for details. | 118 // Reserved actions. See accelerator_table.h for details. |
122 std::set<int> reserved_actions_; | 119 std::set<int> reserved_actions_; |
123 | 120 |
124 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 121 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
125 }; | 122 }; |
126 | 123 |
127 } // namespace ash | 124 } // namespace ash |
128 | 125 |
129 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 126 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |