OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_ | |
6 #define UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "ui/aura_shell/aura_shell_export.h" | |
13 #include "ui/base/models/accelerator.h" | |
14 | |
15 namespace ui { | |
16 class AcceleratorManager; | |
17 } // namespace ui | |
18 | |
19 namespace aura_shell { | |
20 | |
21 // ShellAcceleratorController provides functions for registering or | |
22 // unregistering global keyboard accelerators, which are handled earlier than | |
23 // any windows. It also implements several handlers as an accelerator target. | |
24 class AURA_SHELL_EXPORT ShellAcceleratorController | |
25 : public ui::AcceleratorTarget { | |
26 public: | |
27 ShellAcceleratorController(); | |
28 virtual ~ShellAcceleratorController(); | |
29 | |
30 // Register a global keyboard accelerator for the specified target. If | |
31 // multiple targets are registered for an accelerator, a target registered | |
32 // later has higher priority. | |
33 void Register(const ui::Accelerator& accelerator, | |
34 ui::AcceleratorTarget* target); | |
35 | |
36 // Unregister the specified keyboard accelerator for the specified target. | |
37 void Unregister(const ui::Accelerator& accelerator, | |
38 ui::AcceleratorTarget* target); | |
39 | |
40 // Unregister all keyboard accelerators for the specified target. | |
41 void UnregisterAll(ui::AcceleratorTarget* target); | |
42 | |
43 // Activate the target associated with the specified accelerator. | |
44 // First, AcceleratorPressed handler of the most recently registered target | |
45 // is called, and if that handler processes the event (i.e. returns true), | |
46 // this method immediately returns. If not, we do the same thing on the next | |
47 // target, and so on. | |
48 // Returns true if an accelerator was activated. | |
49 bool Process(const ui::Accelerator& accelerator); | |
50 | |
51 // Overridden from ui::AcceleratorTarget: | |
52 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
53 | |
54 private: | |
55 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(ShellAcceleratorController); | |
58 }; | |
59 | |
60 } // namespace aura_shell | |
61 | |
62 #endif // UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_ | |
OLD | NEW |