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 29 matching lines...) Expand all Loading... |
40 #include "ui/base/accelerators/accelerator_manager.h" | 40 #include "ui/base/accelerators/accelerator_manager.h" |
41 #include "ui/keyboard/keyboard_controller.h" | 41 #include "ui/keyboard/keyboard_controller.h" |
42 | 42 |
43 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
44 #include "ash/common/palette_delegate.h" | 44 #include "ash/common/palette_delegate.h" |
45 #include "ash/common/shelf/wm_shelf.h" | 45 #include "ash/common/shelf/wm_shelf.h" |
46 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" | 46 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
47 #include "ash/common/system/chromeos/palette/palette_tray.h" | 47 #include "ash/common/system/chromeos/palette/palette_tray.h" |
48 #include "ash/common/system/chromeos/palette/palette_utils.h" | 48 #include "ash/common/system/chromeos/palette/palette_utils.h" |
49 #include "ash/common/system/status_area_widget.h" | 49 #include "ash/common/system/status_area_widget.h" |
| 50 #include "ash/common/system/system_notifier.h" |
50 #include "ash/common/wm_root_window_controller.h" | 51 #include "ash/common/wm_root_window_controller.h" |
51 #include "ash/common/wm_window.h" | 52 #include "ash/common/wm_window.h" |
| 53 #include "ash/resources/vector_icons/vector_icons.h" |
52 #include "chromeos/dbus/dbus_thread_manager.h" | 54 #include "chromeos/dbus/dbus_thread_manager.h" |
53 #include "chromeos/dbus/power_manager_client.h" | 55 #include "chromeos/dbus/power_manager_client.h" |
| 56 #include "grit/ash_strings.h" |
54 #include "ui/base/ime/chromeos/ime_keyboard.h" | 57 #include "ui/base/ime/chromeos/ime_keyboard.h" |
55 #include "ui/base/ime/chromeos/input_method_manager.h" | 58 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 59 #include "ui/base/l10n/l10n_util.h" |
| 60 #include "ui/gfx/paint_vector_icon.h" |
| 61 #include "ui/message_center/message_center.h" |
56 #endif // defined(OS_CHROMEOS) | 62 #endif // defined(OS_CHROMEOS) |
57 | 63 |
58 namespace ash { | 64 namespace ash { |
59 namespace { | 65 namespace { |
60 | 66 |
61 using base::UserMetricsAction; | 67 using base::UserMetricsAction; |
62 | 68 |
63 ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode, | 69 ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode, |
64 int modifiers, | 70 int modifiers, |
65 bool trigger_on_press) { | 71 bool trigger_on_press) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | 338 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); |
333 return (active_window && !active_window->GetWindowState()->IsDocked()); | 339 return (active_window && !active_window->GetWindowState()->IsDocked()); |
334 } | 340 } |
335 | 341 |
336 void HandlePositionCenter() { | 342 void HandlePositionCenter() { |
337 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); | 343 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); |
338 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); | 344 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); |
339 } | 345 } |
340 | 346 |
341 #if defined(OS_CHROMEOS) | 347 #if defined(OS_CHROMEOS) |
| 348 |
| 349 using message_center::Notification; |
| 350 |
| 351 // Identifier for the high contrast toggle accelerator notification. |
| 352 const char kHighContrastToggleAccelNotificationId[] = |
| 353 "chrome://settings/accessibility/highcontrast"; |
| 354 |
342 void HandleShowImeMenuBubble() { | 355 void HandleShowImeMenuBubble() { |
343 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); | 356 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); |
344 | 357 |
345 StatusAreaWidget* status_area_widget = | 358 StatusAreaWidget* status_area_widget = |
346 WmShelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()) | 359 WmShelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()) |
347 ->GetStatusAreaWidget(); | 360 ->GetStatusAreaWidget(); |
348 if (status_area_widget) { | 361 if (status_area_widget) { |
349 ImeMenuTray* ime_menu_tray = status_area_widget->ime_menu_tray(); | 362 ImeMenuTray* ime_menu_tray = status_area_widget->ime_menu_tray(); |
350 if (ime_menu_tray && ime_menu_tray->visible() && | 363 if (ime_menu_tray && ime_menu_tray->visible() && |
351 !ime_menu_tray->IsImeMenuBubbleShown()) { | 364 !ime_menu_tray->IsImeMenuBubbleShown()) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 472 } |
460 | 473 |
461 void HandleToggleCapsLock() { | 474 void HandleToggleCapsLock() { |
462 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); | 475 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); |
463 chromeos::input_method::InputMethodManager* ime = | 476 chromeos::input_method::InputMethodManager* ime = |
464 chromeos::input_method::InputMethodManager::Get(); | 477 chromeos::input_method::InputMethodManager::Get(); |
465 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); | 478 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); |
466 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 479 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
467 } | 480 } |
468 | 481 |
| 482 void HandleToggleHighContrast() { |
| 483 base::RecordAction(UserMetricsAction("Accel_Toggle_High_Contrast")); |
| 484 |
| 485 // Show a notification so the user knows that this accelerator toggled |
| 486 // high contrast mode, and that they can press it again to toggle back. |
| 487 // The message center automatically only shows this once per session. |
| 488 std::unique_ptr<Notification> notification(new Notification( |
| 489 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 490 kHighContrastToggleAccelNotificationId, base::string16() /* title */, |
| 491 l10n_util::GetStringUTF16(IDS_HIGH_CONTRAST_ACCEL_MSG), |
| 492 gfx::Image(CreateVectorIcon(kSystemMenuAccessibilityIcon, SK_ColorBLACK)), |
| 493 base::string16() /* display source */, GURL(), |
| 494 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
| 495 system_notifier::kNotifierAccessibility), |
| 496 message_center::RichNotificationData(), nullptr)); |
| 497 message_center::MessageCenter::Get()->AddNotification( |
| 498 std::move(notification)); |
| 499 |
| 500 WmShell::Get()->accessibility_delegate()->ToggleHighContrast(); |
| 501 } |
| 502 |
469 void HandleToggleSpokenFeedback() { | 503 void HandleToggleSpokenFeedback() { |
470 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); | 504 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); |
471 | 505 |
472 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 506 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
473 A11Y_NOTIFICATION_SHOW); | 507 A11Y_NOTIFICATION_SHOW); |
474 } | 508 } |
475 | 509 |
476 void HandleVolumeDown(mojom::VolumeController* volume_controller, | 510 void HandleVolumeDown(mojom::VolumeController* volume_controller, |
477 const ui::Accelerator& accelerator) { | 511 const ui::Accelerator& accelerator) { |
478 if (accelerator.key_code() == ui::VKEY_VOLUME_DOWN) | 512 if (accelerator.key_code() == ui::VKEY_VOLUME_DOWN) |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 #if defined(OS_CHROMEOS) | 859 #if defined(OS_CHROMEOS) |
826 case BRIGHTNESS_DOWN: | 860 case BRIGHTNESS_DOWN: |
827 case BRIGHTNESS_UP: | 861 case BRIGHTNESS_UP: |
828 case KEYBOARD_BRIGHTNESS_DOWN: | 862 case KEYBOARD_BRIGHTNESS_DOWN: |
829 case KEYBOARD_BRIGHTNESS_UP: | 863 case KEYBOARD_BRIGHTNESS_UP: |
830 case OPEN_CROSH: | 864 case OPEN_CROSH: |
831 case OPEN_FILE_MANAGER: | 865 case OPEN_FILE_MANAGER: |
832 case OPEN_GET_HELP: | 866 case OPEN_GET_HELP: |
833 case SHOW_IME_MENU_BUBBLE: | 867 case SHOW_IME_MENU_BUBBLE: |
834 case SUSPEND: | 868 case SUSPEND: |
| 869 case TOGGLE_HIGH_CONTRAST: |
835 case TOGGLE_SPOKEN_FEEDBACK: | 870 case TOGGLE_SPOKEN_FEEDBACK: |
836 case TOGGLE_WIFI: | 871 case TOGGLE_WIFI: |
837 case VOLUME_DOWN: | 872 case VOLUME_DOWN: |
838 case VOLUME_MUTE: | 873 case VOLUME_MUTE: |
839 case VOLUME_UP: | 874 case VOLUME_UP: |
840 #else | 875 #else |
841 case DUMMY_FOR_RESERVED: | 876 case DUMMY_FOR_RESERVED: |
842 #endif | 877 #endif |
843 return true; | 878 return true; |
844 | 879 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 break; | 1077 break; |
1043 case SWITCH_TO_NEXT_USER: | 1078 case SWITCH_TO_NEXT_USER: |
1044 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); | 1079 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); |
1045 break; | 1080 break; |
1046 case SWITCH_TO_PREVIOUS_USER: | 1081 case SWITCH_TO_PREVIOUS_USER: |
1047 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); | 1082 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); |
1048 break; | 1083 break; |
1049 case TOGGLE_CAPS_LOCK: | 1084 case TOGGLE_CAPS_LOCK: |
1050 HandleToggleCapsLock(); | 1085 HandleToggleCapsLock(); |
1051 break; | 1086 break; |
| 1087 case TOGGLE_HIGH_CONTRAST: |
| 1088 HandleToggleHighContrast(); |
| 1089 break; |
1052 case TOGGLE_SPOKEN_FEEDBACK: | 1090 case TOGGLE_SPOKEN_FEEDBACK: |
1053 HandleToggleSpokenFeedback(); | 1091 HandleToggleSpokenFeedback(); |
1054 break; | 1092 break; |
1055 case TOGGLE_WIFI: | 1093 case TOGGLE_WIFI: |
1056 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); | 1094 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); |
1057 break; | 1095 break; |
1058 case VOLUME_DOWN: | 1096 case VOLUME_DOWN: |
1059 HandleVolumeDown(GetVolumeController(), accelerator); | 1097 HandleVolumeDown(GetVolumeController(), accelerator); |
1060 break; | 1098 break; |
1061 case VOLUME_MUTE: | 1099 case VOLUME_MUTE: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 base::Unretained(this))); | 1172 base::Unretained(this))); |
1135 } | 1173 } |
1136 return volume_controller_.get(); | 1174 return volume_controller_.get(); |
1137 } | 1175 } |
1138 | 1176 |
1139 void AcceleratorController::OnVolumeControllerConnectionError() { | 1177 void AcceleratorController::OnVolumeControllerConnectionError() { |
1140 volume_controller_.reset(); | 1178 volume_controller_.reset(); |
1141 } | 1179 } |
1142 | 1180 |
1143 } // namespace ash | 1181 } // namespace ash |
OLD | NEW |