| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 return CanHandleToggleAppList(accelerator, previous_accelerator); | 775 return CanHandleToggleAppList(accelerator, previous_accelerator); |
| 760 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 776 case WINDOW_CYCLE_SNAP_DOCK_LEFT: |
| 761 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 777 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: |
| 762 return CanHandleWindowSnapOrDock(); | 778 return CanHandleWindowSnapOrDock(); |
| 763 case WINDOW_POSITION_CENTER: | 779 case WINDOW_POSITION_CENTER: |
| 764 return CanHandlePositionCenter(); | 780 return CanHandlePositionCenter(); |
| 765 #if defined(OS_CHROMEOS) | 781 #if defined(OS_CHROMEOS) |
| 766 case DEBUG_SHOW_TOAST: | 782 case DEBUG_SHOW_TOAST: |
| 767 case DEBUG_TOGGLE_TOUCH_PAD: | 783 case DEBUG_TOGGLE_TOUCH_PAD: |
| 768 case DEBUG_TOGGLE_TOUCH_SCREEN: | 784 case DEBUG_TOGGLE_TOUCH_SCREEN: |
| 769 case DEBUG_TOGGLE_TOUCH_VIEW: | |
| 770 return debug::DebugAcceleratorsEnabled(); | 785 return debug::DebugAcceleratorsEnabled(); |
| 771 case DISABLE_CAPS_LOCK: | 786 case DISABLE_CAPS_LOCK: |
| 772 return CanHandleDisableCapsLock(previous_accelerator); | 787 return CanHandleDisableCapsLock(previous_accelerator); |
| 773 case LOCK_SCREEN: | 788 case LOCK_SCREEN: |
| 774 return CanHandleLock(); | 789 return CanHandleLock(); |
| 775 case SHOW_STYLUS_TOOLS: | 790 case SHOW_STYLUS_TOOLS: |
| 776 return CanHandleShowStylusTools(); | 791 return CanHandleShowStylusTools(); |
| 777 case SWITCH_TO_PREVIOUS_USER: | 792 case SWITCH_TO_PREVIOUS_USER: |
| 778 case SWITCH_TO_NEXT_USER: | 793 case SWITCH_TO_NEXT_USER: |
| 779 return CanHandleCycleUser(); | 794 return CanHandleCycleUser(); |
| 780 case TOGGLE_CAPS_LOCK: | 795 case TOGGLE_CAPS_LOCK: |
| 781 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 796 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
| 797 case DEBUG_TOGGLE_TOUCH_VIEW: |
| 798 return debug::DeveloperAcceleratorsEnabled(); |
| 782 #endif | 799 #endif |
| 783 case EXIT: | 800 case EXIT: |
| 784 case FOCUS_NEXT_PANE: | 801 case FOCUS_NEXT_PANE: |
| 785 case FOCUS_PREVIOUS_PANE: | 802 case FOCUS_PREVIOUS_PANE: |
| 786 case FOCUS_SHELF: | 803 case FOCUS_SHELF: |
| 787 case LAUNCH_APP_0: | 804 case LAUNCH_APP_0: |
| 788 case LAUNCH_APP_1: | 805 case LAUNCH_APP_1: |
| 789 case LAUNCH_APP_2: | 806 case LAUNCH_APP_2: |
| 790 case LAUNCH_APP_3: | 807 case LAUNCH_APP_3: |
| 791 case LAUNCH_APP_4: | 808 case LAUNCH_APP_4: |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 case BRIGHTNESS_UP: { | 993 case BRIGHTNESS_UP: { |
| 977 BrightnessControlDelegate* delegate = | 994 BrightnessControlDelegate* delegate = |
| 978 WmShell::Get()->brightness_control_delegate(); | 995 WmShell::Get()->brightness_control_delegate(); |
| 979 if (delegate) | 996 if (delegate) |
| 980 delegate->HandleBrightnessUp(accelerator); | 997 delegate->HandleBrightnessUp(accelerator); |
| 981 break; | 998 break; |
| 982 } | 999 } |
| 983 case DEBUG_SHOW_TOAST: | 1000 case DEBUG_SHOW_TOAST: |
| 984 case DEBUG_TOGGLE_TOUCH_PAD: | 1001 case DEBUG_TOGGLE_TOUCH_PAD: |
| 985 case DEBUG_TOGGLE_TOUCH_SCREEN: | 1002 case DEBUG_TOGGLE_TOUCH_SCREEN: |
| 1003 debug::PerformDebugActionIfEnabled(action); |
| 1004 break; |
| 986 case DEBUG_TOGGLE_TOUCH_VIEW: | 1005 case DEBUG_TOGGLE_TOUCH_VIEW: |
| 987 debug::PerformDebugActionIfEnabled(action); | 1006 HandleToggleTouchView(); |
| 988 break; | 1007 break; |
| 989 case DISABLE_CAPS_LOCK: | 1008 case DISABLE_CAPS_LOCK: |
| 990 HandleDisableCapsLock(); | 1009 HandleDisableCapsLock(); |
| 991 break; | 1010 break; |
| 992 case KEYBOARD_BRIGHTNESS_DOWN: { | 1011 case KEYBOARD_BRIGHTNESS_DOWN: { |
| 993 KeyboardBrightnessControlDelegate* delegate = | 1012 KeyboardBrightnessControlDelegate* delegate = |
| 994 WmShell::Get()->keyboard_brightness_control_delegate(); | 1013 WmShell::Get()->keyboard_brightness_control_delegate(); |
| 995 if (delegate) | 1014 if (delegate) |
| 996 delegate->HandleKeyboardBrightnessDown(accelerator); | 1015 delegate->HandleKeyboardBrightnessDown(accelerator); |
| 997 break; | 1016 break; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 1122 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
| 1104 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1123 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
| 1105 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 1124 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
| 1106 A11Y_ALERT_WINDOW_NEEDED); | 1125 A11Y_ALERT_WINDOW_NEEDED); |
| 1107 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1126 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1108 } | 1127 } |
| 1109 return RESTRICTION_NONE; | 1128 return RESTRICTION_NONE; |
| 1110 } | 1129 } |
| 1111 | 1130 |
| 1112 } // namespace ash | 1131 } // namespace ash |
| OLD | NEW |