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

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

Issue 2162193003: Separates out accelerators using non-common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accelerators
Patch Set: fix compile issues 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
6
7 #include <algorithm>
8 #include <cmath>
9 #include <string>
10 #include <utility>
11
12 #include "ash/accelerators/accelerator_commands_aura.h"
13 #include "ash/common/accessibility_delegate.h"
14 #include "ash/common/accessibility_types.h"
15 #include "ash/common/ash_switches.h"
16 #include "ash/common/focus_cycler.h"
17 #include "ash/common/gpu_support.h"
18 #include "ash/common/session/session_state_delegate.h"
19 #include "ash/common/shell_delegate.h"
20 #include "ash/common/shell_window_ids.h"
21 #include "ash/common/system/status_area_widget.h"
22 #include "ash/common/system/system_notifier.h"
23 #include "ash/common/system/tray/system_tray.h"
24 #include "ash/common/system/web_notification/web_notification_tray.h"
25 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
26 #include "ash/common/wm/window_state.h"
27 #include "ash/common/wm/wm_event.h"
28 #include "ash/common/wm_shell.h"
29 #include "ash/debug.h"
30 #include "ash/display/window_tree_host_manager.h"
31 #include "ash/magnifier/magnification_controller.h"
32 #include "ash/magnifier/partial_magnification_controller.h"
33 #include "ash/new_window_delegate.h"
34 #include "ash/root_window_controller.h"
35 #include "ash/rotator/screen_rotation_animator.h"
36 #include "ash/rotator/window_rotation.h"
37 #include "ash/screen_util.h"
38 #include "ash/screenshot_delegate.h"
39 #include "ash/shelf/shelf.h"
40 #include "ash/shelf/shelf_widget.h"
41 #include "ash/shell.h"
42 #include "ash/touch/touch_hud_debug.h"
43 #include "ash/utility/screenshot_controller.h"
44 #include "ash/wm/power_button_controller.h"
45 #include "ash/wm/window_state_aura.h"
46 #include "ash/wm/window_util.h"
47 #include "base/metrics/histogram_macros.h"
48 #include "base/metrics/user_metrics.h"
49 #include "base/strings/string_split.h"
50 #include "base/strings/utf_string_conversions.h"
51 #include "ui/base/accelerators/accelerator.h"
52 #include "ui/base/l10n/l10n_util.h"
53 #include "ui/compositor/layer.h"
54 #include "ui/compositor/layer_animation_sequence.h"
55 #include "ui/compositor/layer_animator.h"
56 #include "ui/display/screen.h"
57 #include "ui/events/event.h"
58 #include "ui/events/keycodes/keyboard_codes.h"
59 #include "ui/message_center/message_center.h"
60 #include "ui/message_center/notification.h"
61 #include "ui/message_center/notifier_settings.h"
62
63 #if defined(OS_CHROMEOS)
64 #include "ash/display/display_configuration_controller.h"
65 #include "base/sys_info.h"
66 #endif // defined(OS_CHROMEOS)
67
68 namespace ash {
69 namespace {
70
71 using base::UserMetricsAction;
72
73 // The notification delegate that will be used to open the keyboard shortcut
74 // help page when the notification is clicked.
75 class DeprecatedAcceleratorNotificationDelegate
76 : public message_center::NotificationDelegate {
77 public:
78 DeprecatedAcceleratorNotificationDelegate() {}
79
80 // message_center::NotificationDelegate:
81 bool HasClickedListener() override { return true; }
82
83 void Click() override {
84 if (!WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked())
85 WmShell::Get()->delegate()->OpenKeyboardShortcutHelpPage();
86 }
87
88 private:
89 // Private destructor since NotificationDelegate is ref-counted.
90 ~DeprecatedAcceleratorNotificationDelegate() override {}
91
92 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate);
93 };
94
95 // Ensures that there are no word breaks at the "+"s in the shortcut texts such
96 // as "Ctrl+Shift+Space".
97 void EnsureNoWordBreaks(base::string16* shortcut_text) {
98 std::vector<base::string16> keys =
99 base::SplitString(*shortcut_text, base::ASCIIToUTF16("+"),
100 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
101
102 if (keys.size() < 2U)
103 return;
104
105 // The plus sign surrounded by the word joiner to guarantee an non-breaking
106 // shortcut.
107 const base::string16 non_breaking_plus =
108 base::UTF8ToUTF16("\xe2\x81\xa0+\xe2\x81\xa0");
109 shortcut_text->clear();
110 for (size_t i = 0; i < keys.size() - 1; ++i) {
111 *shortcut_text += keys[i];
112 *shortcut_text += non_breaking_plus;
113 }
114
115 *shortcut_text += keys.back();
116 }
117
118 // Gets the notification message after it formats it in such a way that there
119 // are no line breaks in the middle of the shortcut texts.
120 base::string16 GetNotificationText(int message_id,
121 int old_shortcut_id,
122 int new_shortcut_id) {
123 base::string16 old_shortcut = l10n_util::GetStringUTF16(old_shortcut_id);
124 base::string16 new_shortcut = l10n_util::GetStringUTF16(new_shortcut_id);
125 EnsureNoWordBreaks(&old_shortcut);
126 EnsureNoWordBreaks(&new_shortcut);
127
128 return l10n_util::GetStringFUTF16(message_id, new_shortcut, old_shortcut);
129 }
130
131 void HandleFocusShelf() {
132 base::RecordAction(base::UserMetricsAction("Accel_Focus_Shelf"));
James Cook 2016/07/20 16:08:04 nit: base:: not needed, here and below
sky 2016/07/20 16:42:50 Done.
133 WmShell::Get()->focus_cycler()->FocusWidget(
134 Shelf::ForPrimaryDisplay()->shelf_widget());
135 }
136
137 void HandleLaunchAppN(int n) {
138 base::RecordAction(UserMetricsAction("Accel_Launch_App"));
139 Shelf::ForPrimaryDisplay()->LaunchAppIndexAt(n);
140 }
141
142 void HandleLaunchLastApp() {
143 base::RecordAction(UserMetricsAction("Accel_Launch_Last_App"));
144 Shelf::ForPrimaryDisplay()->LaunchAppIndexAt(-1);
145 }
146
147 bool CanHandleMagnifyScreen() {
148 Shell* shell = Shell::GetInstance();
149 return shell->magnification_controller()->IsEnabled() ||
150 shell->partial_magnification_controller()->is_enabled();
151 }
152
153 // Magnify the screen
154 void HandleMagnifyScreen(int delta_index) {
155 if (Shell::GetInstance()->magnification_controller()->IsEnabled()) {
156 // TODO(yoshiki): Move the following logic to MagnificationController.
157 float scale = Shell::GetInstance()->magnification_controller()->GetScale();
158 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale.
159 int scale_index =
160 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5);
161
162 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index));
163
164 Shell::GetInstance()->magnification_controller()->SetScale(
165 std::pow(kMagnificationScaleFactor, new_scale_index), true);
166 } else if (Shell::GetInstance()
167 ->partial_magnification_controller()
168 ->is_enabled()) {
169 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1;
170 Shell::GetInstance()->partial_magnification_controller()->SetScale(scale);
171 }
172 }
173
174 bool CanHandleNewIncognitoWindow() {
175 return WmShell::Get()->delegate()->IsIncognitoAllowed();
176 }
177
178 void HandleNewIncognitoWindow() {
179 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window"));
180 Shell::GetInstance()->new_window_delegate()->NewWindow(
James Cook 2016/07/20 16:08:04 NewWindowDelegate has no aura dependencies. What d
sky 2016/07/20 16:42:50 I did see that NewWindowDelegate has no aura depen
James Cook 2016/07/20 17:11:56 This is OK for now, but having AppDriver know the
181 true /* is_incognito */);
182 }
183
184 void HandleNewTab(const ui::Accelerator& accelerator) {
185 if (accelerator.key_code() == ui::VKEY_T)
186 base::RecordAction(base::UserMetricsAction("Accel_NewTab_T"));
187 Shell::GetInstance()->new_window_delegate()->NewTab();
188 }
189
190 void HandleNewWindow() {
191 base::RecordAction(base::UserMetricsAction("Accel_New_Window"));
192 Shell::GetInstance()->new_window_delegate()->NewWindow(
193 false /* is_incognito */);
194 }
195
196 void HandleOpenFeedbackPage() {
197 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page"));
198 Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
199 }
200
201 void HandleRestoreTab() {
202 base::RecordAction(base::UserMetricsAction("Accel_Restore_Tab"));
203 Shell::GetInstance()->new_window_delegate()->RestoreTab();
204 }
205
206 display::Display::Rotation GetNextRotation(display::Display::Rotation current) {
207 switch (current) {
208 case display::Display::ROTATE_0:
209 return display::Display::ROTATE_90;
210 case display::Display::ROTATE_90:
211 return display::Display::ROTATE_180;
212 case display::Display::ROTATE_180:
213 return display::Display::ROTATE_270;
214 case display::Display::ROTATE_270:
215 return display::Display::ROTATE_0;
216 }
217 NOTREACHED() << "Unknown rotation:" << current;
218 return display::Display::ROTATE_0;
219 }
220
221 // Rotates the screen.
222 void HandleRotateScreen() {
223 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode())
224 return;
225
226 base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
227 gfx::Point point = display::Screen::GetScreen()->GetCursorScreenPoint();
228 display::Display display =
229 display::Screen::GetScreen()->GetDisplayNearestPoint(point);
230 const DisplayInfo& display_info =
231 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
232 ScreenRotationAnimator(display.id())
233 .Rotate(GetNextRotation(display_info.GetActiveRotation()),
234 display::Display::ROTATION_SOURCE_USER);
235 }
236
237 // Rotate the active window.
238 void HandleRotateActiveWindow() {
239 base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
240 aura::Window* active_window = wm::GetActiveWindow();
241 if (active_window) {
242 // The rotation animation bases its target transform on the current
243 // rotation and position. Since there could be an animation in progress
244 // right now, queue this animation so when it starts it picks up a neutral
245 // rotation and position. Use replace so we only enqueue one at a time.
246 active_window->layer()->GetAnimator()->set_preemption_strategy(
247 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
248 active_window->layer()->GetAnimator()->StartAnimation(
249 new ui::LayerAnimationSequence(
250 new WindowRotation(360, active_window->layer())));
251 }
252 }
253
254 void HandleShowKeyboardOverlay() {
255 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay"));
256 Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
257 }
258
259 bool CanHandleShowMessageCenterBubble() {
260 RootWindowController* controller =
261 RootWindowController::ForTargetRootWindow();
262 StatusAreaWidget* status_area_widget =
263 controller->shelf_widget()->status_area_widget();
264 return status_area_widget &&
265 status_area_widget->web_notification_tray()->visible();
266 }
267
268 void HandleShowMessageCenterBubble() {
269 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble"));
270 RootWindowController* controller =
271 RootWindowController::ForTargetRootWindow();
272 StatusAreaWidget* status_area_widget =
273 controller->shelf_widget()->status_area_widget();
274 if (status_area_widget) {
275 WebNotificationTray* notification_tray =
276 status_area_widget->web_notification_tray();
277 if (notification_tray->visible())
278 notification_tray->ShowMessageCenterBubble();
279 }
280 }
281
282 void HandleShowSystemTrayBubble() {
James Cook 2016/07/20 16:08:04 How urgent is it to move all these status area / s
sky 2016/07/20 16:42:50 I would like to land this soon so I can complete t
James Cook 2016/07/20 17:11:56 OK. I'll CC you on the bugs for the applist and sy
283 base::RecordAction(UserMetricsAction("Accel_Show_System_Tray_Bubble"));
284 RootWindowController* controller =
285 RootWindowController::ForTargetRootWindow();
286 if (!controller->GetSystemTray()->HasSystemBubble())
287 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
288 }
289
290 void HandleShowTaskManager() {
291 base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager"));
292 Shell::GetInstance()->new_window_delegate()->ShowTaskManager();
293 }
294
295 void HandleTakeWindowScreenshot(ScreenshotDelegate* screenshot_delegate) {
296 base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot"));
297 DCHECK(screenshot_delegate);
298 Shell::GetInstance()->screenshot_controller()->StartWindowScreenshotSession(
299 screenshot_delegate);
300 }
301
302 void HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) {
303 base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot"));
304 DCHECK(screenshot_delegate);
305 Shell::GetInstance()->screenshot_controller()->StartPartialScreenshotSession(
306 screenshot_delegate);
307 }
308
309 void HandleTakeScreenshot(ScreenshotDelegate* screenshot_delegate) {
310 base::RecordAction(UserMetricsAction("Accel_Take_Screenshot"));
311 DCHECK(screenshot_delegate);
312 if (screenshot_delegate->CanTakeScreenshot())
313 screenshot_delegate->HandleTakeScreenshotForAllRootWindows();
314 }
315
316 bool CanHandleToggleAppList(const ui::Accelerator& accelerator,
317 const ui::Accelerator& previous_accelerator) {
318 if (accelerator.key_code() == ui::VKEY_LWIN) {
319 // If something else was pressed between the Search key (LWIN)
320 // being pressed and released, then ignore the release of the
321 // Search key.
322 if (previous_accelerator.type() != ui::ET_KEY_PRESSED ||
323 previous_accelerator.key_code() != ui::VKEY_LWIN) {
324 return false;
325 }
326
327 // When spoken feedback is enabled, we should neither toggle the list nor
328 // consume the key since Search+Shift is one of the shortcuts the a11y
329 // feature uses. crbug.com/132296
330 if (WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled())
331 return false;
332 }
333 return true;
334 }
335
336 void HandleToggleAppList(const ui::Accelerator& accelerator) {
337 if (accelerator.key_code() == ui::VKEY_LWIN)
338 base::RecordAction(base::UserMetricsAction("Accel_Search_LWin"));
339 Shell::GetInstance()->ToggleAppList(nullptr);
James Cook 2016/07/20 16:08:04 If it can wait, I have a CL that will go out for r
sky 2016/07/20 16:42:50 Similar comment to above.
340 }
341
342 bool CanHandleUnpin() {
343 wm::WindowState* window_state = wm::GetActiveWindowState();
344 return window_state && window_state->IsPinned();
345 }
346
347 #if defined(OS_CHROMEOS)
348 void HandleCrosh() {
349 base::RecordAction(UserMetricsAction("Accel_Open_Crosh"));
350
351 Shell::GetInstance()->new_window_delegate()->OpenCrosh();
352 }
353
354 void HandleFileManager() {
355 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager"));
356
357 Shell::GetInstance()->new_window_delegate()->OpenFileManager();
358 }
359
360 void HandleGetHelp() {
361 Shell::GetInstance()->new_window_delegate()->OpenGetHelp();
362 }
363
364 void HandleSwapPrimaryDisplay() {
365 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
366 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId(
367 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */);
368 }
369
370 void HandleToggleMirrorMode() {
371 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode"));
372 bool mirror = !Shell::GetInstance()->display_manager()->IsInMirrorMode();
373 Shell::GetInstance()->display_configuration_controller()->SetMirrorMode(
374 mirror, true /* user_action */);
375 }
376
377 bool CanHandleTouchHud() {
378 return RootWindowController::ForTargetRootWindow()->touch_hud_debug();
379 }
380
381 void HandleTouchHudClear() {
382 RootWindowController::ForTargetRootWindow()->touch_hud_debug()->Clear();
383 }
384
385 void HandleTouchHudModeChange() {
386 RootWindowController* controller =
387 RootWindowController::ForTargetRootWindow();
388 controller->touch_hud_debug()->ChangeToNextMode();
389 }
390
391 #endif // defined(OS_CHROMEOS)
392
393 } // namespace
394
395 AcceleratorControllerDelegateAura::AcceleratorControllerDelegateAura() {}
396
397 AcceleratorControllerDelegateAura::~AcceleratorControllerDelegateAura() {}
398
399 void AcceleratorControllerDelegateAura::SetScreenshotDelegate(
400 std::unique_ptr<ScreenshotDelegate> screenshot_delegate) {
401 screenshot_delegate_ = std::move(screenshot_delegate);
402 }
403
404 bool AcceleratorControllerDelegateAura::HandlesAction(
405 AcceleratorAction action) {
406 switch (action) {
407 case FOCUS_SHELF:
408 case LAUNCH_APP_0:
409 case LAUNCH_APP_1:
410 case LAUNCH_APP_2:
411 case LAUNCH_APP_3:
412 case LAUNCH_APP_4:
413 case LAUNCH_APP_5:
414 case LAUNCH_APP_6:
415 case LAUNCH_APP_7:
416 case LAUNCH_LAST_APP:
417 case MAGNIFY_SCREEN_ZOOM_IN:
418 case MAGNIFY_SCREEN_ZOOM_OUT:
419 case NEW_INCOGNITO_WINDOW:
420 case NEW_TAB:
421 case NEW_WINDOW:
422 case OPEN_FEEDBACK_PAGE:
423 case RESTORE_TAB:
424 case ROTATE_SCREEN:
425 case ROTATE_WINDOW:
426 case SCALE_UI_DOWN:
427 case SCALE_UI_RESET:
428 case SCALE_UI_UP:
429 case SHOW_KEYBOARD_OVERLAY:
430 case SHOW_MESSAGE_CENTER_BUBBLE:
431 case SHOW_SYSTEM_TRAY_BUBBLE:
432 case SHOW_TASK_MANAGER:
433 case TAKE_PARTIAL_SCREENSHOT:
434 case TAKE_SCREENSHOT:
435 case TAKE_WINDOW_SCREENSHOT:
436 case TOGGLE_APP_LIST:
437 case UNPIN:
438 return true;
439
440 #if defined(OS_CHROMEOS)
441 case DISABLE_GPU_WATCHDOG:
442 case LOCK_PRESSED:
443 case LOCK_RELEASED:
444 case OPEN_CROSH:
445 case OPEN_FILE_MANAGER:
446 case OPEN_GET_HELP:
447 case POWER_PRESSED:
448 case POWER_RELEASED:
449 case SWAP_PRIMARY_DISPLAY:
450 case TOGGLE_MIRROR_MODE:
451 case TOUCH_HUD_CLEAR:
452 case TOUCH_HUD_MODE_CHANGE:
453 case TOUCH_HUD_PROJECTION_TOGGLE:
454 return true;
455 #endif
456
457 default:
458 break;
459 }
460 return false;
461 }
462
463 bool AcceleratorControllerDelegateAura::CanPerformAction(
464 AcceleratorAction action,
465 const ui::Accelerator& accelerator,
466 const ui::Accelerator& previous_accelerator) {
467 switch (action) {
468 case MAGNIFY_SCREEN_ZOOM_IN:
469 case MAGNIFY_SCREEN_ZOOM_OUT:
470 return CanHandleMagnifyScreen();
471 case NEW_INCOGNITO_WINDOW:
472 return CanHandleNewIncognitoWindow();
473 case SCALE_UI_DOWN:
474 case SCALE_UI_RESET:
475 case SCALE_UI_UP:
476 return accelerators::IsInternalDisplayZoomEnabled();
477 case SHOW_MESSAGE_CENTER_BUBBLE:
478 return CanHandleShowMessageCenterBubble();
479 case TOGGLE_APP_LIST:
480 return CanHandleToggleAppList(accelerator, previous_accelerator);
481 case UNPIN:
482 return CanHandleUnpin();
483
484 // Following are always enabled:
485 case FOCUS_SHELF:
486 case LAUNCH_APP_0:
487 case LAUNCH_APP_1:
488 case LAUNCH_APP_2:
489 case LAUNCH_APP_3:
490 case LAUNCH_APP_4:
491 case LAUNCH_APP_5:
492 case LAUNCH_APP_6:
493 case LAUNCH_APP_7:
494 case LAUNCH_LAST_APP:
495 case NEW_TAB:
496 case NEW_WINDOW:
497 case OPEN_FEEDBACK_PAGE:
498 case RESTORE_TAB:
499 case ROTATE_SCREEN:
500 case ROTATE_WINDOW:
501 case SHOW_KEYBOARD_OVERLAY:
502 case SHOW_SYSTEM_TRAY_BUBBLE:
503 case SHOW_TASK_MANAGER:
504 case TAKE_PARTIAL_SCREENSHOT:
505 case TAKE_SCREENSHOT:
506 case TAKE_WINDOW_SCREENSHOT:
507 return true;
508
509 #if defined(OS_CHROMEOS)
510 case SWAP_PRIMARY_DISPLAY:
511 return display::Screen::GetScreen()->GetNumDisplays() > 1;
512 case TOUCH_HUD_CLEAR:
513 case TOUCH_HUD_MODE_CHANGE:
514 return CanHandleTouchHud();
515
516 // Following are always enabled.
517 case DISABLE_GPU_WATCHDOG:
518 case LOCK_PRESSED:
519 case LOCK_RELEASED:
520 case OPEN_CROSH:
521 case OPEN_FILE_MANAGER:
522 case OPEN_GET_HELP:
523 case POWER_PRESSED:
524 case POWER_RELEASED:
525 case TOGGLE_MIRROR_MODE:
526 case TOUCH_HUD_PROJECTION_TOGGLE:
527 return true;
528 #endif
529
530 default:
531 NOTREACHED();
532 break;
533 }
534 return false;
535 }
536
537 void AcceleratorControllerDelegateAura::PerformAction(
538 AcceleratorAction action,
539 const ui::Accelerator& accelerator) {
540 switch (action) {
541 case FOCUS_SHELF:
542 HandleFocusShelf();
543 break;
544 case LAUNCH_APP_0:
545 HandleLaunchAppN(0);
546 break;
547 case LAUNCH_APP_1:
548 HandleLaunchAppN(1);
549 break;
550 case LAUNCH_APP_2:
551 HandleLaunchAppN(2);
552 break;
553 case LAUNCH_APP_3:
554 HandleLaunchAppN(3);
555 break;
556 case LAUNCH_APP_4:
557 HandleLaunchAppN(4);
558 break;
559 case LAUNCH_APP_5:
560 HandleLaunchAppN(5);
561 break;
562 case LAUNCH_APP_6:
563 HandleLaunchAppN(6);
564 break;
565 case LAUNCH_APP_7:
566 HandleLaunchAppN(7);
567 break;
568 case LAUNCH_LAST_APP:
569 HandleLaunchLastApp();
570 break;
571 case MAGNIFY_SCREEN_ZOOM_IN:
572 HandleMagnifyScreen(1);
573 break;
574 case MAGNIFY_SCREEN_ZOOM_OUT:
575 HandleMagnifyScreen(-1);
576 break;
577 case NEW_INCOGNITO_WINDOW:
578 HandleNewIncognitoWindow();
579 break;
580 case NEW_TAB:
581 HandleNewTab(accelerator);
582 break;
583 case NEW_WINDOW:
584 HandleNewWindow();
585 break;
586 case OPEN_FEEDBACK_PAGE:
587 HandleOpenFeedbackPage();
588 break;
589 case RESTORE_TAB:
590 HandleRestoreTab();
591 break;
592 case ROTATE_SCREEN:
593 HandleRotateScreen();
594 break;
595 case ROTATE_WINDOW:
596 HandleRotateActiveWindow();
597 break;
598 case SCALE_UI_DOWN:
599 accelerators::ZoomInternalDisplay(false /* down */);
600 break;
601 case SCALE_UI_RESET:
602 accelerators::ResetInternalDisplayZoom();
603 break;
604 case SCALE_UI_UP:
605 accelerators::ZoomInternalDisplay(true /* up */);
606 break;
607 case SHOW_KEYBOARD_OVERLAY:
608 HandleShowKeyboardOverlay();
609 break;
610 case SHOW_MESSAGE_CENTER_BUBBLE:
611 HandleShowMessageCenterBubble();
612 break;
613 case SHOW_SYSTEM_TRAY_BUBBLE:
614 HandleShowSystemTrayBubble();
615 break;
616 case SHOW_TASK_MANAGER:
617 HandleShowTaskManager();
618 break;
619 case TAKE_PARTIAL_SCREENSHOT:
620 HandleTakePartialScreenshot(screenshot_delegate_.get());
621 break;
622 case TAKE_SCREENSHOT:
623 HandleTakeScreenshot(screenshot_delegate_.get());
624 break;
625 case TAKE_WINDOW_SCREENSHOT:
626 HandleTakeWindowScreenshot(screenshot_delegate_.get());
627 break;
628 case TOGGLE_APP_LIST:
629 HandleToggleAppList(accelerator);
630 break;
631 case UNPIN:
632 accelerators::Unpin();
633 break;
634 #if defined(OS_CHROMEOS)
635 case DISABLE_GPU_WATCHDOG:
636 Shell::GetInstance()->gpu_support()->DisableGpuWatchdog();
637 break;
638 case LOCK_PRESSED:
639 case LOCK_RELEASED:
640 Shell::GetInstance()->power_button_controller()->OnLockButtonEvent(
641 action == LOCK_PRESSED, base::TimeTicks());
642 break;
643 case OPEN_CROSH:
644 HandleCrosh();
645 break;
646 case OPEN_FILE_MANAGER:
647 HandleFileManager();
648 break;
649 case OPEN_GET_HELP:
650 HandleGetHelp();
651 break;
652 case POWER_PRESSED: // fallthrough
653 case POWER_RELEASED:
654 if (!base::SysInfo::IsRunningOnChromeOS()) {
655 // There is no powerd, the Chrome OS power manager, in linux desktop,
656 // so call the PowerButtonController here.
657 Shell::GetInstance()->power_button_controller()->OnPowerButtonEvent(
658 action == POWER_PRESSED, base::TimeTicks());
659 }
660 // We don't do anything with these at present on the device,
661 // (power button events are reported to us from powerm via
662 // D-BUS), but we consume them to prevent them from getting
663 // passed to apps -- see http://crbug.com/146609.
664 break;
665 case SWAP_PRIMARY_DISPLAY:
666 HandleSwapPrimaryDisplay();
667 break;
668 case TOGGLE_MIRROR_MODE:
669 HandleToggleMirrorMode();
670 break;
671 case TOUCH_HUD_CLEAR:
672 HandleTouchHudClear();
673 break;
674 case TOUCH_HUD_MODE_CHANGE:
675 HandleTouchHudModeChange();
676 break;
677 case TOUCH_HUD_PROJECTION_TOGGLE:
678 accelerators::ToggleTouchHudProjection();
679 break;
680 #endif
681 default:
682 break;
683 }
684 }
685
686 void AcceleratorControllerDelegateAura::ShowDeprecatedAcceleratorNotification(
687 const char* const notification_id,
688 int message_id,
689 int old_shortcut_id,
690 int new_shortcut_id) {
691 const base::string16 message =
692 GetNotificationText(message_id, old_shortcut_id, new_shortcut_id);
693 std::unique_ptr<message_center::Notification> notification(
694 new message_center::Notification(
695 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id,
696 base::string16(), message,
697 WmShell::Get()->delegate()->GetDeprecatedAcceleratorImage(),
698 base::string16(), GURL(),
699 message_center::NotifierId(
700 message_center::NotifierId::SYSTEM_COMPONENT,
701 system_notifier::kNotifierDeprecatedAccelerator),
702 message_center::RichNotificationData(),
703 new DeprecatedAcceleratorNotificationDelegate));
704 message_center::MessageCenter::Get()->AddNotification(
705 std::move(notification));
706 }
707
708 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698