| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ash/common/wm/window_cycle_controller.h" | 26 #include "ash/common/wm/window_cycle_controller.h" |
| 27 #include "ash/common/wm/window_positioning_utils.h" | 27 #include "ash/common/wm/window_positioning_utils.h" |
| 28 #include "ash/common/wm/window_state.h" | 28 #include "ash/common/wm/window_state.h" |
| 29 #include "ash/common/wm/wm_event.h" | 29 #include "ash/common/wm/wm_event.h" |
| 30 #include "ash/common/wm_shell.h" | 30 #include "ash/common/wm_shell.h" |
| 31 #include "ash/common/wm_window.h" | 31 #include "ash/common/wm_window.h" |
| 32 #include "base/metrics/histogram_macros.h" | 32 #include "base/metrics/histogram_macros.h" |
| 33 #include "base/metrics/user_metrics.h" | 33 #include "base/metrics/user_metrics.h" |
| 34 #include "ui/base/accelerators/accelerator.h" | 34 #include "ui/base/accelerators/accelerator.h" |
| 35 #include "ui/base/accelerators/accelerator_manager.h" | 35 #include "ui/base/accelerators/accelerator_manager.h" |
| 36 #include "ui/keyboard/keyboard_controller.h" |
| 36 | 37 |
| 37 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
| 38 #include "ash/common/shelf/wm_shelf.h" | 39 #include "ash/common/shelf/wm_shelf.h" |
| 39 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" | 40 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
| 40 #include "ash/common/system/status_area_widget.h" | 41 #include "ash/common/system/status_area_widget.h" |
| 41 #include "ash/common/wm_root_window_controller.h" | 42 #include "ash/common/wm_root_window_controller.h" |
| 42 #include "ash/common/wm_window.h" | 43 #include "ash/common/wm_window.h" |
| 43 #include "chromeos/dbus/dbus_thread_manager.h" | 44 #include "chromeos/dbus/dbus_thread_manager.h" |
| 44 #include "chromeos/dbus/power_manager_client.h" | 45 #include "chromeos/dbus/power_manager_client.h" |
| 45 #include "ui/base/ime/chromeos/ime_keyboard.h" | 46 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 void HandleNewWindow() { | 130 void HandleNewWindow() { |
| 130 base::RecordAction(UserMetricsAction("Accel_New_Window")); | 131 base::RecordAction(UserMetricsAction("Accel_New_Window")); |
| 131 WmShell::Get()->new_window_delegate()->NewWindow(false /* is_incognito */); | 132 WmShell::Get()->new_window_delegate()->NewWindow(false /* is_incognito */); |
| 132 } | 133 } |
| 133 | 134 |
| 134 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { | 135 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) { |
| 135 return ime_control_delegate && ime_control_delegate->CanCycleIme(); | 136 return ime_control_delegate && ime_control_delegate->CanCycleIme(); |
| 136 } | 137 } |
| 137 | 138 |
| 139 bool CanHandleCycleMru(const ui::Accelerator& accelerator) { |
| 140 // Don't do anything when Alt+Tab comes from a virtual keyboard. Touchscreen |
| 141 // users have better window switching options. See http://crbug.com/638269 |
| 142 keyboard::KeyboardController* keyboard_controller = |
| 143 keyboard::KeyboardController::GetInstance(); |
| 144 return !(keyboard_controller && keyboard_controller->keyboard_visible() && |
| 145 (accelerator.modifiers() & ui::EF_IS_SYNTHESIZED)); |
| 146 } |
| 147 |
| 138 // We must avoid showing the Deprecated NEXT_IME notification erronously. | 148 // We must avoid showing the Deprecated NEXT_IME notification erronously. |
| 139 bool ShouldShowDeprecatedNextImeNotification( | 149 bool ShouldShowDeprecatedNextImeNotification( |
| 140 const ui::Accelerator& previous_accelerator) { | 150 const ui::Accelerator& previous_accelerator) { |
| 141 // We only show the deprecation notification if the previous accelerator key | 151 // We only show the deprecation notification if the previous accelerator key |
| 142 // is ONLY either Shift, or Alt. | 152 // is ONLY either Shift, or Alt. |
| 143 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); | 153 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); |
| 144 switch (previous_key_code) { | 154 switch (previous_key_code) { |
| 145 case ui::VKEY_SHIFT: | 155 case ui::VKEY_SHIFT: |
| 146 case ui::VKEY_LSHIFT: | 156 case ui::VKEY_LSHIFT: |
| 147 case ui::VKEY_RSHIFT: | 157 case ui::VKEY_RSHIFT: |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 if (restriction != RESTRICTION_NONE) | 672 if (restriction != RESTRICTION_NONE) |
| 663 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 673 return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 664 | 674 |
| 665 const ui::Accelerator& previous_accelerator = | 675 const ui::Accelerator& previous_accelerator = |
| 666 accelerator_history_->previous_accelerator(); | 676 accelerator_history_->previous_accelerator(); |
| 667 | 677 |
| 668 // True should be returned if running |action| does something. Otherwise, | 678 // True should be returned if running |action| does something. Otherwise, |
| 669 // false should be returned to give the web contents a chance at handling the | 679 // false should be returned to give the web contents a chance at handling the |
| 670 // accelerator. | 680 // accelerator. |
| 671 switch (action) { | 681 switch (action) { |
| 682 case CYCLE_BACKWARD_MRU: |
| 683 case CYCLE_FORWARD_MRU: |
| 684 return CanHandleCycleMru(accelerator); |
| 672 case DEBUG_PRINT_LAYER_HIERARCHY: | 685 case DEBUG_PRINT_LAYER_HIERARCHY: |
| 673 case DEBUG_PRINT_VIEW_HIERARCHY: | 686 case DEBUG_PRINT_VIEW_HIERARCHY: |
| 674 case DEBUG_PRINT_WINDOW_HIERARCHY: | 687 case DEBUG_PRINT_WINDOW_HIERARCHY: |
| 675 return debug::DebugAcceleratorsEnabled(); | 688 return debug::DebugAcceleratorsEnabled(); |
| 676 case NEW_INCOGNITO_WINDOW: | 689 case NEW_INCOGNITO_WINDOW: |
| 677 return CanHandleNewIncognitoWindow(); | 690 return CanHandleNewIncognitoWindow(); |
| 678 case NEXT_IME: | 691 case NEXT_IME: |
| 679 return CanHandleNextIme(ime_control_delegate_.get()); | 692 return CanHandleNextIme(ime_control_delegate_.get()); |
| 680 case PREVIOUS_IME: | 693 case PREVIOUS_IME: |
| 681 return CanHandlePreviousIme(ime_control_delegate_.get()); | 694 return CanHandlePreviousIme(ime_control_delegate_.get()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 697 case DISABLE_CAPS_LOCK: | 710 case DISABLE_CAPS_LOCK: |
| 698 return CanHandleDisableCapsLock(previous_accelerator); | 711 return CanHandleDisableCapsLock(previous_accelerator); |
| 699 case LOCK_SCREEN: | 712 case LOCK_SCREEN: |
| 700 return CanHandleLock(); | 713 return CanHandleLock(); |
| 701 case SWITCH_TO_PREVIOUS_USER: | 714 case SWITCH_TO_PREVIOUS_USER: |
| 702 case SWITCH_TO_NEXT_USER: | 715 case SWITCH_TO_NEXT_USER: |
| 703 return CanHandleCycleUser(); | 716 return CanHandleCycleUser(); |
| 704 case TOGGLE_CAPS_LOCK: | 717 case TOGGLE_CAPS_LOCK: |
| 705 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 718 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
| 706 #endif | 719 #endif |
| 707 case CYCLE_BACKWARD_MRU: | |
| 708 case CYCLE_FORWARD_MRU: | |
| 709 case EXIT: | 720 case EXIT: |
| 710 case FOCUS_NEXT_PANE: | 721 case FOCUS_NEXT_PANE: |
| 711 case FOCUS_PREVIOUS_PANE: | 722 case FOCUS_PREVIOUS_PANE: |
| 712 case MEDIA_NEXT_TRACK: | 723 case MEDIA_NEXT_TRACK: |
| 713 case MEDIA_PLAY_PAUSE: | 724 case MEDIA_PLAY_PAUSE: |
| 714 case MEDIA_PREV_TRACK: | 725 case MEDIA_PREV_TRACK: |
| 715 case NEW_TAB: | 726 case NEW_TAB: |
| 716 case NEW_WINDOW: | 727 case NEW_WINDOW: |
| 717 case OPEN_FEEDBACK_PAGE: | 728 case OPEN_FEEDBACK_PAGE: |
| 718 case PRINT_UI_HIERARCHIES: | 729 case PRINT_UI_HIERARCHIES: |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 } | 954 } |
| 944 | 955 |
| 945 bool AcceleratorController::ShouldActionConsumeKeyEvent( | 956 bool AcceleratorController::ShouldActionConsumeKeyEvent( |
| 946 AcceleratorAction action) { | 957 AcceleratorAction action) { |
| 947 // Adding new exceptions is *STRONGLY* discouraged. | 958 // Adding new exceptions is *STRONGLY* discouraged. |
| 948 return true; | 959 return true; |
| 949 } | 960 } |
| 950 | 961 |
| 951 AcceleratorController::AcceleratorProcessingRestriction | 962 AcceleratorController::AcceleratorProcessingRestriction |
| 952 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { | 963 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
| 953 if (WmShell::Get()->IsPinned() && | 964 WmShell* wm_shell = WmShell::Get(); |
| 965 if (wm_shell->IsPinned() && |
| 954 actions_allowed_in_pinned_mode_.find(action) == | 966 actions_allowed_in_pinned_mode_.find(action) == |
| 955 actions_allowed_in_pinned_mode_.end()) { | 967 actions_allowed_in_pinned_mode_.end()) { |
| 956 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 968 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 957 } | 969 } |
| 958 WmShell* wm_shell = WmShell::Get(); | |
| 959 if (!wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted() && | 970 if (!wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted() && |
| 960 actions_allowed_at_login_screen_.find(action) == | 971 actions_allowed_at_login_screen_.find(action) == |
| 961 actions_allowed_at_login_screen_.end()) { | 972 actions_allowed_at_login_screen_.end()) { |
| 962 return RESTRICTION_PREVENT_PROCESSING; | 973 return RESTRICTION_PREVENT_PROCESSING; |
| 963 } | 974 } |
| 964 if (wm_shell->GetSessionStateDelegate()->IsScreenLocked() && | 975 if (wm_shell->GetSessionStateDelegate()->IsScreenLocked() && |
| 965 actions_allowed_at_lock_screen_.find(action) == | 976 actions_allowed_at_lock_screen_.find(action) == |
| 966 actions_allowed_at_lock_screen_.end()) { | 977 actions_allowed_at_lock_screen_.end()) { |
| 967 return RESTRICTION_PREVENT_PROCESSING; | 978 return RESTRICTION_PREVENT_PROCESSING; |
| 968 } | 979 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 983 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 994 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
| 984 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 995 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
| 985 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 996 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
| 986 A11Y_ALERT_WINDOW_NEEDED); | 997 A11Y_ALERT_WINDOW_NEEDED); |
| 987 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 998 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 988 } | 999 } |
| 989 return RESTRICTION_NONE; | 1000 return RESTRICTION_NONE; |
| 990 } | 1001 } |
| 991 | 1002 |
| 992 } // namespace ash | 1003 } // namespace ash |
| OLD | NEW |