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 14 matching lines...) Expand all Loading... | |
48 // is called, and if that handler processes the event (i.e. returns true), | 49 // is called, and if that handler processes the event (i.e. returns true), |
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( |
60 scoped_ptr<ScreenshotDelegate> screenshot_delegate); | |
mazda
2012/01/17 07:34:05
I prefer this signature change is done first in an
Yusuke Sato
2012/01/17 08:24:52
Done. Please review https://chromiumcodereview.app
| |
61 void SetCapsLockDelegate(scoped_ptr<CapsLockDelegate> caps_lock_delegate); | |
59 | 62 |
60 private: | 63 private: |
61 // Initialize the accelerators this class handles as a target. | 64 // Initialize the accelerators this class handles as a target. |
62 void Init(); | 65 void Init(); |
63 | 66 |
64 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; | 67 scoped_ptr<ui::AcceleratorManager> accelerator_manager_; |
65 | 68 |
66 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; | 69 scoped_ptr<ScreenshotDelegate> screenshot_delegate_; |
70 scoped_ptr<CapsLockDelegate> caps_lock_delegate_; | |
67 | 71 |
68 // A map from accelerators to the AcceleratorAction values, which are used in | 72 // A map from accelerators to the AcceleratorAction values, which are used in |
69 // the implementation. | 73 // the implementation. |
70 std::map<ui::Accelerator, int> accelerators_; | 74 std::map<ui::Accelerator, int> accelerators_; |
71 | 75 |
72 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 76 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
73 }; | 77 }; |
74 | 78 |
75 } // namespace ash | 79 } // namespace ash |
76 | 80 |
77 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 81 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |