Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: ash/accelerators/accelerator_controller.h

Issue 350943003: Support global keyboard commands on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address various comments. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 20 matching lines...) Expand all
31 class VolumeControlDelegate; 31 class VolumeControlDelegate;
32 32
33 // AcceleratorController provides functions for registering or unregistering 33 // AcceleratorController provides functions for registering or unregistering
34 // global keyboard accelerators, which are handled earlier than any windows. It 34 // global keyboard accelerators, which are handled earlier than any windows. It
35 // also implements several handlers as an accelerator target. 35 // also implements several handlers as an accelerator target.
36 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { 36 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
37 public: 37 public:
38 AcceleratorController(); 38 AcceleratorController();
39 virtual ~AcceleratorController(); 39 virtual ~AcceleratorController();
40 40
41 // A list of possible ways in which an accelerator should be restricted before
42 // processing. Any target registered with this controller should respect
43 // restrictions by calling |GetAcceleratorProcessingRestriction| during
44 // processing.
45 enum AcceleratorProcessingRestriction {
46 // Process the accelerator normally.
47 RESTRICTION_NONE,
48
49 // Don't process the accelerator.
50 RESTRICTION_PREVENT_PROCESSING,
51
52 // Don't process the accelerator and prevent propagation to other targets.
53 RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION
54 };
55
41 // Registers a global keyboard accelerator for the specified target. If 56 // Registers a global keyboard accelerator for the specified target. If
42 // multiple targets are registered for an accelerator, a target registered 57 // multiple targets are registered for an accelerator, a target registered
43 // later has higher priority. 58 // later has higher priority.
44 void Register(const ui::Accelerator& accelerator, 59 void Register(const ui::Accelerator& accelerator,
45 ui::AcceleratorTarget* target); 60 ui::AcceleratorTarget* target);
46 61
47 // Unregisters the specified keyboard accelerator for the specified target. 62 // Unregisters the specified keyboard accelerator for the specified target.
48 void Unregister(const ui::Accelerator& accelerator, 63 void Unregister(const ui::Accelerator& accelerator,
49 ui::AcceleratorTarget* target); 64 ui::AcceleratorTarget* target);
50 65
(...skipping 13 matching lines...) Expand all
64 79
65 // Returns true if the |accelerator| is one of the |reserved_actions_|. 80 // Returns true if the |accelerator| is one of the |reserved_actions_|.
66 bool IsReservedAccelerator(const ui::Accelerator& accelerator) const; 81 bool IsReservedAccelerator(const ui::Accelerator& accelerator) const;
67 82
68 // Performs the specified action. The |accelerator| may provide additional 83 // Performs the specified action. The |accelerator| may provide additional
69 // data the action needs. Returns whether an action was performed 84 // data the action needs. Returns whether an action was performed
70 // successfully. 85 // successfully.
71 bool PerformAction(int action, 86 bool PerformAction(int action,
72 const ui::Accelerator& accelerator); 87 const ui::Accelerator& accelerator);
73 88
89 // Returns which restriction applies for the given accelerator and action.
90 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction(
91 int action,
92 const ui::Accelerator& accelerator);
93
74 // Overridden from ui::AcceleratorTarget: 94 // Overridden from ui::AcceleratorTarget:
75 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 95 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
76 virtual bool CanHandleAccelerators() const OVERRIDE; 96 virtual bool CanHandleAccelerators() const OVERRIDE;
77 97
78 void SetBrightnessControlDelegate( 98 void SetBrightnessControlDelegate(
79 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); 99 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate);
80 void SetImeControlDelegate( 100 void SetImeControlDelegate(
81 scoped_ptr<ImeControlDelegate> ime_control_delegate); 101 scoped_ptr<ImeControlDelegate> ime_control_delegate);
82 void SetScreenshotDelegate( 102 void SetScreenshotDelegate(
83 scoped_ptr<ScreenshotDelegate> screenshot_delegate); 103 scoped_ptr<ScreenshotDelegate> screenshot_delegate);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 std::set<int> actions_allowed_in_app_mode_; 169 std::set<int> actions_allowed_in_app_mode_;
150 // Actions disallowed if there are no windows. 170 // Actions disallowed if there are no windows.
151 std::set<int> actions_needing_window_; 171 std::set<int> actions_needing_window_;
152 172
153 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); 173 DISALLOW_COPY_AND_ASSIGN(AcceleratorController);
154 }; 174 };
155 175
156 } // namespace ash 176 } // namespace ash
157 177
158 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ 178 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller.cc » ('j') | ash/accelerators/accelerator_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698