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/accelerator_manager.h" | |
tfarina
2011/11/17 12:49:55
nit: you can forward declare this;
mazda
2011/11/17 13:10:16
Done.
| |
14 #include "ui/base/models/accelerator.h" | |
tfarina
2011/11/17 12:49:55
nit: I wish we could centralize all classes relate
mazda
2011/11/17 13:10:16
OK. I filed an issue for that (http://crbug.com/10
| |
15 | |
16 namespace aura_shell { | |
17 | |
18 // ShellAcceleratorController provides functions for registering or | |
19 // unregistering global keyboard accelerators, which are handled earlier than | |
20 // any windows. It also implements several handlers as an accelerator target. | |
21 class AURA_SHELL_EXPORT ShellAcceleratorController | |
22 : public ui::AcceleratorTarget { | |
23 public: | |
24 ShellAcceleratorController(); | |
25 virtual ~ShellAcceleratorController(); | |
26 | |
27 // Register a global keyboard accelerator for the specified target. If | |
28 // multiple targets are registered for an accelerator, a target registered | |
29 // later has higher priority. | |
30 void Register(const ui::Accelerator& accelerator, | |
31 ui::AcceleratorTarget* target); | |
32 | |
33 // Unregister the specified keyboard accelerator for the specified target. | |
34 void Unregister(const ui::Accelerator& accelerator, | |
35 ui::AcceleratorTarget* target); | |
36 | |
37 // Unregister all keyboard accelerators for the specified target. | |
38 void UnregisterAll(ui::AcceleratorTarget* target); | |
39 | |
40 // Activate the target associated with the specified accelerator. | |
41 // First, AcceleratorPressed handler of the most recently registered target | |
42 // is called, and if that handler processes the event (i.e. returns true), | |
43 // this method immediately returns. If not, we do the same thing on the next | |
44 // target, and so on. | |
45 // Returns true if an accelerator was activated. | |
46 bool Process(const ui::Accelerator& accelerator); | |
47 | |
48 // Overridden from ui::AcceleratorTarget: | |
49 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
50 | |
51 private: | |
52 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | |
53 DISALLOW_COPY_AND_ASSIGN(ShellAcceleratorController); | |
tfarina
2011/11/17 12:49:55
nit: newline between 52-53
mazda
2011/11/17 13:10:16
Done.
| |
54 }; | |
55 | |
56 } // namespace aura_shell | |
57 | |
58 #endif // UI_AURA_SHELL_SHELL_ACCELERATOR_CONTROLLER_H_ | |
OLD | NEW |