OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 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 class ScreenshotDelegate; | 23 class ScreenshotDelegate; |
| 24 class CapsLockDelegate; |
24 | 25 |
25 // AcceleratorController provides functions for registering or unregistering | 26 // AcceleratorController provides functions for registering or unregistering |
26 // global keyboard accelerators, which are handled earlier than any windows. It | 27 // global keyboard accelerators, which are handled earlier than any windows. It |
27 // also implements several handlers as an accelerator target. | 28 // also implements several handlers as an accelerator target. |
28 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { | 29 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { |
29 public: | 30 public: |
30 AcceleratorController(); | 31 AcceleratorController(); |
31 virtual ~AcceleratorController(); | 32 virtual ~AcceleratorController(); |
32 | 33 |
33 // Register a global keyboard accelerator for the specified target. If | 34 // Register a global keyboard accelerator for the specified target. If |
(...skipping 15 matching lines...) Expand all Loading... |
49 // this method immediately returns. If not, we do the same thing on the next | 50 // this method immediately returns. If not, we do the same thing on the next |
50 // target, and so on. | 51 // target, and so on. |
51 // Returns true if an accelerator was activated. | 52 // Returns true if an accelerator was activated. |
52 bool Process(const ui::Accelerator& accelerator); | 53 bool Process(const ui::Accelerator& accelerator); |
53 | 54 |
54 // Overridden from ui::AcceleratorTarget: | 55 // Overridden from ui::AcceleratorTarget: |
55 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 56 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
56 virtual bool CanHandleAccelerators() const OVERRIDE; | 57 virtual bool CanHandleAccelerators() const OVERRIDE; |
57 | 58 |
58 void SetScreenshotDelegate(ScreenshotDelegate* screenshot_delegate); | 59 void SetScreenshotDelegate(ScreenshotDelegate* screenshot_delegate); |
| 60 void SetCapsLockDelegate(scoped_ptr<CapsLockDelegate> caps_lock_delegate); |
59 | 61 |
60 private: | 62 private: |
61 // Initialize the accelerators this class handles as a target. | 63 // Initialize the accelerators this class handles as a target. |
62 void Init(); | 64 void Init(); |
63 | 65 |
64 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 66 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
65 | 67 |
66 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 68 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; |
| 69 scoped_ptr<CapsLockDelegate> caps_lock_delegate_; |
67 | 70 |
68 // A map from accelerators to the AcceleratorAction values, which are used in | 71 // A map from accelerators to the AcceleratorAction values, which are used in |
69 // the implementation. | 72 // the implementation. |
70 std::map<ui::Accelerator, int> accelerators_; | 73 std::map<ui::Accelerator, int> accelerators_; |
71 | 74 |
72 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 75 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
73 }; | 76 }; |
74 | 77 |
75 } // namespace ash | 78 } // namespace ash |
76 | 79 |
77 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 80 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |