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

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

Issue 2552483002: mash: Have chrome set itself as a controller interface for changing volume (Closed)
Patch Set: comment Created 4 years 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/common/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_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ 5 #ifndef ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
6 #define ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ 6 #define ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 13
14 #include "ash/ash_export.h" 14 #include "ash/ash_export.h"
15 #include "ash/common/accelerators/accelerator_table.h" 15 #include "ash/common/accelerators/accelerator_table.h"
16 #include "ash/common/accelerators/exit_warning_handler.h" 16 #include "ash/common/accelerators/exit_warning_handler.h"
17 #include "ash/public/interfaces/volume.mojom.h" 17 #include "ash/public/interfaces/accelerator_controller.mojom.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/gtest_prod_util.h" 19 #include "base/gtest_prod_util.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "mojo/public/cpp/bindings/binding_set.h"
21 #include "ui/base/accelerators/accelerator.h" 22 #include "ui/base/accelerators/accelerator.h"
22 #include "ui/base/accelerators/accelerator_history.h" 23 #include "ui/base/accelerators/accelerator_history.h"
23 24
24 namespace ui { 25 namespace ui {
25 class AcceleratorManager; 26 class AcceleratorManager;
26 class AcceleratorManagerDelegate; 27 class AcceleratorManagerDelegate;
27 } 28 }
28 29
29 namespace ash { 30 namespace ash {
30 31
31 struct AcceleratorData; 32 struct AcceleratorData;
32 class AcceleratorControllerDelegate; 33 class AcceleratorControllerDelegate;
33 class ExitWarningHandler; 34 class ExitWarningHandler;
34 class ImeControlDelegate; 35 class ImeControlDelegate;
35 36
36 // AcceleratorController provides functions for registering or unregistering 37 // AcceleratorController provides functions for registering or unregistering
37 // global keyboard accelerators, which are handled earlier than any windows. It 38 // global keyboard accelerators, which are handled earlier than any windows. It
38 // also implements several handlers as an accelerator target. 39 // also implements several handlers as an accelerator target.
39 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { 40 class ASH_EXPORT AcceleratorController
41 : public ui::AcceleratorTarget,
42 NON_EXPORTED_BASE(public mojom::AcceleratorController) {
40 public: 43 public:
41 AcceleratorController(AcceleratorControllerDelegate* delegate, 44 AcceleratorController(AcceleratorControllerDelegate* delegate,
42 ui::AcceleratorManagerDelegate* manager_delegate); 45 ui::AcceleratorManagerDelegate* manager_delegate);
43 ~AcceleratorController() override; 46 ~AcceleratorController() override;
44 47
45 // A list of possible ways in which an accelerator should be restricted before 48 // A list of possible ways in which an accelerator should be restricted before
46 // processing. Any target registered with this controller should respect 49 // processing. Any target registered with this controller should respect
47 // restrictions by calling |GetCurrentAcceleratorRestriction| during 50 // restrictions by calling |GetCurrentAcceleratorRestriction| during
48 // processing. 51 // processing.
49 enum AcceleratorProcessingRestriction { 52 enum AcceleratorProcessingRestriction {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const ui::Accelerator& accelerator) const; 117 const ui::Accelerator& accelerator) const;
115 118
116 ui::AcceleratorHistory* accelerator_history() { 119 ui::AcceleratorHistory* accelerator_history() {
117 return accelerator_history_.get(); 120 return accelerator_history_.get();
118 } 121 }
119 122
120 // Overridden from ui::AcceleratorTarget: 123 // Overridden from ui::AcceleratorTarget:
121 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 124 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
122 bool CanHandleAccelerators() const override; 125 bool CanHandleAccelerators() const override;
123 126
127 // Binds the mojom::AcceleratorController interface to this object.
128 void BindRequest(mojom::AcceleratorControllerRequest request);
129
130 // mojom::AcceleratorController:
131 void SetVolumeController(mojom::VolumeControllerPtr controller) override;
132
124 private: 133 private:
125 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); 134 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators);
126 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, 135 FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest,
127 DontRepeatToggleFullscreen); 136 DontRepeatToggleFullscreen);
128 FRIEND_TEST_ALL_PREFIXES(DeprecatedAcceleratorTester, 137 FRIEND_TEST_ALL_PREFIXES(DeprecatedAcceleratorTester,
129 TestDeprecatedAcceleratorsBehavior); 138 TestDeprecatedAcceleratorsBehavior);
130 139
131 // Initializes the accelerators this class handles as a target. 140 // Initializes the accelerators this class handles as a target.
132 void Init(); 141 void Init();
133 142
(...skipping 15 matching lines...) Expand all
149 const ui::Accelerator& accelerator); 158 const ui::Accelerator& accelerator);
150 159
151 // Returns whether performing |action| should consume the key event. 160 // Returns whether performing |action| should consume the key event.
152 bool ShouldActionConsumeKeyEvent(AcceleratorAction action); 161 bool ShouldActionConsumeKeyEvent(AcceleratorAction action);
153 162
154 // Get the accelerator restriction for the given action. Supply an |action| 163 // Get the accelerator restriction for the given action. Supply an |action|
155 // of -1 to get restrictions that apply for the current context. 164 // of -1 to get restrictions that apply for the current context.
156 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction( 165 AcceleratorProcessingRestriction GetAcceleratorProcessingRestriction(
157 int action); 166 int action);
158 167
159 // Returns the volume controller interface raw pointer, may be null in tests.
160 mojom::VolumeController* GetVolumeController();
161 void OnVolumeControllerConnectionError();
162
163 AcceleratorControllerDelegate* delegate_; 168 AcceleratorControllerDelegate* delegate_;
164 169
165 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_; 170 std::unique_ptr<ui::AcceleratorManager> accelerator_manager_;
166 171
167 // A tracker for the current and previous accelerators. 172 // A tracker for the current and previous accelerators.
168 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_; 173 std::unique_ptr<ui::AcceleratorHistory> accelerator_history_;
169 174
170 std::unique_ptr<ImeControlDelegate> ime_control_delegate_; 175 std::unique_ptr<ImeControlDelegate> ime_control_delegate_;
171 176
172 // Handles the exit accelerator which requires a double press to exit and 177 // Handles the exit accelerator which requires a double press to exit and
173 // shows a popup with an explanation. 178 // shows a popup with an explanation.
174 ExitWarningHandler exit_warning_handler_; 179 ExitWarningHandler exit_warning_handler_;
175 180
176 // A map from accelerators to the AcceleratorAction values, which are used in 181 // A map from accelerators to the AcceleratorAction values, which are used in
177 // the implementation. 182 // the implementation.
178 std::map<ui::Accelerator, AcceleratorAction> accelerators_; 183 std::map<ui::Accelerator, AcceleratorAction> accelerators_;
179 184
180 std::map<AcceleratorAction, const DeprecatedAcceleratorData*> 185 std::map<AcceleratorAction, const DeprecatedAcceleratorData*>
181 actions_with_deprecations_; 186 actions_with_deprecations_;
182 std::set<ui::Accelerator> deprecated_accelerators_; 187 std::set<ui::Accelerator> deprecated_accelerators_;
183 188
184 // The cached volume controller interface pointer. 189 // Bindings for the mojom::AcceleratorController interface.
190 mojo::BindingSet<mojom::AcceleratorController> bindings_;
191
192 // Volume controller interface in chrome browser. May be null in tests. Exists
193 // because chrome owns the CrasAudioHandler dbus communication.
185 mojom::VolumeControllerPtr volume_controller_; 194 mojom::VolumeControllerPtr volume_controller_;
186 195
187 // Actions allowed when the user is not signed in. 196 // Actions allowed when the user is not signed in.
188 std::set<int> actions_allowed_at_login_screen_; 197 std::set<int> actions_allowed_at_login_screen_;
189 // Actions allowed when the screen is locked. 198 // Actions allowed when the screen is locked.
190 std::set<int> actions_allowed_at_lock_screen_; 199 std::set<int> actions_allowed_at_lock_screen_;
191 // Actions allowed when a modal window is up. 200 // Actions allowed when a modal window is up.
192 std::set<int> actions_allowed_at_modal_window_; 201 std::set<int> actions_allowed_at_modal_window_;
193 // Preferred actions. See accelerator_table.h for details. 202 // Preferred actions. See accelerator_table.h for details.
194 std::set<int> preferred_actions_; 203 std::set<int> preferred_actions_;
195 // Reserved actions. See accelerator_table.h for details. 204 // Reserved actions. See accelerator_table.h for details.
196 std::set<int> reserved_actions_; 205 std::set<int> reserved_actions_;
197 // Actions which will be repeated while holding the accelerator key. 206 // Actions which will be repeated while holding the accelerator key.
198 std::set<int> repeatable_actions_; 207 std::set<int> repeatable_actions_;
199 // Actions allowed in app mode. 208 // Actions allowed in app mode.
200 std::set<int> actions_allowed_in_app_mode_; 209 std::set<int> actions_allowed_in_app_mode_;
201 // Actions allowed in pinned mode. 210 // Actions allowed in pinned mode.
202 std::set<int> actions_allowed_in_pinned_mode_; 211 std::set<int> actions_allowed_in_pinned_mode_;
203 // Actions disallowed if there are no windows. 212 // Actions disallowed if there are no windows.
204 std::set<int> actions_needing_window_; 213 std::set<int> actions_needing_window_;
205 // Actions that can be performed without closing the menu (if one is present). 214 // Actions that can be performed without closing the menu (if one is present).
206 std::set<int> actions_keeping_menu_open_; 215 std::set<int> actions_keeping_menu_open_;
207 216
208 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); 217 DISALLOW_COPY_AND_ASSIGN(AcceleratorController);
209 }; 218 };
210 219
211 } // namespace ash 220 } // namespace ash
212 221
213 #endif // ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ 222 #endif // ASH_COMMON_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/common/accelerators/accelerator_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698