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" | |
27 #include "ash/common/system/web_notification/web_notification_tray.h" | 26 #include "ash/common/system/web_notification/web_notification_tray.h" |
28 #include "ash/common/wm/mru_window_tracker.h" | 27 #include "ash/common/wm/mru_window_tracker.h" |
29 #include "ash/common/wm/overview/window_selector_controller.h" | 28 #include "ash/common/wm/overview/window_selector_controller.h" |
30 #include "ash/common/wm/window_cycle_controller.h" | 29 #include "ash/common/wm/window_cycle_controller.h" |
31 #include "ash/common/wm/window_positioning_utils.h" | 30 #include "ash/common/wm/window_positioning_utils.h" |
32 #include "ash/common/wm/window_state.h" | 31 #include "ash/common/wm/window_state.h" |
33 #include "ash/common/wm/wm_event.h" | 32 #include "ash/common/wm/wm_event.h" |
34 #include "ash/common/wm_root_window_controller.h" | 33 #include "ash/common/wm_root_window_controller.h" |
35 #include "ash/common/wm_shell.h" | 34 #include "ash/common/wm_shell.h" |
36 #include "ash/common/wm_window.h" | 35 #include "ash/common/wm_window.h" |
37 #include "base/metrics/histogram_macros.h" | 36 #include "base/metrics/histogram_macros.h" |
38 #include "base/metrics/user_metrics.h" | 37 #include "base/metrics/user_metrics.h" |
| 38 #include "services/service_manager/public/cpp/connector.h" |
39 #include "ui/base/accelerators/accelerator.h" | 39 #include "ui/base/accelerators/accelerator.h" |
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" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 WmShell::Get()->accessibility_delegate()->ToggleHighContrast(); | 472 WmShell::Get()->accessibility_delegate()->ToggleHighContrast(); |
473 } | 473 } |
474 | 474 |
475 void HandleToggleSpokenFeedback() { | 475 void HandleToggleSpokenFeedback() { |
476 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); | 476 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); |
477 | 477 |
478 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | 478 WmShell::Get()->accessibility_delegate()->ToggleSpokenFeedback( |
479 A11Y_NOTIFICATION_SHOW); | 479 A11Y_NOTIFICATION_SHOW); |
480 } | 480 } |
481 | 481 |
482 void HandleVolumeDown(const ui::Accelerator& accelerator) { | 482 void HandleVolumeDown(mojom::VolumeController* volume_controller, |
483 VolumeControlDelegate* volume_delegate = | 483 const ui::Accelerator& accelerator) { |
484 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); | 484 if (accelerator.key_code() == ui::VKEY_VOLUME_DOWN) |
485 if (volume_delegate) | 485 base::RecordAction(UserMetricsAction("Accel_VolumeDown_F9")); |
486 volume_delegate->HandleVolumeDown(accelerator); | 486 |
| 487 if (volume_controller) |
| 488 volume_controller->VolumeDown(); |
487 } | 489 } |
488 | 490 |
489 void HandleVolumeMute(const ui::Accelerator& accelerator) { | 491 void HandleVolumeMute(mojom::VolumeController* volume_controller, |
490 VolumeControlDelegate* volume_delegate = | 492 const ui::Accelerator& accelerator) { |
491 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); | 493 if (accelerator.key_code() == ui::VKEY_VOLUME_MUTE) |
492 if (volume_delegate) | 494 base::RecordAction(UserMetricsAction("Accel_VolumeMute_F8")); |
493 volume_delegate->HandleVolumeMute(accelerator); | 495 |
| 496 if (volume_controller) |
| 497 volume_controller->VolumeMute(); |
494 } | 498 } |
495 | 499 |
496 void HandleVolumeUp(const ui::Accelerator& accelerator) { | 500 void HandleVolumeUp(mojom::VolumeController* volume_controller, |
497 VolumeControlDelegate* volume_delegate = | 501 const ui::Accelerator& accelerator) { |
498 WmShell::Get()->system_tray_delegate()->GetVolumeControlDelegate(); | 502 if (accelerator.key_code() == ui::VKEY_VOLUME_UP) |
499 if (volume_delegate) | 503 base::RecordAction(UserMetricsAction("Accel_VolumeUp_F10")); |
500 volume_delegate->HandleVolumeUp(accelerator); | 504 |
| 505 if (volume_controller) |
| 506 volume_controller->VolumeUp(); |
501 } | 507 } |
502 | 508 |
503 #endif // defined(OS_CHROMEOS) | 509 #endif // defined(OS_CHROMEOS) |
504 | 510 |
505 } // namespace | 511 } // namespace |
506 | 512 |
507 //////////////////////////////////////////////////////////////////////////////// | 513 //////////////////////////////////////////////////////////////////////////////// |
508 // AcceleratorController, public: | 514 // AcceleratorController, public: |
509 | 515 |
510 AcceleratorController::AcceleratorController( | 516 AcceleratorController::AcceleratorController( |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 case TOGGLE_HIGH_CONTRAST: | 1059 case TOGGLE_HIGH_CONTRAST: |
1054 HandleToggleHighContrast(); | 1060 HandleToggleHighContrast(); |
1055 break; | 1061 break; |
1056 case TOGGLE_SPOKEN_FEEDBACK: | 1062 case TOGGLE_SPOKEN_FEEDBACK: |
1057 HandleToggleSpokenFeedback(); | 1063 HandleToggleSpokenFeedback(); |
1058 break; | 1064 break; |
1059 case TOGGLE_WIFI: | 1065 case TOGGLE_WIFI: |
1060 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); | 1066 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); |
1061 break; | 1067 break; |
1062 case VOLUME_DOWN: | 1068 case VOLUME_DOWN: |
1063 HandleVolumeDown(accelerator); | 1069 HandleVolumeDown(GetVolumeController(), accelerator); |
1064 break; | 1070 break; |
1065 case VOLUME_MUTE: | 1071 case VOLUME_MUTE: |
1066 HandleVolumeMute(accelerator); | 1072 HandleVolumeMute(GetVolumeController(), accelerator); |
1067 break; | 1073 break; |
1068 case VOLUME_UP: | 1074 case VOLUME_UP: |
1069 HandleVolumeUp(accelerator); | 1075 HandleVolumeUp(GetVolumeController(), accelerator); |
1070 break; | 1076 break; |
1071 #else | 1077 #else |
1072 case DUMMY_FOR_RESERVED: | 1078 case DUMMY_FOR_RESERVED: |
1073 NOTREACHED(); | 1079 NOTREACHED(); |
1074 break; | 1080 break; |
1075 #endif | 1081 #endif |
1076 default: | 1082 default: |
1077 // Temporary until mash transition complete. Needed as some actions | 1083 // Temporary until mash transition complete. Needed as some actions |
1078 // don't yet work with mash. | 1084 // don't yet work with mash. |
1079 DCHECK(delegate_ && delegate_->HandlesAction(action)); | 1085 DCHECK(delegate_ && delegate_->HandlesAction(action)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 } | 1128 } |
1123 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && | 1129 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && |
1124 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1130 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
1125 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( | 1131 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( |
1126 A11Y_ALERT_WINDOW_NEEDED); | 1132 A11Y_ALERT_WINDOW_NEEDED); |
1127 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1133 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
1128 } | 1134 } |
1129 return RESTRICTION_NONE; | 1135 return RESTRICTION_NONE; |
1130 } | 1136 } |
1131 | 1137 |
| 1138 mojom::VolumeController* AcceleratorController::GetVolumeController() { |
| 1139 if (!volume_controller_ && WmShell::Get()->delegate()->GetShellConnector()) { |
| 1140 WmShell::Get()->delegate()->GetShellConnector()->ConnectToInterface( |
| 1141 "service:content_browser", &volume_controller_); |
| 1142 volume_controller_.set_connection_error_handler( |
| 1143 base::Bind(&AcceleratorController::OnVolumeControllerConnectionError, |
| 1144 base::Unretained(this))); |
| 1145 } |
| 1146 return volume_controller_.get(); |
| 1147 } |
| 1148 |
| 1149 void AcceleratorController::OnVolumeControllerConnectionError() { |
| 1150 volume_controller_.reset(); |
| 1151 } |
| 1152 |
1132 } // namespace ash | 1153 } // namespace ash |
OLD | NEW |