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