OLD | NEW |
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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include "ash/common/accelerators/accelerator_commands.h" | 7 #include "ash/common/accelerators/accelerator_commands.h" |
8 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 8 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
9 #include "ash/common/accelerators/debug_commands.h" | 9 #include "ash/common/accelerators/debug_commands.h" |
10 #include "ash/common/accessibility_delegate.h" | 10 #include "ash/common/accessibility_delegate.h" |
11 #include "ash/common/accessibility_types.h" | 11 #include "ash/common/accessibility_types.h" |
12 #include "ash/common/focus_cycler.h" | 12 #include "ash/common/focus_cycler.h" |
13 #include "ash/common/ime_control_delegate.h" | 13 #include "ash/common/ime_control_delegate.h" |
14 #include "ash/common/media_delegate.h" | 14 #include "ash/common/media_delegate.h" |
15 #include "ash/common/multi_profile_uma.h" | 15 #include "ash/common/multi_profile_uma.h" |
16 #include "ash/common/new_window_delegate.h" | 16 #include "ash/common/new_window_delegate.h" |
17 #include "ash/common/session/session_state_delegate.h" | 17 #include "ash/common/session/session_state_delegate.h" |
18 #include "ash/common/shelf/shelf_widget.h" | 18 #include "ash/common/shelf/shelf_widget.h" |
19 #include "ash/common/shelf/wm_shelf.h" | 19 #include "ash/common/shelf/wm_shelf.h" |
20 #include "ash/common/shell_delegate.h" | 20 #include "ash/common/shell_delegate.h" |
21 #include "ash/common/system/brightness_control_delegate.h" | 21 #include "ash/common/system/brightness_control_delegate.h" |
22 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 22 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
23 #include "ash/common/system/status_area_widget.h" | 23 #include "ash/common/system/status_area_widget.h" |
24 #include "ash/common/system/tray/system_tray_delegate.h" | 24 #include "ash/common/system/tray/system_tray_delegate.h" |
25 #include "ash/common/system/tray/system_tray_notifier.h" | 25 #include "ash/common/system/tray/system_tray_notifier.h" |
26 #include "ash/common/system/volume_control_delegate.h" | 26 #include "ash/common/system/volume_control_delegate.h" |
27 #include "ash/common/system/web_notification/web_notification_tray.h" | 27 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 28 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
28 #include "ash/common/wm/mru_window_tracker.h" | 29 #include "ash/common/wm/mru_window_tracker.h" |
29 #include "ash/common/wm/overview/window_selector_controller.h" | 30 #include "ash/common/wm/overview/window_selector_controller.h" |
30 #include "ash/common/wm/window_cycle_controller.h" | 31 #include "ash/common/wm/window_cycle_controller.h" |
31 #include "ash/common/wm/window_positioning_utils.h" | 32 #include "ash/common/wm/window_positioning_utils.h" |
32 #include "ash/common/wm/window_state.h" | 33 #include "ash/common/wm/window_state.h" |
33 #include "ash/common/wm/wm_event.h" | 34 #include "ash/common/wm/wm_event.h" |
34 #include "ash/common/wm_root_window_controller.h" | 35 #include "ash/common/wm_root_window_controller.h" |
35 #include "ash/common/wm_shell.h" | 36 #include "ash/common/wm_shell.h" |
36 #include "ash/common/wm_window.h" | 37 #include "ash/common/wm_window.h" |
37 #include "base/metrics/histogram_macros.h" | 38 #include "base/metrics/histogram_macros.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 467 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
467 } | 468 } |
468 | 469 |
469 void HandleToggleSpokenFeedback() { | 470 void HandleToggleSpokenFeedback() { |
470 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); | 471 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); |
471 | 472 |
472 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 473 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
473 A11Y_NOTIFICATION_SHOW); | 474 A11Y_NOTIFICATION_SHOW); |
474 } | 475 } |
475 | 476 |
| 477 void HandleToggleTouchView() { |
| 478 MaximizeModeController* controller = |
| 479 WmShell::Get()->maximize_mode_controller(); |
| 480 controller->EnableMaximizeModeWindowManager( |
| 481 !controller->IsMaximizeModeWindowManagerEnabled()); |
| 482 } |
| 483 |
476 void HandleVolumeDown(const ui::Accelerator& accelerator) { | 484 void HandleVolumeDown(const ui::Accelerator& accelerator) { |
477 VolumeControlDelegate* volume_delegate = | 485 VolumeControlDelegate* volume_delegate = |
478 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); | 486 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); |
479 if (volume_delegate) | 487 if (volume_delegate) |
480 volume_delegate->HandleVolumeDown(accelerator); | 488 volume_delegate->HandleVolumeDown(accelerator); |
481 } | 489 } |
482 | 490 |
483 void HandleVolumeMute(const ui::Accelerator& accelerator) { | 491 void HandleVolumeMute(const ui::Accelerator& accelerator) { |
484 VolumeControlDelegate* volume_delegate = | 492 VolumeControlDelegate* volume_delegate = |
485 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); | 493 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); | 687 RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); |
680 | 688 |
681 RegisterDeprecatedAccelerators(); | 689 RegisterDeprecatedAccelerators(); |
682 | 690 |
683 if (debug::DebugAcceleratorsEnabled()) { | 691 if (debug::DebugAcceleratorsEnabled()) { |
684 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); | 692 RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength); |
685 // All debug accelerators are reserved. | 693 // All debug accelerators are reserved. |
686 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | 694 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
687 reserved_actions_.insert(kDebugAcceleratorData[i].action); | 695 reserved_actions_.insert(kDebugAcceleratorData[i].action); |
688 } | 696 } |
| 697 |
| 698 if (debug::DeveloperAcceleratorsEnabled()) { |
| 699 RegisterAccelerators(kDeveloperAcceleratorData, |
| 700 kDeveloperAcceleratorDataLength); |
| 701 // Developer accelerators are also reserved. |
| 702 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) |
| 703 reserved_actions_.insert(kDeveloperAcceleratorData[i].action); |
| 704 } |
689 } | 705 } |
690 | 706 |
691 void AcceleratorController::RegisterAccelerators( | 707 void AcceleratorController::RegisterAccelerators( |
692 const AcceleratorData accelerators[], | 708 const AcceleratorData accelerators[], |
693 size_t accelerators_length) { | 709 size_t accelerators_length) { |
694 for (size_t i = 0; i < accelerators_length; ++i) { | 710 for (size_t i = 0; i < accelerators_length; ++i) { |
695 ui::Accelerator accelerator = | 711 ui::Accelerator accelerator = |
696 CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, | 712 CreateAccelerator(accelerators[i].keycode, accelerators[i].modifiers, |
697 accelerators[i].trigger_on_press); | 713 accelerators[i].trigger_on_press); |
698 Register(accelerator, this); | 714 Register(accelerator, this); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 return CanHandleToggleAppList(accelerator, previous_accelerator); | 776 return CanHandleToggleAppList(accelerator, previous_accelerator); |
761 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 777 case WINDOW_CYCLE_SNAP_DOCK_LEFT: |
762 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 778 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: |
763 return CanHandleWindowSnapOrDock(); | 779 return CanHandleWindowSnapOrDock(); |
764 case WINDOW_POSITION_CENTER: | 780 case WINDOW_POSITION_CENTER: |
765 return CanHandlePositionCenter(); | 781 return CanHandlePositionCenter(); |
766 #if defined(OS_CHROMEOS) | 782 #if defined(OS_CHROMEOS) |
767 case DEBUG_SHOW_TOAST: | 783 case DEBUG_SHOW_TOAST: |
768 case DEBUG_TOGGLE_TOUCH_PAD: | 784 case DEBUG_TOGGLE_TOUCH_PAD: |
769 case DEBUG_TOGGLE_TOUCH_SCREEN: | 785 case DEBUG_TOGGLE_TOUCH_SCREEN: |
770 case DEBUG_TOGGLE_TOUCH_VIEW: | |
771 return debug::DebugAcceleratorsEnabled(); | 786 return debug::DebugAcceleratorsEnabled(); |
772 case DISABLE_CAPS_LOCK: | 787 case DISABLE_CAPS_LOCK: |
773 return CanHandleDisableCapsLock(previous_accelerator); | 788 return CanHandleDisableCapsLock(previous_accelerator); |
774 case LOCK_SCREEN: | 789 case LOCK_SCREEN: |
775 return CanHandleLock(); | 790 return CanHandleLock(); |
776 case SHOW_STYLUS_TOOLS: | 791 case SHOW_STYLUS_TOOLS: |
777 return CanHandleShowStylusTools(); | 792 return CanHandleShowStylusTools(); |
778 case SWITCH_TO_PREVIOUS_USER: | 793 case SWITCH_TO_PREVIOUS_USER: |
779 case SWITCH_TO_NEXT_USER: | 794 case SWITCH_TO_NEXT_USER: |
780 return CanHandleCycleUser(); | 795 return CanHandleCycleUser(); |
781 case TOGGLE_CAPS_LOCK: | 796 case TOGGLE_CAPS_LOCK: |
782 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 797 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
| 798 case DEV_TOGGLE_TOUCH_VIEW: |
| 799 return debug::DeveloperAcceleratorsEnabled(); |
783 #endif | 800 #endif |
784 case EXIT: | 801 case EXIT: |
785 case FOCUS_NEXT_PANE: | 802 case FOCUS_NEXT_PANE: |
786 case FOCUS_PREVIOUS_PANE: | 803 case FOCUS_PREVIOUS_PANE: |
787 case FOCUS_SHELF: | 804 case FOCUS_SHELF: |
788 case LAUNCH_APP_0: | 805 case LAUNCH_APP_0: |
789 case LAUNCH_APP_1: | 806 case LAUNCH_APP_1: |
790 case LAUNCH_APP_2: | 807 case LAUNCH_APP_2: |
791 case LAUNCH_APP_3: | 808 case LAUNCH_APP_3: |
792 case LAUNCH_APP_4: | 809 case LAUNCH_APP_4: |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 case BRIGHTNESS_UP: { | 995 case BRIGHTNESS_UP: { |
979 BrightnessControlDelegate* delegate = | 996 BrightnessControlDelegate* delegate = |
980 WmShell::Get()->brightness_control_delegate(); | 997 WmShell::Get()->brightness_control_delegate(); |
981 if (delegate) | 998 if (delegate) |
982 delegate->HandleBrightnessUp(accelerator); | 999 delegate->HandleBrightnessUp(accelerator); |
983 break; | 1000 break; |
984 } | 1001 } |
985 case DEBUG_SHOW_TOAST: | 1002 case DEBUG_SHOW_TOAST: |
986 case DEBUG_TOGGLE_TOUCH_PAD: | 1003 case DEBUG_TOGGLE_TOUCH_PAD: |
987 case DEBUG_TOGGLE_TOUCH_SCREEN: | 1004 case DEBUG_TOGGLE_TOUCH_SCREEN: |
988 case DEBUG_TOGGLE_TOUCH_VIEW: | |
989 debug::PerformDebugActionIfEnabled(action); | 1005 debug::PerformDebugActionIfEnabled(action); |
990 break; | 1006 break; |
| 1007 case DEV_TOGGLE_TOUCH_VIEW: |
| 1008 HandleToggleTouchView(); |
| 1009 break; |
991 case DISABLE_CAPS_LOCK: | 1010 case DISABLE_CAPS_LOCK: |
992 HandleDisableCapsLock(); | 1011 HandleDisableCapsLock(); |
993 break; | 1012 break; |
994 case KEYBOARD_BRIGHTNESS_DOWN: { | 1013 case KEYBOARD_BRIGHTNESS_DOWN: { |
995 KeyboardBrightnessControlDelegate* delegate = | 1014 KeyboardBrightnessControlDelegate* delegate = |
996 WmShell::Get()->keyboard_brightness_control_delegate(); | 1015 WmShell::Get()->keyboard_brightness_control_delegate(); |
997 if (delegate) | 1016 if (delegate) |
998 delegate->HandleKeyboardBrightnessDown(accelerator); | 1017 delegate->HandleKeyboardBrightnessDown(accelerator); |
999 break; | 1018 break; |
1000 } | 1019 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 1124 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
1106 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1125 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
1107 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 1126 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
1108 A11Y_ALERT_WINDOW_NEEDED); | 1127 A11Y_ALERT_WINDOW_NEEDED); |
1109 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1128 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
1110 } | 1129 } |
1111 return RESTRICTION_NONE; | 1130 return RESTRICTION_NONE; |
1112 } | 1131 } |
1113 | 1132 |
1114 } // namespace ash | 1133 } // namespace ash |
OLD | NEW |