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

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

Issue 2162193003: Separates out accelerators using non-common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accelerators
Patch Set: sim=20 Created 4 years, 5 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
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 #include "ash/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include <algorithm>
8 #include <cmath>
9 #include <string>
10 #include <utility>
11
12 #include "ash/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/accelerators/accelerator_controller_delegate.h"
13 #include "ash/accelerators/debug_commands.h" 9 #include "ash/accelerators/debug_commands.h"
14 #include "ash/common/accessibility_delegate.h" 10 #include "ash/common/accessibility_delegate.h"
15 #include "ash/common/accessibility_types.h" 11 #include "ash/common/accessibility_types.h"
16 #include "ash/common/ash_switches.h"
17 #include "ash/common/focus_cycler.h" 12 #include "ash/common/focus_cycler.h"
18 #include "ash/common/gpu_support.h"
19 #include "ash/common/media_delegate.h" 13 #include "ash/common/media_delegate.h"
20 #include "ash/common/multi_profile_uma.h" 14 #include "ash/common/multi_profile_uma.h"
21 #include "ash/common/session/session_state_delegate.h" 15 #include "ash/common/session/session_state_delegate.h"
22 #include "ash/common/shelf/shelf_model.h"
23 #include "ash/common/shell_delegate.h" 16 #include "ash/common/shell_delegate.h"
24 #include "ash/common/shell_window_ids.h"
25 #include "ash/common/system/brightness_control_delegate.h" 17 #include "ash/common/system/brightness_control_delegate.h"
26 #include "ash/common/system/keyboard_brightness_control_delegate.h" 18 #include "ash/common/system/keyboard_brightness_control_delegate.h"
27 #include "ash/common/system/status_area_widget.h"
28 #include "ash/common/system/system_notifier.h"
29 #include "ash/common/system/tray/system_tray.h"
30 #include "ash/common/system/tray/system_tray_delegate.h" 19 #include "ash/common/system/tray/system_tray_delegate.h"
31 #include "ash/common/system/tray/system_tray_notifier.h" 20 #include "ash/common/system/tray/system_tray_notifier.h"
32 #include "ash/common/system/volume_control_delegate.h" 21 #include "ash/common/system/volume_control_delegate.h"
33 #include "ash/common/system/web_notification/web_notification_tray.h"
34 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
35 #include "ash/common/wm/mru_window_tracker.h" 22 #include "ash/common/wm/mru_window_tracker.h"
36 #include "ash/common/wm/overview/window_selector_controller.h" 23 #include "ash/common/wm/overview/window_selector_controller.h"
37 #include "ash/common/wm/window_cycle_controller.h" 24 #include "ash/common/wm/window_cycle_controller.h"
25 #include "ash/common/wm/window_positioning_utils.h"
38 #include "ash/common/wm/window_state.h" 26 #include "ash/common/wm/window_state.h"
39 #include "ash/common/wm/wm_event.h" 27 #include "ash/common/wm/wm_event.h"
40 #include "ash/common/wm_shell.h" 28 #include "ash/common/wm_shell.h"
41 #include "ash/debug.h" 29 #include "ash/common/wm_window.h"
42 #include "ash/display/window_tree_host_manager.h"
43 #include "ash/ime_control_delegate.h" 30 #include "ash/ime_control_delegate.h"
44 #include "ash/magnifier/magnification_controller.h"
45 #include "ash/magnifier/partial_magnification_controller.h"
46 #include "ash/new_window_delegate.h"
47 #include "ash/root_window_controller.h"
48 #include "ash/rotator/screen_rotation_animator.h"
49 #include "ash/rotator/window_rotation.h"
50 #include "ash/screen_util.h"
51 #include "ash/screenshot_delegate.h"
52 #include "ash/shelf/shelf.h"
53 #include "ash/shelf/shelf_delegate.h"
54 #include "ash/shelf/shelf_widget.h"
55 #include "ash/shell.h"
56 #include "ash/touch/touch_hud_debug.h"
57 #include "ash/utility/screenshot_controller.h"
58 #include "ash/wm/power_button_controller.h"
59 #include "ash/wm/window_state_aura.h"
60 #include "ash/wm/window_util.h"
61 #include "base/bind.h"
62 #include "base/command_line.h"
63 #include "base/metrics/histogram_macros.h" 31 #include "base/metrics/histogram_macros.h"
64 #include "base/metrics/user_metrics.h" 32 #include "base/metrics/user_metrics.h"
65 #include "base/strings/string_split.h"
66 #include "base/strings/utf_string_conversions.h"
67 #include "ui/aura/env.h"
68 #include "ui/base/accelerators/accelerator.h" 33 #include "ui/base/accelerators/accelerator.h"
69 #include "ui/base/accelerators/accelerator_manager.h" 34 #include "ui/base/accelerators/accelerator_manager.h"
70 #include "ui/base/l10n/l10n_util.h"
71 #include "ui/base/resource/resource_bundle.h"
72 #include "ui/compositor/layer.h"
73 #include "ui/compositor/layer_animation_sequence.h"
74 #include "ui/compositor/layer_animator.h"
75 #include "ui/display/screen.h"
76 #include "ui/events/event.h"
77 #include "ui/events/keycodes/keyboard_codes.h"
78 #include "ui/message_center/message_center.h"
79 #include "ui/message_center/notification.h"
80 #include "ui/message_center/notifier_settings.h"
81 35
82 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
83 #include "ash/display/display_configuration_controller.h"
84 #include "base/sys_info.h"
85 #include "chromeos/dbus/dbus_thread_manager.h" 37 #include "chromeos/dbus/dbus_thread_manager.h"
86 #include "chromeos/dbus/power_manager_client.h" 38 #include "chromeos/dbus/power_manager_client.h"
87 #include "ui/base/ime/chromeos/ime_keyboard.h" 39 #include "ui/base/ime/chromeos/ime_keyboard.h"
88 #include "ui/base/ime/chromeos/input_method_manager.h" 40 #include "ui/base/ime/chromeos/input_method_manager.h"
89 #endif // defined(OS_CHROMEOS) 41 #endif // defined(OS_CHROMEOS)
90 42
91 namespace ash { 43 namespace ash {
92 namespace { 44 namespace {
93 45
94 using base::UserMetricsAction; 46 using base::UserMetricsAction;
95 47
96 // The notification delegate that will be used to open the keyboard shortcut
97 // help page when the notification is clicked.
98 class DeprecatedAcceleratorNotificationDelegate
99 : public message_center::NotificationDelegate {
100 public:
101 DeprecatedAcceleratorNotificationDelegate() {}
102
103 // message_center::NotificationDelegate:
104 bool HasClickedListener() override { return true; }
105
106 void Click() override {
107 if (!WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked())
108 WmShell::Get()->delegate()->OpenKeyboardShortcutHelpPage();
109 }
110
111 private:
112 // Private destructor since NotificationDelegate is ref-counted.
113 ~DeprecatedAcceleratorNotificationDelegate() override {}
114
115 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate);
116 };
117
118 ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode, 48 ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode,
119 int modifiers, 49 int modifiers,
120 bool trigger_on_press) { 50 bool trigger_on_press) {
121 ui::Accelerator accelerator(keycode, modifiers); 51 ui::Accelerator accelerator(keycode, modifiers);
122 accelerator.set_type(trigger_on_press ? ui::ET_KEY_PRESSED 52 accelerator.set_type(trigger_on_press ? ui::ET_KEY_PRESSED
123 : ui::ET_KEY_RELEASED); 53 : ui::ET_KEY_RELEASED);
124 return accelerator; 54 return accelerator;
125 } 55 }
126 56
127 // Ensures that there are no word breaks at the "+"s in the shortcut texts such
128 // as "Ctrl+Shift+Space".
129 void EnsureNoWordBreaks(base::string16* shortcut_text) {
130 std::vector<base::string16> keys =
131 base::SplitString(*shortcut_text, base::ASCIIToUTF16("+"),
132 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
133
134 if (keys.size() < 2U)
135 return;
136
137 // The plus sign surrounded by the word joiner to guarantee an non-breaking
138 // shortcut.
139 const base::string16 non_breaking_plus =
140 base::UTF8ToUTF16("\xe2\x81\xa0+\xe2\x81\xa0");
141 shortcut_text->clear();
142 for (size_t i = 0; i < keys.size() - 1; ++i) {
143 *shortcut_text += keys[i];
144 *shortcut_text += non_breaking_plus;
145 }
146
147 *shortcut_text += keys.back();
148 }
149
150 // Gets the notification message after it formats it in such a way that there
151 // are no line breaks in the middle of the shortcut texts.
152 base::string16 GetNotificationText(int message_id,
153 int old_shortcut_id,
154 int new_shortcut_id) {
155 base::string16 old_shortcut = l10n_util::GetStringUTF16(old_shortcut_id);
156 base::string16 new_shortcut = l10n_util::GetStringUTF16(new_shortcut_id);
157 EnsureNoWordBreaks(&old_shortcut);
158 EnsureNoWordBreaks(&new_shortcut);
159
160 return l10n_util::GetStringFUTF16(message_id, new_shortcut, old_shortcut);
161 }
162
163 void ShowDeprecatedAcceleratorNotification(const char* const notification_id,
164 int message_id,
165 int old_shortcut_id,
166 int new_shortcut_id) {
167 const base::string16 message =
168 GetNotificationText(message_id, old_shortcut_id, new_shortcut_id);
169 std::unique_ptr<message_center::Notification> notification(
170 new message_center::Notification(
171 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id,
172 base::string16(), message,
173 WmShell::Get()->delegate()->GetDeprecatedAcceleratorImage(),
174 base::string16(), GURL(),
175 message_center::NotifierId(
176 message_center::NotifierId::SYSTEM_COMPONENT,
177 system_notifier::kNotifierDeprecatedAccelerator),
178 message_center::RichNotificationData(),
179 new DeprecatedAcceleratorNotificationDelegate));
180 message_center::MessageCenter::Get()->AddNotification(
181 std::move(notification));
182 }
183
184 void RecordUmaHistogram(const char* histogram_name, 57 void RecordUmaHistogram(const char* histogram_name,
185 DeprecatedAcceleratorUsage sample) { 58 DeprecatedAcceleratorUsage sample) {
186 auto* histogram = base::LinearHistogram::FactoryGet( 59 auto* histogram = base::LinearHistogram::FactoryGet(
187 histogram_name, 1, DEPRECATED_USAGE_COUNT, DEPRECATED_USAGE_COUNT + 1, 60 histogram_name, 1, DEPRECATED_USAGE_COUNT, DEPRECATED_USAGE_COUNT + 1,
188 base::HistogramBase::kUmaTargetedHistogramFlag); 61 base::HistogramBase::kUmaTargetedHistogramFlag);
189 histogram->Add(sample); 62 histogram->Add(sample);
190 } 63 }
191 64
192 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { 65 void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) {
193 if (accelerator.key_code() == ui::VKEY_TAB) 66 if (accelerator.key_code() == ui::VKEY_TAB)
(...skipping 19 matching lines...) Expand all
213 break; 86 break;
214 } 87 }
215 case FocusCycler::BACKWARD: { 88 case FocusCycler::BACKWARD: {
216 base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane")); 89 base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane"));
217 break; 90 break;
218 } 91 }
219 } 92 }
220 WmShell::Get()->focus_cycler()->RotateFocus(direction); 93 WmShell::Get()->focus_cycler()->RotateFocus(direction);
221 } 94 }
222 95
223 void HandleFocusShelf() {
224 base::RecordAction(base::UserMetricsAction("Accel_Focus_Shelf"));
225 WmShell::Get()->focus_cycler()->FocusWidget(
226 Shelf::ForPrimaryDisplay()->shelf_widget());
227 }
228
229 void HandleLaunchAppN(int n) {
230 base::RecordAction(UserMetricsAction("Accel_Launch_App"));
231 Shelf::ForPrimaryDisplay()->LaunchAppIndexAt(n);
232 }
233
234 void HandleLaunchLastApp() {
235 base::RecordAction(UserMetricsAction("Accel_Launch_Last_App"));
236 Shelf::ForPrimaryDisplay()->LaunchAppIndexAt(-1);
237 }
238
239 bool CanHandleMagnifyScreen() {
240 Shell* shell = Shell::GetInstance();
241 return shell->magnification_controller()->IsEnabled() ||
242 shell->partial_magnification_controller()->is_enabled();
243 }
244
245 // Magnify the screen
246 void HandleMagnifyScreen(int delta_index) {
247 if (Shell::GetInstance()->magnification_controller()->IsEnabled()) {
248 // TODO(yoshiki): Move the following logic to MagnificationController.
249 float scale = Shell::GetInstance()->magnification_controller()->GetScale();
250 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale.
251 int scale_index =
252 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5);
253
254 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index));
255
256 Shell::GetInstance()->magnification_controller()->SetScale(
257 std::pow(kMagnificationScaleFactor, new_scale_index), true);
258 } else if (Shell::GetInstance()
259 ->partial_magnification_controller()
260 ->is_enabled()) {
261 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1;
262 Shell::GetInstance()->partial_magnification_controller()->SetScale(scale);
263 }
264 }
265
266 void HandleMediaNextTrack() { 96 void HandleMediaNextTrack() {
267 WmShell::Get()->media_delegate()->HandleMediaNextTrack(); 97 WmShell::Get()->media_delegate()->HandleMediaNextTrack();
268 } 98 }
269 99
270 void HandleMediaPlayPause() { 100 void HandleMediaPlayPause() {
271 WmShell::Get()->media_delegate()->HandleMediaPlayPause(); 101 WmShell::Get()->media_delegate()->HandleMediaPlayPause();
272 } 102 }
273 103
274 void HandleMediaPrevTrack() { 104 void HandleMediaPrevTrack() {
275 WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); 105 WmShell::Get()->media_delegate()->HandleMediaPrevTrack();
276 } 106 }
277 107
278 bool CanHandleNewIncognitoWindow() {
279 return WmShell::Get()->delegate()->IsIncognitoAllowed();
280 }
281
282 void HandleNewIncognitoWindow() {
283 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window"));
284 Shell::GetInstance()->new_window_delegate()->NewWindow(
285 true /* is_incognito */);
286 }
287
288 void HandleNewTab(const ui::Accelerator& accelerator) {
289 if (accelerator.key_code() == ui::VKEY_T)
290 base::RecordAction(base::UserMetricsAction("Accel_NewTab_T"));
291 Shell::GetInstance()->new_window_delegate()->NewTab();
292 }
293
294 void HandleNewWindow() {
295 base::RecordAction(base::UserMetricsAction("Accel_New_Window"));
296 Shell::GetInstance()->new_window_delegate()->NewWindow(
297 false /* is_incognito */);
298 }
299
300 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { 108 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) {
301 return ime_control_delegate && ime_control_delegate->CanCycleIme(); 109 return ime_control_delegate && ime_control_delegate->CanCycleIme();
302 } 110 }
303 111
304 // We must avoid showing the Deprecated NEXT_IME notification erronously. 112 // We must avoid showing the Deprecated NEXT_IME notification erronously.
305 bool ShouldShowDeprecatedNextImeNotification( 113 bool ShouldShowDeprecatedNextImeNotification(
306 const ui::Accelerator& previous_accelerator) { 114 const ui::Accelerator& previous_accelerator) {
307 // We only show the deprecation notification if the previous accelerator key 115 // We only show the deprecation notification if the previous accelerator key
308 // is ONLY either Shift, or Alt. 116 // is ONLY either Shift, or Alt.
309 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); 117 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
310 switch (previous_key_code) { 118 switch (previous_key_code) {
311 case ui::VKEY_SHIFT: 119 case ui::VKEY_SHIFT:
312 case ui::VKEY_LSHIFT: 120 case ui::VKEY_LSHIFT:
313 case ui::VKEY_RSHIFT: 121 case ui::VKEY_RSHIFT:
314 case ui::VKEY_MENU: 122 case ui::VKEY_MENU:
315 case ui::VKEY_LMENU: 123 case ui::VKEY_LMENU:
316 case ui::VKEY_RMENU: 124 case ui::VKEY_RMENU:
317 return true; 125 return true;
318 126
319 default: 127 default:
320 return false; 128 return false;
321 } 129 }
322 } 130 }
323 131
324 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { 132 void HandleNextIme(ImeControlDelegate* ime_control_delegate) {
325 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); 133 base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
326 ime_control_delegate->HandleNextIme(); 134 ime_control_delegate->HandleNextIme();
327 } 135 }
328 136
329 void HandleOpenFeedbackPage() {
330 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page"));
331 Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
332 }
333
334 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) { 137 bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) {
335 return ime_control_delegate && ime_control_delegate->CanCycleIme(); 138 return ime_control_delegate && ime_control_delegate->CanCycleIme();
336 } 139 }
337 140
338 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate, 141 void HandlePreviousIme(ImeControlDelegate* ime_control_delegate,
339 const ui::Accelerator& accelerator) { 142 const ui::Accelerator& accelerator) {
340 base::RecordAction(UserMetricsAction("Accel_Previous_Ime")); 143 base::RecordAction(UserMetricsAction("Accel_Previous_Ime"));
341 if (accelerator.type() == ui::ET_KEY_PRESSED) 144 if (accelerator.type() == ui::ET_KEY_PRESSED)
342 ime_control_delegate->HandlePreviousIme(); 145 ime_control_delegate->HandlePreviousIme();
343 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything. 146 // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything.
344 } 147 }
345 148
346 void HandleRestoreTab() {
347 base::RecordAction(base::UserMetricsAction("Accel_Restore_Tab"));
348 Shell::GetInstance()->new_window_delegate()->RestoreTab();
349 }
350
351 display::Display::Rotation GetNextRotation(display::Display::Rotation current) {
352 switch (current) {
353 case display::Display::ROTATE_0:
354 return display::Display::ROTATE_90;
355 case display::Display::ROTATE_90:
356 return display::Display::ROTATE_180;
357 case display::Display::ROTATE_180:
358 return display::Display::ROTATE_270;
359 case display::Display::ROTATE_270:
360 return display::Display::ROTATE_0;
361 }
362 NOTREACHED() << "Unknown rotation:" << current;
363 return display::Display::ROTATE_0;
364 }
365
366 // Rotates the screen.
367 void HandleRotateScreen() {
368 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode())
369 return;
370
371 base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
372 gfx::Point point = display::Screen::GetScreen()->GetCursorScreenPoint();
373 display::Display display =
374 display::Screen::GetScreen()->GetDisplayNearestPoint(point);
375 const DisplayInfo& display_info =
376 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
377 ScreenRotationAnimator(display.id())
378 .Rotate(GetNextRotation(display_info.GetActiveRotation()),
379 display::Display::ROTATION_SOURCE_USER);
380 }
381
382 // Rotate the active window.
383 void HandleRotateActiveWindow() {
384 base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
385 aura::Window* active_window = wm::GetActiveWindow();
386 if (active_window) {
387 // The rotation animation bases its target transform on the current
388 // rotation and position. Since there could be an animation in progress
389 // right now, queue this animation so when it starts it picks up a neutral
390 // rotation and position. Use replace so we only enqueue one at a time.
391 active_window->layer()->GetAnimator()->set_preemption_strategy(
392 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
393 active_window->layer()->GetAnimator()->StartAnimation(
394 new ui::LayerAnimationSequence(
395 new WindowRotation(360, active_window->layer())));
396 }
397 }
398
399 void HandleShowKeyboardOverlay() {
400 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay"));
401 Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
402 }
403
404 bool CanHandleShowMessageCenterBubble() {
405 RootWindowController* controller =
406 RootWindowController::ForTargetRootWindow();
407 StatusAreaWidget* status_area_widget =
408 controller->shelf_widget()->status_area_widget();
409 return status_area_widget &&
410 status_area_widget->web_notification_tray()->visible();
411 }
412
413 void HandleShowMessageCenterBubble() {
414 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble"));
415 RootWindowController* controller =
416 RootWindowController::ForTargetRootWindow();
417 StatusAreaWidget* status_area_widget =
418 controller->shelf_widget()->status_area_widget();
419 if (status_area_widget) {
420 WebNotificationTray* notification_tray =
421 status_area_widget->web_notification_tray();
422 if (notification_tray->visible())
423 notification_tray->ShowMessageCenterBubble();
424 }
425 }
426
427 void HandleShowSystemTrayBubble() {
428 base::RecordAction(UserMetricsAction("Accel_Show_System_Tray_Bubble"));
429 RootWindowController* controller =
430 RootWindowController::ForTargetRootWindow();
431 if (!controller->GetSystemTray()->HasSystemBubble())
432 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
433 }
434
435 void HandleShowTaskManager() {
436 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager"));
437 Shell::GetInstance()->new_window_delegate()->ShowTaskManager();
438 }
439
440 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate, 149 bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate,
441 const ui::Accelerator& accelerator) { 150 const ui::Accelerator& accelerator) {
442 return ime_control_delegate && 151 return ime_control_delegate &&
443 ime_control_delegate->CanSwitchIme(accelerator); 152 ime_control_delegate->CanSwitchIme(accelerator);
444 } 153 }
445 154
446 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate, 155 void HandleSwitchIme(ImeControlDelegate* ime_control_delegate,
447 const ui::Accelerator& accelerator) { 156 const ui::Accelerator& accelerator) {
448 base::RecordAction(UserMetricsAction("Accel_Switch_Ime")); 157 base::RecordAction(UserMetricsAction("Accel_Switch_Ime"));
449 ime_control_delegate->HandleSwitchIme(accelerator); 158 ime_control_delegate->HandleSwitchIme(accelerator);
450 } 159 }
451 160
452 void HandleTakeWindowScreenshot(ScreenshotDelegate* screenshot_delegate) {
453 base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot"));
454 DCHECK(screenshot_delegate);
455 Shell::GetInstance()->screenshot_controller()->StartWindowScreenshotSession(
456 screenshot_delegate);
457 }
458
459 void HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) {
460 base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot"));
461 DCHECK(screenshot_delegate);
462 Shell::GetInstance()->screenshot_controller()->StartPartialScreenshotSession(
463 screenshot_delegate);
464 }
465
466 void HandleTakeScreenshot(ScreenshotDelegate* screenshot_delegate) {
467 base::RecordAction(UserMetricsAction("Accel_Take_Screenshot"));
468 DCHECK(screenshot_delegate);
469 if (screenshot_delegate->CanTakeScreenshot())
470 screenshot_delegate->HandleTakeScreenshotForAllRootWindows();
471 }
472
473 bool CanHandleToggleAppList(const ui::Accelerator& accelerator,
474 const ui::Accelerator& previous_accelerator) {
475 if (accelerator.key_code() == ui::VKEY_LWIN) {
476 // If something else was pressed between the Search key (LWIN)
477 // being pressed and released, then ignore the release of the
478 // Search key.
479 if (previous_accelerator.type() != ui::ET_KEY_PRESSED ||
480 previous_accelerator.key_code() != ui::VKEY_LWIN) {
481 return false;
482 }
483
484 // When spoken feedback is enabled, we should neither toggle the list nor
485 // consume the key since Search+Shift is one of the shortcuts the a11y
486 // feature uses. crbug.com/132296
487 if (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled())
488 return false;
489 }
490 return true;
491 }
492
493 void HandleToggleAppList(const ui::Accelerator& accelerator) {
494 if (accelerator.key_code() == ui::VKEY_LWIN)
495 base::RecordAction(base::UserMetricsAction("Accel_Search_LWin"));
496 Shell::GetInstance()->ToggleAppList(NULL);
497 }
498
499 void HandleToggleFullscreen(const ui::Accelerator& accelerator) { 161 void HandleToggleFullscreen(const ui::Accelerator& accelerator) {
500 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2) 162 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2)
501 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); 163 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4"));
502 accelerators::ToggleFullscreen(); 164 accelerators::ToggleFullscreen();
503 } 165 }
504 166
505 void HandleToggleOverview() { 167 void HandleToggleOverview() {
506 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); 168 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5"));
507 WmShell::Get()->window_selector_controller()->ToggleOverview(); 169 WmShell::Get()->window_selector_controller()->ToggleOverview();
508 } 170 }
509 171
510 bool CanHandleWindowSnapOrDock() { 172 bool CanHandleWindowSnapOrDock() {
511 wm::WindowState* window_state = wm::GetActiveWindowState(); 173 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
174 if (!active_window)
175 return false;
176 wm::WindowState* window_state = active_window->GetWindowState();
512 // Disable window snapping shortcut key for full screen window due to 177 // Disable window snapping shortcut key for full screen window due to
513 // http://crbug.com/135487. 178 // http://crbug.com/135487.
514 return (window_state && window_state->IsUserPositionable() && 179 return (window_state && window_state->IsUserPositionable() &&
515 !window_state->IsFullscreen()); 180 !window_state->IsFullscreen());
516 } 181 }
517 182
518 void HandleWindowSnapOrDock(AcceleratorAction action) { 183 void HandleWindowSnapOrDock(AcceleratorAction action) {
519 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) 184 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT)
520 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); 185 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left"));
521 else 186 else
522 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); 187 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right"));
523 188
524 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT 189 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT
525 ? wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT 190 ? wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT
526 : wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); 191 : wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT);
527 wm::GetActiveWindowState()->OnWMEvent(&event); 192 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
193 DCHECK(active_window);
194 active_window->GetWindowState()->OnWMEvent(&event);
528 } 195 }
529 196
530 void HandleWindowMinimize() { 197 void HandleWindowMinimize() {
531 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); 198 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus"));
532 accelerators::ToggleMinimized(); 199 accelerators::ToggleMinimized();
533 } 200 }
534 201
535 bool CanHandlePositionCenter() { 202 bool CanHandlePositionCenter() {
536 // Docked windows do not support centering. 203 // Docked windows do not support centering.
537 wm::WindowState* window_state = wm::GetActiveWindowState(); 204 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
538 return (window_state && !window_state->IsDocked()); 205 return (active_window && !active_window->GetWindowState()->IsDocked());
539 } 206 }
540 207
541 void HandlePositionCenter() { 208 void HandlePositionCenter() {
542 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); 209 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center"));
543 wm::CenterWindow(wm::GetActiveWindow()); 210 wm::CenterWindow(WmShell::Get()->GetActiveWindow());
544 }
545
546 bool CanHandleUnpin() {
547 wm::WindowState* window_state = wm::GetActiveWindowState();
548 return window_state && window_state->IsPinned();
549 }
550
551 void HandleUnpin() {
552 accelerators::Unpin();
553 } 211 }
554 212
555 #if defined(OS_CHROMEOS) 213 #if defined(OS_CHROMEOS)
556 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) { 214 bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) {
557 ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); 215 ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
558 if (previous_accelerator.type() == ui::ET_KEY_RELEASED || 216 if (previous_accelerator.type() == ui::ET_KEY_RELEASED ||
559 (previous_key_code != ui::VKEY_LSHIFT && 217 (previous_key_code != ui::VKEY_LSHIFT &&
560 previous_key_code != ui::VKEY_SHIFT && 218 previous_key_code != ui::VKEY_SHIFT &&
561 previous_key_code != ui::VKEY_RSHIFT)) { 219 previous_key_code != ui::VKEY_RSHIFT)) {
562 // If something else was pressed between the Shift key being pressed 220 // If something else was pressed between the Shift key being pressed
(...skipping 21 matching lines...) Expand all
584 void HandleLock() { 242 void HandleLock() {
585 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); 243 base::RecordAction(UserMetricsAction("Accel_LockScreen_L"));
586 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); 244 WmShell::Get()->GetSessionStateDelegate()->LockScreen();
587 } 245 }
588 246
589 void HandleSuspend() { 247 void HandleSuspend() {
590 base::RecordAction(UserMetricsAction("Accel_Suspend")); 248 base::RecordAction(UserMetricsAction("Accel_Suspend"));
591 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); 249 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend();
592 } 250 }
593 251
594 void HandleCrosh() {
595 base::RecordAction(UserMetricsAction("Accel_Open_Crosh"));
596
597 Shell::GetInstance()->new_window_delegate()->OpenCrosh();
598 }
599
600 void HandleFileManager() {
601 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager"));
602
603 Shell::GetInstance()->new_window_delegate()->OpenFileManager();
604 }
605
606 void HandleGetHelp() {
607 Shell::GetInstance()->new_window_delegate()->OpenGetHelp();
608 }
609
610 void HandleSwapPrimaryDisplay() {
611 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
612 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId(
613 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */);
614 }
615
616 bool CanHandleCycleUser() { 252 bool CanHandleCycleUser() {
617 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && 253 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() &&
618 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1; 254 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1;
619 } 255 }
620 256
621 void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) { 257 void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) {
622 MultiProfileUMA::RecordSwitchActiveUser( 258 MultiProfileUMA::RecordSwitchActiveUser(
623 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); 259 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR);
624 switch (cycle_user) { 260 switch (cycle_user) {
625 case SessionStateDelegate::CYCLE_TO_NEXT_USER: 261 case SessionStateDelegate::CYCLE_TO_NEXT_USER:
(...skipping 23 matching lines...) Expand all
649 } 285 }
650 286
651 void HandleToggleCapsLock() { 287 void HandleToggleCapsLock() {
652 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); 288 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock"));
653 chromeos::input_method::InputMethodManager* ime = 289 chromeos::input_method::InputMethodManager* ime =
654 chromeos::input_method::InputMethodManager::Get(); 290 chromeos::input_method::InputMethodManager::Get();
655 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); 291 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard();
656 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); 292 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled());
657 } 293 }
658 294
659 void HandleToggleMirrorMode() {
660 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode"));
661 bool mirror = !Shell::GetInstance()->display_manager()->IsInMirrorMode();
662 Shell::GetInstance()->display_configuration_controller()->SetMirrorMode(
663 mirror, true /* user_action */);
664 }
665
666 void HandleToggleSpokenFeedback() { 295 void HandleToggleSpokenFeedback() {
667 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); 296 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback"));
668 297
669 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( 298 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback(
670 A11Y_NOTIFICATION_SHOW); 299 A11Y_NOTIFICATION_SHOW);
671 } 300 }
672 301
673 bool CanHandleTouchHud() {
674 return RootWindowController::ForTargetRootWindow()->touch_hud_debug();
675 }
676
677 void HandleTouchHudClear() {
678 RootWindowController::ForTargetRootWindow()->touch_hud_debug()->Clear();
679 }
680
681 void HandleTouchHudModeChange() {
682 RootWindowController* controller =
683 RootWindowController::ForTargetRootWindow();
684 controller->touch_hud_debug()->ChangeToNextMode();
685 }
686
687 void HandleVolumeDown(const ui::Accelerator& accelerator) { 302 void HandleVolumeDown(const ui::Accelerator& accelerator) {
688 VolumeControlDelegate* volume_delegate = 303 VolumeControlDelegate* volume_delegate =
689 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); 304 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate();
690 if (volume_delegate) 305 if (volume_delegate)
691 volume_delegate->HandleVolumeDown(accelerator); 306 volume_delegate->HandleVolumeDown(accelerator);
692 } 307 }
693 308
694 void HandleVolumeMute(const ui::Accelerator& accelerator) { 309 void HandleVolumeMute(const ui::Accelerator& accelerator) {
695 VolumeControlDelegate* volume_delegate = 310 VolumeControlDelegate* volume_delegate =
696 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); 311 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate();
697 if (volume_delegate) 312 if (volume_delegate)
698 volume_delegate->HandleVolumeMute(accelerator); 313 volume_delegate->HandleVolumeMute(accelerator);
699 } 314 }
700 315
701 void HandleVolumeUp(const ui::Accelerator& accelerator) { 316 void HandleVolumeUp(const ui::Accelerator& accelerator) {
702 VolumeControlDelegate* volume_delegate = 317 VolumeControlDelegate* volume_delegate =
703 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); 318 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate();
704 if (volume_delegate) 319 if (volume_delegate)
705 volume_delegate->HandleVolumeUp(accelerator); 320 volume_delegate->HandleVolumeUp(accelerator);
706 } 321 }
707 322
708 #endif // defined(OS_CHROMEOS) 323 #endif // defined(OS_CHROMEOS)
709 324
710 } // namespace 325 } // namespace
711 326
712 //////////////////////////////////////////////////////////////////////////////// 327 ////////////////////////////////////////////////////////////////////////////////
713 // AcceleratorController, public: 328 // AcceleratorController, public:
714 329
715 AcceleratorController::AcceleratorController() 330 AcceleratorController::AcceleratorController(
716 : accelerator_manager_(new ui::AcceleratorManager), 331 AcceleratorControllerDelegate* delegate)
332 : delegate_(delegate),
333 accelerator_manager_(new ui::AcceleratorManager),
717 accelerator_history_(new ui::AcceleratorHistory) { 334 accelerator_history_(new ui::AcceleratorHistory) {
718 Init(); 335 Init();
719 } 336 }
720 337
721 AcceleratorController::~AcceleratorController() {} 338 AcceleratorController::~AcceleratorController() {}
722 339
723 void AcceleratorController::Register(const ui::Accelerator& accelerator, 340 void AcceleratorController::Register(const ui::Accelerator& accelerator,
724 ui::AcceleratorTarget* target) { 341 ui::AcceleratorTarget* target) {
725 accelerator_manager_->Register( 342 accelerator_manager_->Register(
726 accelerator, ui::AcceleratorManager::kNormalPriority, target); 343 accelerator, ui::AcceleratorManager::kNormalPriority, target);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 AcceleratorController::AcceleratorProcessingRestriction 397 AcceleratorController::AcceleratorProcessingRestriction
781 AcceleratorController::GetCurrentAcceleratorRestriction() { 398 AcceleratorController::GetCurrentAcceleratorRestriction() {
782 return GetAcceleratorProcessingRestriction(-1); 399 return GetAcceleratorProcessingRestriction(-1);
783 } 400 }
784 401
785 void AcceleratorController::SetImeControlDelegate( 402 void AcceleratorController::SetImeControlDelegate(
786 std::unique_ptr<ImeControlDelegate> ime_control_delegate) { 403 std::unique_ptr<ImeControlDelegate> ime_control_delegate) {
787 ime_control_delegate_ = std::move(ime_control_delegate); 404 ime_control_delegate_ = std::move(ime_control_delegate);
788 } 405 }
789 406
790 void AcceleratorController::SetScreenshotDelegate(
791 std::unique_ptr<ScreenshotDelegate> screenshot_delegate) {
792 screenshot_delegate_ = std::move(screenshot_delegate);
793 }
794
795 bool AcceleratorController::ShouldCloseMenuAndRepostAccelerator( 407 bool AcceleratorController::ShouldCloseMenuAndRepostAccelerator(
796 const ui::Accelerator& accelerator) const { 408 const ui::Accelerator& accelerator) const {
797 auto itr = accelerators_.find(accelerator); 409 auto itr = accelerators_.find(accelerator);
798 if (itr == accelerators_.end()) 410 if (itr == accelerators_.end())
799 return false; // Menu shouldn't be closed for an invalid accelerator. 411 return false; // Menu shouldn't be closed for an invalid accelerator.
800 412
801 AcceleratorAction action = itr->second; 413 AcceleratorAction action = itr->second;
802 return actions_keeping_menu_open_.count(action) == 0; 414 return actions_keeping_menu_open_.count(action) == 0;
803 } 415 }
804 416
(...skipping 15 matching lines...) Expand all
820 if (deprecated_accelerators_.count(accelerator)) { 432 if (deprecated_accelerators_.count(accelerator)) {
821 // This accelerator has been deprecated and should be treated according 433 // This accelerator has been deprecated and should be treated according
822 // to its |DeprecatedAcceleratorData|. 434 // to its |DeprecatedAcceleratorData|.
823 435
824 // Record UMA stats. 436 // Record UMA stats.
825 RecordUmaHistogram(data->uma_histogram_name, DEPRECATED_USED); 437 RecordUmaHistogram(data->uma_histogram_name, DEPRECATED_USED);
826 438
827 // We always display the notification as long as this entry exists, 439 // We always display the notification as long as this entry exists,
828 // except for NEXT_IME, we must check to avoid showing it for the wrong 440 // except for NEXT_IME, we must check to avoid showing it for the wrong
829 // shortcut, as Alt+Shift is tricky and trigger the action on release. 441 // shortcut, as Alt+Shift is tricky and trigger the action on release.
830 if (action != NEXT_IME || 442 if (delegate_ &&
831 (action == NEXT_IME && 443 (action != NEXT_IME ||
832 ShouldShowDeprecatedNextImeNotification( 444 (action == NEXT_IME &&
833 accelerator_history_->previous_accelerator()))) { 445 ShouldShowDeprecatedNextImeNotification(
834 ShowDeprecatedAcceleratorNotification( 446 accelerator_history_->previous_accelerator())))) {
447 delegate_->ShowDeprecatedAcceleratorNotification(
835 data->uma_histogram_name, data->notification_message_id, 448 data->uma_histogram_name, data->notification_message_id,
836 data->old_shortcut_id, data->new_shortcut_id); 449 data->old_shortcut_id, data->new_shortcut_id);
837 } 450 }
838 451
839 if (!data->deprecated_enabled) 452 if (!data->deprecated_enabled)
840 return false; 453 return false;
841 } else { 454 } else {
842 // This is a new accelerator replacing the old deprecated one. 455 // This is a new accelerator replacing the old deprecated one.
843 // Record UMA stats and proceed normally. 456 // Record UMA stats and proceed normally.
844 RecordUmaHistogram(data->uma_histogram_name, NEW_USED); 457 RecordUmaHistogram(data->uma_histogram_name, NEW_USED);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 case DEBUG_PRINT_LAYER_HIERARCHY: 566 case DEBUG_PRINT_LAYER_HIERARCHY:
954 case DEBUG_PRINT_VIEW_HIERARCHY: 567 case DEBUG_PRINT_VIEW_HIERARCHY:
955 case DEBUG_PRINT_WINDOW_HIERARCHY: 568 case DEBUG_PRINT_WINDOW_HIERARCHY:
956 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: 569 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
957 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: 570 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
958 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: 571 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
959 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: 572 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
960 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: 573 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
961 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: 574 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
962 return debug::DebugAcceleratorsEnabled(); 575 return debug::DebugAcceleratorsEnabled();
963 case MAGNIFY_SCREEN_ZOOM_IN:
964 case MAGNIFY_SCREEN_ZOOM_OUT:
965 return CanHandleMagnifyScreen();
966 case NEW_INCOGNITO_WINDOW:
967 return CanHandleNewIncognitoWindow();
968 case NEXT_IME: 576 case NEXT_IME:
969 return CanHandleNextIme(ime_control_delegate_.get()); 577 return CanHandleNextIme(ime_control_delegate_.get());
970 case PREVIOUS_IME: 578 case PREVIOUS_IME:
971 return CanHandlePreviousIme(ime_control_delegate_.get()); 579 return CanHandlePreviousIme(ime_control_delegate_.get());
972 case SCALE_UI_RESET:
973 case SCALE_UI_UP:
974 case SCALE_UI_DOWN:
975 return accelerators::IsInternalDisplayZoomEnabled();
976 case SHOW_MESSAGE_CENTER_BUBBLE:
977 return CanHandleShowMessageCenterBubble();
978 case SWITCH_IME: 580 case SWITCH_IME:
979 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); 581 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator);
980 case TOGGLE_APP_LIST:
981 return CanHandleToggleAppList(accelerator, previous_accelerator);
982 case WINDOW_CYCLE_SNAP_DOCK_LEFT: 582 case WINDOW_CYCLE_SNAP_DOCK_LEFT:
983 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: 583 case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
984 return CanHandleWindowSnapOrDock(); 584 return CanHandleWindowSnapOrDock();
985 case WINDOW_POSITION_CENTER: 585 case WINDOW_POSITION_CENTER:
986 return CanHandlePositionCenter(); 586 return CanHandlePositionCenter();
987 case UNPIN:
988 return CanHandleUnpin();
989 #if defined(OS_CHROMEOS) 587 #if defined(OS_CHROMEOS)
990 case DEBUG_ADD_REMOVE_DISPLAY: 588 case DEBUG_ADD_REMOVE_DISPLAY:
991 case DEBUG_SHOW_TOAST: 589 case DEBUG_SHOW_TOAST:
992 case DEBUG_TOGGLE_TOUCH_PAD: 590 case DEBUG_TOGGLE_TOUCH_PAD:
993 case DEBUG_TOGGLE_TOUCH_SCREEN: 591 case DEBUG_TOGGLE_TOUCH_SCREEN:
994 case DEBUG_TOGGLE_TOUCH_VIEW: 592 case DEBUG_TOGGLE_TOUCH_VIEW:
995 case DEBUG_TOGGLE_UNIFIED_DESKTOP: 593 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
996 return debug::DebugAcceleratorsEnabled(); 594 return debug::DebugAcceleratorsEnabled();
997 case DISABLE_CAPS_LOCK: 595 case DISABLE_CAPS_LOCK:
998 return CanHandleDisableCapsLock(previous_accelerator); 596 return CanHandleDisableCapsLock(previous_accelerator);
999 case LOCK_SCREEN: 597 case LOCK_SCREEN:
1000 return CanHandleLock(); 598 return CanHandleLock();
1001 case SWITCH_TO_PREVIOUS_USER: 599 case SWITCH_TO_PREVIOUS_USER:
1002 case SWITCH_TO_NEXT_USER: 600 case SWITCH_TO_NEXT_USER:
1003 return CanHandleCycleUser(); 601 return CanHandleCycleUser();
1004 case TOGGLE_CAPS_LOCK: 602 case TOGGLE_CAPS_LOCK:
1005 return CanHandleToggleCapsLock(accelerator, previous_accelerator); 603 return CanHandleToggleCapsLock(accelerator, previous_accelerator);
1006 case TOUCH_HUD_CLEAR:
1007 case TOUCH_HUD_MODE_CHANGE:
1008 return CanHandleTouchHud();
1009 case SWAP_PRIMARY_DISPLAY:
1010 return display::Screen::GetScreen()->GetNumDisplays() > 1;
1011 #endif 604 #endif
1012 case CYCLE_BACKWARD_MRU: 605 case CYCLE_BACKWARD_MRU:
1013 case CYCLE_FORWARD_MRU: 606 case CYCLE_FORWARD_MRU:
1014 case EXIT: 607 case EXIT:
1015 case FOCUS_NEXT_PANE: 608 case FOCUS_NEXT_PANE:
1016 case FOCUS_PREVIOUS_PANE: 609 case FOCUS_PREVIOUS_PANE:
1017 case FOCUS_SHELF:
1018 case LAUNCH_APP_0:
1019 case LAUNCH_APP_1:
1020 case LAUNCH_APP_2:
1021 case LAUNCH_APP_3:
1022 case LAUNCH_APP_4:
1023 case LAUNCH_APP_5:
1024 case LAUNCH_APP_6:
1025 case LAUNCH_APP_7:
1026 case LAUNCH_LAST_APP:
1027 case MEDIA_NEXT_TRACK: 610 case MEDIA_NEXT_TRACK:
1028 case MEDIA_PLAY_PAUSE: 611 case MEDIA_PLAY_PAUSE:
1029 case MEDIA_PREV_TRACK: 612 case MEDIA_PREV_TRACK:
1030 case NEW_TAB:
1031 case NEW_WINDOW:
1032 case OPEN_FEEDBACK_PAGE:
1033 case PRINT_UI_HIERARCHIES: 613 case PRINT_UI_HIERARCHIES:
1034 case RESTORE_TAB:
1035 case ROTATE_SCREEN:
1036 case ROTATE_WINDOW:
1037 case SHOW_KEYBOARD_OVERLAY:
1038 case SHOW_SYSTEM_TRAY_BUBBLE:
1039 case SHOW_TASK_MANAGER:
1040 case TAKE_WINDOW_SCREENSHOT:
1041 case TAKE_PARTIAL_SCREENSHOT:
1042 case TAKE_SCREENSHOT:
1043 case TOGGLE_FULLSCREEN: 614 case TOGGLE_FULLSCREEN:
1044 case TOGGLE_MAXIMIZED: 615 case TOGGLE_MAXIMIZED:
1045 case TOGGLE_OVERVIEW: 616 case TOGGLE_OVERVIEW:
1046 case WINDOW_MINIMIZE: 617 case WINDOW_MINIMIZE:
1047 #if defined(OS_CHROMEOS) 618 #if defined(OS_CHROMEOS)
1048 case BRIGHTNESS_DOWN: 619 case BRIGHTNESS_DOWN:
1049 case BRIGHTNESS_UP: 620 case BRIGHTNESS_UP:
1050 case DISABLE_GPU_WATCHDOG:
1051 case KEYBOARD_BRIGHTNESS_DOWN: 621 case KEYBOARD_BRIGHTNESS_DOWN:
1052 case KEYBOARD_BRIGHTNESS_UP: 622 case KEYBOARD_BRIGHTNESS_UP:
1053 case LOCK_PRESSED:
1054 case LOCK_RELEASED:
1055 case OPEN_CROSH:
1056 case OPEN_FILE_MANAGER:
1057 case OPEN_GET_HELP:
1058 case POWER_PRESSED:
1059 case POWER_RELEASED:
1060 case SUSPEND: 623 case SUSPEND:
1061 case TOGGLE_MIRROR_MODE:
1062 case TOGGLE_SPOKEN_FEEDBACK: 624 case TOGGLE_SPOKEN_FEEDBACK:
1063 case TOGGLE_WIFI: 625 case TOGGLE_WIFI:
1064 case TOUCH_HUD_PROJECTION_TOGGLE:
1065 case VOLUME_DOWN: 626 case VOLUME_DOWN:
1066 case VOLUME_MUTE: 627 case VOLUME_MUTE:
1067 case VOLUME_UP: 628 case VOLUME_UP:
1068 #else 629 #else
1069 case DUMMY_FOR_RESERVED: 630 case DUMMY_FOR_RESERVED:
1070 #endif 631 #endif
1071 return true; 632 return true;
633
634 default:
635 // Default switch is temporary until mash transition complete. Needed as
636 // some actions don't yet work with mash.
637 break;
1072 } 638 }
1073 return false; 639 DCHECK(delegate_ && delegate_->HandlesAction(action));
640 return delegate_->CanPerformAction(action, accelerator, previous_accelerator);
1074 } 641 }
1075 642
1076 void AcceleratorController::PerformAction(AcceleratorAction action, 643 void AcceleratorController::PerformAction(AcceleratorAction action,
1077 const ui::Accelerator& accelerator) { 644 const ui::Accelerator& accelerator) {
1078 AcceleratorProcessingRestriction restriction = 645 AcceleratorProcessingRestriction restriction =
1079 GetAcceleratorProcessingRestriction(action); 646 GetAcceleratorProcessingRestriction(action);
1080 if (restriction != RESTRICTION_NONE) 647 if (restriction != RESTRICTION_NONE)
1081 return; 648 return;
1082 649
1083 // If your accelerator invokes more than one line of code, please either 650 // If your accelerator invokes more than one line of code, please either
1084 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE 651 // implement it in your module's controller code or pull it into a HandleFoo()
1085 // below) or pull it into a HandleFoo() function above. 652 // function above.
1086 switch (action) { 653 switch (action) {
1087 case CYCLE_BACKWARD_MRU: 654 case CYCLE_BACKWARD_MRU:
1088 HandleCycleBackwardMRU(accelerator); 655 HandleCycleBackwardMRU(accelerator);
1089 break; 656 break;
1090 case CYCLE_FORWARD_MRU: 657 case CYCLE_FORWARD_MRU:
1091 HandleCycleForwardMRU(accelerator); 658 HandleCycleForwardMRU(accelerator);
1092 break; 659 break;
1093 case DEBUG_PRINT_LAYER_HIERARCHY: 660 case DEBUG_PRINT_LAYER_HIERARCHY:
1094 case DEBUG_PRINT_VIEW_HIERARCHY: 661 case DEBUG_PRINT_VIEW_HIERARCHY:
1095 case DEBUG_PRINT_WINDOW_HIERARCHY: 662 case DEBUG_PRINT_WINDOW_HIERARCHY:
1096 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: 663 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
1097 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: 664 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
1098 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: 665 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
1099 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: 666 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
1100 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: 667 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
1101 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: 668 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
1102 debug::PerformDebugActionIfEnabled(action); 669 debug::PerformDebugActionIfEnabled(action);
1103 break; 670 break;
1104 case EXIT: 671 case EXIT:
1105 // UMA metrics are recorded in the handler. 672 // UMA metrics are recorded in the handler.
1106 exit_warning_handler_.HandleAccelerator(); 673 exit_warning_handler_.HandleAccelerator();
1107 break; 674 break;
1108 case FOCUS_NEXT_PANE: 675 case FOCUS_NEXT_PANE:
1109 HandleRotatePaneFocus(FocusCycler::FORWARD); 676 HandleRotatePaneFocus(FocusCycler::FORWARD);
1110 break; 677 break;
1111 case FOCUS_PREVIOUS_PANE: 678 case FOCUS_PREVIOUS_PANE:
1112 HandleRotatePaneFocus(FocusCycler::BACKWARD); 679 HandleRotatePaneFocus(FocusCycler::BACKWARD);
1113 break; 680 break;
1114 case FOCUS_SHELF:
1115 HandleFocusShelf();
1116 break;
1117 case LAUNCH_APP_0:
1118 HandleLaunchAppN(0);
1119 break;
1120 case LAUNCH_APP_1:
1121 HandleLaunchAppN(1);
1122 break;
1123 case LAUNCH_APP_2:
1124 HandleLaunchAppN(2);
1125 break;
1126 case LAUNCH_APP_3:
1127 HandleLaunchAppN(3);
1128 break;
1129 case LAUNCH_APP_4:
1130 HandleLaunchAppN(4);
1131 break;
1132 case LAUNCH_APP_5:
1133 HandleLaunchAppN(5);
1134 break;
1135 case LAUNCH_APP_6:
1136 HandleLaunchAppN(6);
1137 break;
1138 case LAUNCH_APP_7:
1139 HandleLaunchAppN(7);
1140 break;
1141 case LAUNCH_LAST_APP:
1142 HandleLaunchLastApp();
1143 break;
1144 case MAGNIFY_SCREEN_ZOOM_IN:
1145 HandleMagnifyScreen(1);
1146 break;
1147 case MAGNIFY_SCREEN_ZOOM_OUT:
1148 HandleMagnifyScreen(-1);
1149 break;
1150 case MEDIA_NEXT_TRACK: 681 case MEDIA_NEXT_TRACK:
1151 HandleMediaNextTrack(); 682 HandleMediaNextTrack();
1152 break; 683 break;
1153 case MEDIA_PLAY_PAUSE: 684 case MEDIA_PLAY_PAUSE:
1154 HandleMediaPlayPause(); 685 HandleMediaPlayPause();
1155 break; 686 break;
1156 case MEDIA_PREV_TRACK: 687 case MEDIA_PREV_TRACK:
1157 HandleMediaPrevTrack(); 688 HandleMediaPrevTrack();
1158 break; 689 break;
1159 case NEW_INCOGNITO_WINDOW:
1160 HandleNewIncognitoWindow();
1161 break;
1162 case NEW_TAB:
1163 HandleNewTab(accelerator);
1164 break;
1165 case NEW_WINDOW:
1166 HandleNewWindow();
1167 break;
1168 case NEXT_IME: 690 case NEXT_IME:
1169 HandleNextIme(ime_control_delegate_.get()); 691 HandleNextIme(ime_control_delegate_.get());
1170 break; 692 break;
1171 case OPEN_FEEDBACK_PAGE:
1172 HandleOpenFeedbackPage();
1173 break;
1174 case PREVIOUS_IME: 693 case PREVIOUS_IME:
1175 HandlePreviousIme(ime_control_delegate_.get(), accelerator); 694 HandlePreviousIme(ime_control_delegate_.get(), accelerator);
1176 break; 695 break;
1177 case PRINT_UI_HIERARCHIES: 696 case PRINT_UI_HIERARCHIES:
1178 debug::PrintUIHierarchies(); 697 debug::PrintUIHierarchies();
1179 break; 698 break;
1180 case RESTORE_TAB:
1181 HandleRestoreTab();
1182 break;
1183 case ROTATE_SCREEN:
1184 HandleRotateScreen();
1185 break;
1186 case ROTATE_WINDOW:
1187 HandleRotateActiveWindow();
1188 break;
1189 case SCALE_UI_DOWN:
1190 accelerators::ZoomInternalDisplay(false /* down */);
1191 break;
1192 case SCALE_UI_RESET:
1193 accelerators::ResetInternalDisplayZoom();
1194 break;
1195 case SCALE_UI_UP:
1196 accelerators::ZoomInternalDisplay(true /* up */);
1197 break;
1198 case SHOW_KEYBOARD_OVERLAY:
1199 HandleShowKeyboardOverlay();
1200 break;
1201 case SHOW_MESSAGE_CENTER_BUBBLE:
1202 HandleShowMessageCenterBubble();
1203 break;
1204 case SHOW_SYSTEM_TRAY_BUBBLE:
1205 HandleShowSystemTrayBubble();
1206 break;
1207 case SHOW_TASK_MANAGER:
1208 HandleShowTaskManager();
1209 break;
1210 case SWITCH_IME: 699 case SWITCH_IME:
1211 HandleSwitchIme(ime_control_delegate_.get(), accelerator); 700 HandleSwitchIme(ime_control_delegate_.get(), accelerator);
1212 break; 701 break;
1213 case TAKE_WINDOW_SCREENSHOT:
1214 HandleTakeWindowScreenshot(screenshot_delegate_.get());
1215 break;
1216 case TAKE_PARTIAL_SCREENSHOT:
1217 HandleTakePartialScreenshot(screenshot_delegate_.get());
1218 break;
1219 case TAKE_SCREENSHOT:
1220 HandleTakeScreenshot(screenshot_delegate_.get());
1221 break;
1222 case TOGGLE_APP_LIST:
1223 HandleToggleAppList(accelerator);
1224 break;
1225 case TOGGLE_FULLSCREEN: 702 case TOGGLE_FULLSCREEN:
1226 HandleToggleFullscreen(accelerator); 703 HandleToggleFullscreen(accelerator);
1227 break; 704 break;
1228 case TOGGLE_MAXIMIZED: 705 case TOGGLE_MAXIMIZED:
1229 accelerators::ToggleMaximized(); 706 accelerators::ToggleMaximized();
1230 break; 707 break;
1231 case TOGGLE_OVERVIEW: 708 case TOGGLE_OVERVIEW:
1232 HandleToggleOverview(); 709 HandleToggleOverview();
1233 break; 710 break;
1234 case WINDOW_CYCLE_SNAP_DOCK_LEFT: 711 case WINDOW_CYCLE_SNAP_DOCK_LEFT:
1235 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: 712 case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
1236 HandleWindowSnapOrDock(action); 713 HandleWindowSnapOrDock(action);
1237 break; 714 break;
1238 case WINDOW_MINIMIZE: 715 case WINDOW_MINIMIZE:
1239 HandleWindowMinimize(); 716 HandleWindowMinimize();
1240 break; 717 break;
1241 case WINDOW_POSITION_CENTER: 718 case WINDOW_POSITION_CENTER:
1242 HandlePositionCenter(); 719 HandlePositionCenter();
1243 break; 720 break;
1244 case UNPIN:
1245 HandleUnpin();
1246 break;
1247 #if defined(OS_CHROMEOS) 721 #if defined(OS_CHROMEOS)
1248 case BRIGHTNESS_DOWN: { 722 case BRIGHTNESS_DOWN: {
1249 BrightnessControlDelegate* delegate = 723 BrightnessControlDelegate* delegate =
1250 WmShell::Get()->brightness_control_delegate(); 724 WmShell::Get()->brightness_control_delegate();
1251 if (delegate) 725 if (delegate)
1252 delegate->HandleBrightnessDown(accelerator); 726 delegate->HandleBrightnessDown(accelerator);
1253 break; 727 break;
1254 } 728 }
1255 case BRIGHTNESS_UP: { 729 case BRIGHTNESS_UP: {
1256 BrightnessControlDelegate* delegate = 730 BrightnessControlDelegate* delegate =
1257 WmShell::Get()->brightness_control_delegate(); 731 WmShell::Get()->brightness_control_delegate();
1258 if (delegate) 732 if (delegate)
1259 delegate->HandleBrightnessUp(accelerator); 733 delegate->HandleBrightnessUp(accelerator);
1260 break; 734 break;
1261 } 735 }
1262 case DEBUG_ADD_REMOVE_DISPLAY: 736 case DEBUG_ADD_REMOVE_DISPLAY:
1263 case DEBUG_SHOW_TOAST: 737 case DEBUG_SHOW_TOAST:
1264 case DEBUG_TOGGLE_TOUCH_PAD: 738 case DEBUG_TOGGLE_TOUCH_PAD:
1265 case DEBUG_TOGGLE_TOUCH_SCREEN: 739 case DEBUG_TOGGLE_TOUCH_SCREEN:
1266 case DEBUG_TOGGLE_TOUCH_VIEW: 740 case DEBUG_TOGGLE_TOUCH_VIEW:
1267 case DEBUG_TOGGLE_UNIFIED_DESKTOP: 741 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
1268 debug::PerformDebugActionIfEnabled(action); 742 debug::PerformDebugActionIfEnabled(action);
1269 break; 743 break;
1270 case DISABLE_CAPS_LOCK: 744 case DISABLE_CAPS_LOCK:
1271 HandleDisableCapsLock(); 745 HandleDisableCapsLock();
1272 break; 746 break;
1273 case DISABLE_GPU_WATCHDOG:
1274 Shell::GetInstance()->gpu_support()->DisableGpuWatchdog();
1275 break;
1276 case KEYBOARD_BRIGHTNESS_DOWN: { 747 case KEYBOARD_BRIGHTNESS_DOWN: {
1277 KeyboardBrightnessControlDelegate* delegate = 748 KeyboardBrightnessControlDelegate* delegate =
1278 WmShell::Get()->keyboard_brightness_control_delegate(); 749 WmShell::Get()->keyboard_brightness_control_delegate();
1279 if (delegate) 750 if (delegate)
1280 delegate->HandleKeyboardBrightnessDown(accelerator); 751 delegate->HandleKeyboardBrightnessDown(accelerator);
1281 break; 752 break;
1282 } 753 }
1283 case KEYBOARD_BRIGHTNESS_UP: { 754 case KEYBOARD_BRIGHTNESS_UP: {
1284 KeyboardBrightnessControlDelegate* delegate = 755 KeyboardBrightnessControlDelegate* delegate =
1285 WmShell::Get()->keyboard_brightness_control_delegate(); 756 WmShell::Get()->keyboard_brightness_control_delegate();
1286 if (delegate) 757 if (delegate)
1287 delegate->HandleKeyboardBrightnessUp(accelerator); 758 delegate->HandleKeyboardBrightnessUp(accelerator);
1288 break; 759 break;
1289 } 760 }
1290 case LOCK_PRESSED:
1291 case LOCK_RELEASED:
1292 Shell::GetInstance()->power_button_controller()->OnLockButtonEvent(
1293 action == LOCK_PRESSED, base::TimeTicks());
1294 break;
1295 case LOCK_SCREEN: 761 case LOCK_SCREEN:
1296 HandleLock(); 762 HandleLock();
1297 break; 763 break;
1298 case OPEN_CROSH:
1299 HandleCrosh();
1300 break;
1301 case OPEN_FILE_MANAGER:
1302 HandleFileManager();
1303 break;
1304 case OPEN_GET_HELP:
1305 HandleGetHelp();
1306 break;
1307 case POWER_PRESSED: // fallthrough
1308 case POWER_RELEASED:
1309 if (!base::SysInfo::IsRunningOnChromeOS()) {
1310 // There is no powerd, the Chrome OS power manager, in linux desktop,
1311 // so call the PowerButtonController here.
1312 Shell::GetInstance()->power_button_controller()->OnPowerButtonEvent(
1313 action == POWER_PRESSED, base::TimeTicks());
1314 }
1315 // We don't do anything with these at present on the device,
1316 // (power button events are reported to us from powerm via
1317 // D-BUS), but we consume them to prevent them from getting
1318 // passed to apps -- see http://crbug.com/146609.
1319 break;
1320 case SUSPEND: 764 case SUSPEND:
1321 HandleSuspend(); 765 HandleSuspend();
1322 break; 766 break;
1323 case SWAP_PRIMARY_DISPLAY:
1324 HandleSwapPrimaryDisplay();
1325 break;
1326 case SWITCH_TO_NEXT_USER: 767 case SWITCH_TO_NEXT_USER:
1327 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); 768 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER);
1328 break; 769 break;
1329 case SWITCH_TO_PREVIOUS_USER: 770 case SWITCH_TO_PREVIOUS_USER:
1330 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); 771 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER);
1331 break; 772 break;
1332 case TOGGLE_CAPS_LOCK: 773 case TOGGLE_CAPS_LOCK:
1333 HandleToggleCapsLock(); 774 HandleToggleCapsLock();
1334 break; 775 break;
1335 case TOGGLE_MIRROR_MODE:
1336 HandleToggleMirrorMode();
1337 break;
1338 case TOGGLE_SPOKEN_FEEDBACK: 776 case TOGGLE_SPOKEN_FEEDBACK:
1339 HandleToggleSpokenFeedback(); 777 HandleToggleSpokenFeedback();
1340 break; 778 break;
1341 case TOGGLE_WIFI: 779 case TOGGLE_WIFI:
1342 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); 780 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi();
1343 break; 781 break;
1344 case TOUCH_HUD_CLEAR:
1345 HandleTouchHudClear();
1346 break;
1347 case TOUCH_HUD_MODE_CHANGE:
1348 HandleTouchHudModeChange();
1349 break;
1350 case TOUCH_HUD_PROJECTION_TOGGLE:
1351 accelerators::ToggleTouchHudProjection();
1352 break;
1353 case VOLUME_DOWN: 782 case VOLUME_DOWN:
1354 HandleVolumeDown(accelerator); 783 HandleVolumeDown(accelerator);
1355 break; 784 break;
1356 case VOLUME_MUTE: 785 case VOLUME_MUTE:
1357 HandleVolumeMute(accelerator); 786 HandleVolumeMute(accelerator);
1358 break; 787 break;
1359 case VOLUME_UP: 788 case VOLUME_UP:
1360 HandleVolumeUp(accelerator); 789 HandleVolumeUp(accelerator);
1361 break; 790 break;
1362 #else 791 #else
1363 case DUMMY_FOR_RESERVED: 792 case DUMMY_FOR_RESERVED:
1364 NOTREACHED(); 793 NOTREACHED();
1365 break; 794 break;
1366 #endif 795 #endif
796 default:
797 // Temporary until mash transition complete. Needed as some actions
798 // don't yet work with mash.
799 DCHECK(delegate_ && delegate_->HandlesAction(action));
800 delegate_->PerformAction(action, accelerator);
801 break;
1367 } 802 }
1368 } 803 }
1369 804
1370 bool AcceleratorController::ShouldActionConsumeKeyEvent( 805 bool AcceleratorController::ShouldActionConsumeKeyEvent(
1371 AcceleratorAction action) { 806 AcceleratorAction action) {
1372 // Adding new exceptions is *STRONGLY* discouraged. 807 // Adding new exceptions is *STRONGLY* discouraged.
1373 return true; 808 return true;
1374 } 809 }
1375 810
1376 AcceleratorController::AcceleratorProcessingRestriction 811 AcceleratorController::AcceleratorProcessingRestriction
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && 843 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() &&
1409 actions_needing_window_.find(action) != actions_needing_window_.end()) { 844 actions_needing_window_.find(action) != actions_needing_window_.end()) {
1410 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( 845 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert(
1411 A11Y_ALERT_WINDOW_NEEDED); 846 A11Y_ALERT_WINDOW_NEEDED);
1412 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 847 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1413 } 848 }
1414 return RESTRICTION_NONE; 849 return RESTRICTION_NONE;
1415 } 850 }
1416 851
1417 } // namespace ash 852 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698