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/wm_shelf.h" |
18 #include "ash/common/shell_delegate.h" | 19 #include "ash/common/shell_delegate.h" |
19 #include "ash/common/system/brightness_control_delegate.h" | 20 #include "ash/common/system/brightness_control_delegate.h" |
20 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 21 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 22 #include "ash/common/system/status_area_widget.h" |
21 #include "ash/common/system/tray/system_tray_delegate.h" | 23 #include "ash/common/system/tray/system_tray_delegate.h" |
22 #include "ash/common/system/tray/system_tray_notifier.h" | 24 #include "ash/common/system/tray/system_tray_notifier.h" |
23 #include "ash/common/system/volume_control_delegate.h" | 25 #include "ash/common/system/volume_control_delegate.h" |
24 #include "ash/common/wm/mru_window_tracker.h" | 26 #include "ash/common/wm/mru_window_tracker.h" |
25 #include "ash/common/wm/overview/window_selector_controller.h" | 27 #include "ash/common/wm/overview/window_selector_controller.h" |
26 #include "ash/common/wm/window_cycle_controller.h" | 28 #include "ash/common/wm/window_cycle_controller.h" |
27 #include "ash/common/wm/window_positioning_utils.h" | 29 #include "ash/common/wm/window_positioning_utils.h" |
28 #include "ash/common/wm/window_state.h" | 30 #include "ash/common/wm/window_state.h" |
29 #include "ash/common/wm/wm_event.h" | 31 #include "ash/common/wm/wm_event.h" |
| 32 #include "ash/common/wm_root_window_controller.h" |
30 #include "ash/common/wm_shell.h" | 33 #include "ash/common/wm_shell.h" |
31 #include "ash/common/wm_window.h" | 34 #include "ash/common/wm_window.h" |
32 #include "base/metrics/histogram_macros.h" | 35 #include "base/metrics/histogram_macros.h" |
33 #include "base/metrics/user_metrics.h" | 36 #include "base/metrics/user_metrics.h" |
34 #include "ui/base/accelerators/accelerator.h" | 37 #include "ui/base/accelerators/accelerator.h" |
35 #include "ui/base/accelerators/accelerator_manager.h" | 38 #include "ui/base/accelerators/accelerator_manager.h" |
36 | 39 |
37 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
| 41 #include "ash/common/palette_delegate.h" |
| 42 #include "ash/common/system/chromeos/palette/palette_tray.h" |
| 43 #include "ash/common/system/chromeos/palette/palette_utils.h" |
38 #include "chromeos/dbus/dbus_thread_manager.h" | 44 #include "chromeos/dbus/dbus_thread_manager.h" |
39 #include "chromeos/dbus/power_manager_client.h" | 45 #include "chromeos/dbus/power_manager_client.h" |
40 #include "ui/base/ime/chromeos/ime_keyboard.h" | 46 #include "ui/base/ime/chromeos/ime_keyboard.h" |
41 #include "ui/base/ime/chromeos/input_method_manager.h" | 47 #include "ui/base/ime/chromeos/input_method_manager.h" |
42 #endif // defined(OS_CHROMEOS) | 48 #endif // defined(OS_CHROMEOS) |
43 | 49 |
44 namespace ash { | 50 namespace ash { |
45 namespace { | 51 namespace { |
46 | 52 |
47 using base::UserMetricsAction; | 53 using base::UserMetricsAction; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 326 |
321 bool CanHandleLock() { | 327 bool CanHandleLock() { |
322 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); | 328 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); |
323 } | 329 } |
324 | 330 |
325 void HandleLock() { | 331 void HandleLock() { |
326 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); | 332 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
327 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 333 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
328 } | 334 } |
329 | 335 |
| 336 void HandleShowStylusTools() { |
| 337 base::RecordAction(UserMetricsAction("Accel_Show_Stylus_Tools")); |
| 338 |
| 339 WmRootWindowController* root_window_controller = |
| 340 WmShell::Get()->GetRootWindowForNewWindows()->GetRootWindowController(); |
| 341 PaletteTray* palette_tray = |
| 342 root_window_controller->GetShelf()->GetStatusAreaWidget()->palette_tray(); |
| 343 palette_tray->OpenBubble(); |
| 344 } |
| 345 |
| 346 bool CanHandleShowStylusTools() { |
| 347 return IsPaletteFeatureEnabled() && |
| 348 WmShell::Get()->palette_delegate()->ShouldShowPalette(); |
| 349 } |
| 350 |
330 void HandleSuspend() { | 351 void HandleSuspend() { |
331 base::RecordAction(UserMetricsAction("Accel_Suspend")); | 352 base::RecordAction(UserMetricsAction("Accel_Suspend")); |
332 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); | 353 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); |
333 } | 354 } |
334 | 355 |
335 bool CanHandleCycleUser() { | 356 bool CanHandleCycleUser() { |
336 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && | 357 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() && |
337 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1; | 358 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1; |
338 } | 359 } |
339 | 360 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 #if defined(OS_CHROMEOS) | 690 #if defined(OS_CHROMEOS) |
670 case DEBUG_SHOW_TOAST: | 691 case DEBUG_SHOW_TOAST: |
671 case DEBUG_TOGGLE_TOUCH_PAD: | 692 case DEBUG_TOGGLE_TOUCH_PAD: |
672 case DEBUG_TOGGLE_TOUCH_SCREEN: | 693 case DEBUG_TOGGLE_TOUCH_SCREEN: |
673 case DEBUG_TOGGLE_TOUCH_VIEW: | 694 case DEBUG_TOGGLE_TOUCH_VIEW: |
674 return debug::DebugAcceleratorsEnabled(); | 695 return debug::DebugAcceleratorsEnabled(); |
675 case DISABLE_CAPS_LOCK: | 696 case DISABLE_CAPS_LOCK: |
676 return CanHandleDisableCapsLock(previous_accelerator); | 697 return CanHandleDisableCapsLock(previous_accelerator); |
677 case LOCK_SCREEN: | 698 case LOCK_SCREEN: |
678 return CanHandleLock(); | 699 return CanHandleLock(); |
| 700 case SHOW_STYLUS_TOOLS: |
| 701 return CanHandleShowStylusTools(); |
679 case SWITCH_TO_PREVIOUS_USER: | 702 case SWITCH_TO_PREVIOUS_USER: |
680 case SWITCH_TO_NEXT_USER: | 703 case SWITCH_TO_NEXT_USER: |
681 return CanHandleCycleUser(); | 704 return CanHandleCycleUser(); |
682 case TOGGLE_CAPS_LOCK: | 705 case TOGGLE_CAPS_LOCK: |
683 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 706 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
684 #endif | 707 #endif |
685 case CYCLE_BACKWARD_MRU: | 708 case CYCLE_BACKWARD_MRU: |
686 case CYCLE_FORWARD_MRU: | 709 case CYCLE_FORWARD_MRU: |
687 case EXIT: | 710 case EXIT: |
688 case FOCUS_NEXT_PANE: | 711 case FOCUS_NEXT_PANE: |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 break; | 891 break; |
869 case OPEN_CROSH: | 892 case OPEN_CROSH: |
870 HandleCrosh(); | 893 HandleCrosh(); |
871 break; | 894 break; |
872 case OPEN_FILE_MANAGER: | 895 case OPEN_FILE_MANAGER: |
873 HandleFileManager(); | 896 HandleFileManager(); |
874 break; | 897 break; |
875 case OPEN_GET_HELP: | 898 case OPEN_GET_HELP: |
876 HandleGetHelp(); | 899 HandleGetHelp(); |
877 break; | 900 break; |
| 901 case SHOW_STYLUS_TOOLS: |
| 902 HandleShowStylusTools(); |
| 903 break; |
878 case SUSPEND: | 904 case SUSPEND: |
879 HandleSuspend(); | 905 HandleSuspend(); |
880 break; | 906 break; |
881 case SWITCH_TO_NEXT_USER: | 907 case SWITCH_TO_NEXT_USER: |
882 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); | 908 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); |
883 break; | 909 break; |
884 case SWITCH_TO_PREVIOUS_USER: | 910 case SWITCH_TO_PREVIOUS_USER: |
885 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); | 911 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); |
886 break; | 912 break; |
887 case TOGGLE_CAPS_LOCK: | 913 case TOGGLE_CAPS_LOCK: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 983 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
958 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 984 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
959 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 985 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
960 A11Y_ALERT_WINDOW_NEEDED); | 986 A11Y_ALERT_WINDOW_NEEDED); |
961 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 987 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
962 } | 988 } |
963 return RESTRICTION_NONE; | 989 return RESTRICTION_NONE; |
964 } | 990 } |
965 | 991 |
966 } // namespace ash | 992 } // namespace ash |
OLD | NEW |