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

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

Issue 729993002: Alphabetise AcceleratorController::PerformAction() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nested_dispatch0
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "ash/accelerators/accelerator_table.h"
11 #include "ash/accelerators/exit_warning_handler.h" 12 #include "ash/accelerators/exit_warning_handler.h"
12 #include "ash/ash_export.h" 13 #include "ash/ash_export.h"
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "ui/base/accelerators/accelerator.h" 18 #include "ui/base/accelerators/accelerator.h"
18 19
19 namespace ui { 20 namespace ui {
20 class AcceleratorManager; 21 class AcceleratorManager;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // is handled before being passed to an window/web contents, unless 82 // is handled before being passed to an window/web contents, unless
82 // the window is in fullscreen state. 83 // the window is in fullscreen state.
83 bool IsPreferred(const ui::Accelerator& accelerator) const; 84 bool IsPreferred(const ui::Accelerator& accelerator) const;
84 85
85 // Returns true if the |accelerator| is reserved. A reserved accelerator 86 // Returns true if the |accelerator| is reserved. A reserved accelerator
86 // is always handled and will never be passed to an window/web contents. 87 // is always handled and will never be passed to an window/web contents.
87 bool IsReserved(const ui::Accelerator& accelerator) const; 88 bool IsReserved(const ui::Accelerator& accelerator) const;
88 89
89 // Performs the specified action if it is enabled. Returns whether the action 90 // Performs the specified action if it is enabled. Returns whether the action
90 // was performed successfully. 91 // was performed successfully.
91 bool PerformActionIfEnabled(int action); 92 bool PerformActionIfEnabled(AcceleratorAction action);
92 93
93 // Returns the restriction for the current context. 94 // Returns the restriction for the current context.
94 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction(); 95 AcceleratorProcessingRestriction GetCurrentAcceleratorRestriction();
95 96
96 // Overridden from ui::AcceleratorTarget:
97 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
98 bool CanHandleAccelerators() const override;
99
100 void SetBrightnessControlDelegate( 97 void SetBrightnessControlDelegate(
101 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate); 98 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate);
102 void SetImeControlDelegate( 99 void SetImeControlDelegate(
103 scoped_ptr<ImeControlDelegate> ime_control_delegate); 100 scoped_ptr<ImeControlDelegate> ime_control_delegate);
104 void SetScreenshotDelegate( 101 void SetScreenshotDelegate(
105 scoped_ptr<ScreenshotDelegate> screenshot_delegate); 102 scoped_ptr<ScreenshotDelegate> screenshot_delegate);
106 BrightnessControlDelegate* brightness_control_delegate() const { 103 BrightnessControlDelegate* brightness_control_delegate() const {
107 return brightness_control_delegate_.get(); 104 return brightness_control_delegate_.get();
108 } 105 }
109 ScreenshotDelegate* screenshot_delegate() { 106 ScreenshotDelegate* screenshot_delegate() {
110 return screenshot_delegate_.get(); 107 return screenshot_delegate_.get();
111 } 108 }
112 109
113 // Provides access to the ExitWarningHandler for testing. 110 // Provides access to the ExitWarningHandler for testing.
114 ExitWarningHandler* GetExitWarningHandlerForTest() { 111 ExitWarningHandler* GetExitWarningHandlerForTest() {
115 return &exit_warning_handler_; 112 return &exit_warning_handler_;
116 } 113 }
117 114
118 const ui::Accelerator& previous_accelerator_for_test() const { 115 const ui::Accelerator& previous_accelerator_for_test() const {
119 return previous_accelerator_; 116 return previous_accelerator_;
120 } 117 }
121 118
119 // Overridden from ui::AcceleratorTarget:
120 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
121 bool CanHandleAccelerators() const override;
122
122 private: 123 private:
123 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); 124 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators);
124 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, 125 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest,
125 DontRepeatToggleFullscreen); 126 DontRepeatToggleFullscreen);
126 127
127 // Initializes the accelerators this class handles as a target. 128 // Initializes the accelerators this class handles as a target.
128 void Init(); 129 void Init();
129 130
130 // Registers the specified accelerators. 131 // Registers the specified accelerators.
131 void RegisterAccelerators(const AcceleratorData accelerators[], 132 void RegisterAccelerators(const AcceleratorData accelerators[],
132 size_t accelerators_length); 133 size_t accelerators_length);
133 134
134 // Performs the specified action. The |accelerator| may provide additional 135 // Performs the specified action. The |accelerator| may provide additional
135 // data the action needs. Returns whether an action was performed 136 // data the action needs. Returns whether an action was performed
136 // successfully. 137 // successfully.
137 bool PerformAction(int action, 138 bool PerformAction(AcceleratorAction action,
138 const ui::Accelerator& accelerator); 139 const ui::Accelerator& accelerator);
139 140
140 // Get the accelerator restriction for the given action. Supply an |action| 141 // Get the accelerator restriction for the given action. Supply an |action|
141 // of -1 to get restrictions that apply for the current context. 142 // of -1 to get restrictions that apply for the current context.
142 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( 143 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction(
143 int action); 144 int action);
144 145
145 void SetKeyboardBrightnessControlDelegate( 146 void SetKeyboardBrightnessControlDelegate(
146 scoped_ptr<KeyboardBrightnessControlDelegate> 147 scoped_ptr<KeyboardBrightnessControlDelegate>
147 keyboard_brightness_control_delegate); 148 keyboard_brightness_control_delegate);
(...skipping 11 matching lines...) Expand all
159 // Remember previous accelerator as some accelerator needs to be fired 160 // Remember previous accelerator as some accelerator needs to be fired
160 // with a specific sequence. 161 // with a specific sequence.
161 ui::Accelerator previous_accelerator_; 162 ui::Accelerator previous_accelerator_;
162 163
163 // Handles the exit accelerator which requires a double press to exit and 164 // Handles the exit accelerator which requires a double press to exit and
164 // shows a popup with an explanation. 165 // shows a popup with an explanation.
165 ExitWarningHandler exit_warning_handler_; 166 ExitWarningHandler exit_warning_handler_;
166 167
167 // A map from accelerators to the AcceleratorAction values, which are used in 168 // A map from accelerators to the AcceleratorAction values, which are used in
168 // the implementation. 169 // the implementation.
169 std::map<ui::Accelerator, int> accelerators_; 170 std::map<ui::Accelerator, AcceleratorAction> accelerators_;
170 171
171 // Actions allowed when the user is not signed in. 172 // Actions allowed when the user is not signed in.
172 std::set<int> actions_allowed_at_login_screen_; 173 std::set<int> actions_allowed_at_login_screen_;
173 // Actions allowed when the screen is locked. 174 // Actions allowed when the screen is locked.
174 std::set<int> actions_allowed_at_lock_screen_; 175 std::set<int> actions_allowed_at_lock_screen_;
175 // Actions allowed when a modal window is up. 176 // Actions allowed when a modal window is up.
176 std::set<int> actions_allowed_at_modal_window_; 177 std::set<int> actions_allowed_at_modal_window_;
177 // Preferred actions. See accelerator_table.h for details. 178 // Preferred actions. See accelerator_table.h for details.
178 std::set<int> preferred_actions_; 179 std::set<int> preferred_actions_;
179 // Reserved actions. See accelerator_table.h for details. 180 // Reserved actions. See accelerator_table.h for details.
180 std::set<int> reserved_actions_; 181 std::set<int> reserved_actions_;
181 // Actions which will not be repeated while holding the accelerator key. 182 // Actions which will not be repeated while holding the accelerator key.
182 std::set<int> nonrepeatable_actions_; 183 std::set<int> nonrepeatable_actions_;
183 // Actions allowed in app mode. 184 // Actions allowed in app mode.
184 std::set<int> actions_allowed_in_app_mode_; 185 std::set<int> actions_allowed_in_app_mode_;
185 // Actions disallowed if there are no windows. 186 // Actions disallowed if there are no windows.
186 std::set<int> actions_needing_window_; 187 std::set<int> actions_needing_window_;
187 188
188 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); 189 DISALLOW_COPY_AND_ASSIGN(AcceleratorController);
189 }; 190 };
190 191
191 } // namespace ash 192 } // namespace ash
192 193
193 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ 194 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698