Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: ash/common/accelerators/accelerator_controller.cc

Issue 2552483002: mash: Have chrome set itself as a controller interface for changing volume (Closed)
Patch Set: comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/accelerators/accelerator_controller.h ('k') | ash/common/mojo_interface_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility>
8
7 #include "ash/common/accelerators/accelerator_commands.h" 9 #include "ash/common/accelerators/accelerator_commands.h"
8 #include "ash/common/accelerators/accelerator_controller_delegate.h" 10 #include "ash/common/accelerators/accelerator_controller_delegate.h"
9 #include "ash/common/accelerators/debug_commands.h" 11 #include "ash/common/accelerators/debug_commands.h"
10 #include "ash/common/accessibility_delegate.h" 12 #include "ash/common/accessibility_delegate.h"
11 #include "ash/common/accessibility_types.h" 13 #include "ash/common/accessibility_types.h"
12 #include "ash/common/focus_cycler.h" 14 #include "ash/common/focus_cycler.h"
13 #include "ash/common/ime_control_delegate.h" 15 #include "ash/common/ime_control_delegate.h"
14 #include "ash/common/media_delegate.h" 16 #include "ash/common/media_delegate.h"
15 #include "ash/common/multi_profile_uma.h" 17 #include "ash/common/multi_profile_uma.h"
16 #include "ash/common/session/session_state_delegate.h" 18 #include "ash/common/session/session_state_delegate.h"
(...skipping 11 matching lines...) Expand all
28 #include "ash/common/wm/window_cycle_controller.h" 30 #include "ash/common/wm/window_cycle_controller.h"
29 #include "ash/common/wm/window_positioning_utils.h" 31 #include "ash/common/wm/window_positioning_utils.h"
30 #include "ash/common/wm/window_state.h" 32 #include "ash/common/wm/window_state.h"
31 #include "ash/common/wm/wm_event.h" 33 #include "ash/common/wm/wm_event.h"
32 #include "ash/common/wm_root_window_controller.h" 34 #include "ash/common/wm_root_window_controller.h"
33 #include "ash/common/wm_shell.h" 35 #include "ash/common/wm_shell.h"
34 #include "ash/common/wm_window.h" 36 #include "ash/common/wm_window.h"
35 #include "ash/public/interfaces/new_window.mojom.h" 37 #include "ash/public/interfaces/new_window.mojom.h"
36 #include "base/metrics/histogram_macros.h" 38 #include "base/metrics/histogram_macros.h"
37 #include "base/metrics/user_metrics.h" 39 #include "base/metrics/user_metrics.h"
38 #include "content/public/common/service_names.mojom.h"
39 #include "services/service_manager/public/cpp/connector.h"
40 #include "ui/base/accelerators/accelerator.h" 40 #include "ui/base/accelerators/accelerator.h"
41 #include "ui/base/accelerators/accelerator_manager.h" 41 #include "ui/base/accelerators/accelerator_manager.h"
42 #include "ui/keyboard/keyboard_controller.h" 42 #include "ui/keyboard/keyboard_controller.h"
43 43
44 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
45 #include "ash/common/palette_delegate.h" 45 #include "ash/common/palette_delegate.h"
46 #include "ash/common/shelf/wm_shelf.h" 46 #include "ash/common/shelf/wm_shelf.h"
47 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" 47 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
48 #include "ash/common/system/chromeos/palette/palette_tray.h" 48 #include "ash/common/system/chromeos/palette/palette_tray.h"
49 #include "ash/common/system/chromeos/palette/palette_utils.h" 49 #include "ash/common/system/chromeos/palette/palette_utils.h"
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 PerformAction(action, accelerator); 677 PerformAction(action, accelerator);
678 return ShouldActionConsumeKeyEvent(action); 678 return ShouldActionConsumeKeyEvent(action);
679 } 679 }
680 return false; 680 return false;
681 } 681 }
682 682
683 bool AcceleratorController::CanHandleAccelerators() const { 683 bool AcceleratorController::CanHandleAccelerators() const {
684 return true; 684 return true;
685 } 685 }
686 686
687 void AcceleratorController::BindRequest(
688 mojom::AcceleratorControllerRequest request) {
689 bindings_.AddBinding(this, std::move(request));
690 }
691
692 void AcceleratorController::SetVolumeController(
693 mojom::VolumeControllerPtr controller) {
694 volume_controller_ = std::move(controller);
695 }
696
687 /////////////////////////////////////////////////////////////////////////////// 697 ///////////////////////////////////////////////////////////////////////////////
688 // AcceleratorController, private: 698 // AcceleratorController, private:
689 699
690 void AcceleratorController::Init() { 700 void AcceleratorController::Init() {
691 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) { 701 for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) {
692 actions_allowed_at_login_screen_.insert( 702 actions_allowed_at_login_screen_.insert(
693 kActionsAllowedAtLoginOrLockScreen[i]); 703 kActionsAllowedAtLoginOrLockScreen[i]);
694 actions_allowed_at_lock_screen_.insert( 704 actions_allowed_at_lock_screen_.insert(
695 kActionsAllowedAtLoginOrLockScreen[i]); 705 kActionsAllowedAtLoginOrLockScreen[i]);
696 } 706 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 case TOGGLE_HIGH_CONTRAST: 1098 case TOGGLE_HIGH_CONTRAST:
1089 HandleToggleHighContrast(); 1099 HandleToggleHighContrast();
1090 break; 1100 break;
1091 case TOGGLE_SPOKEN_FEEDBACK: 1101 case TOGGLE_SPOKEN_FEEDBACK:
1092 HandleToggleSpokenFeedback(); 1102 HandleToggleSpokenFeedback();
1093 break; 1103 break;
1094 case TOGGLE_WIFI: 1104 case TOGGLE_WIFI:
1095 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi(); 1105 WmShell::Get()->system_tray_notifier()->NotifyRequestToggleWifi();
1096 break; 1106 break;
1097 case VOLUME_DOWN: 1107 case VOLUME_DOWN:
1098 HandleVolumeDown(GetVolumeController(), accelerator); 1108 HandleVolumeDown(volume_controller_.get(), accelerator);
1099 break; 1109 break;
1100 case VOLUME_MUTE: 1110 case VOLUME_MUTE:
1101 HandleVolumeMute(GetVolumeController(), accelerator); 1111 HandleVolumeMute(volume_controller_.get(), accelerator);
1102 break; 1112 break;
1103 case VOLUME_UP: 1113 case VOLUME_UP:
1104 HandleVolumeUp(GetVolumeController(), accelerator); 1114 HandleVolumeUp(volume_controller_.get(), accelerator);
1105 break; 1115 break;
1106 #else 1116 #else
1107 case DUMMY_FOR_RESERVED: 1117 case DUMMY_FOR_RESERVED:
1108 NOTREACHED(); 1118 NOTREACHED();
1109 break; 1119 break;
1110 #endif 1120 #endif
1111 default: 1121 default:
1112 // Temporary until mash transition complete. Needed as some actions 1122 // Temporary until mash transition complete. Needed as some actions
1113 // don't yet work with mash. 1123 // don't yet work with mash.
1114 DCHECK(delegate_ && delegate_->HandlesAction(action)); 1124 DCHECK(delegate_ && delegate_->HandlesAction(action));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 } 1167 }
1158 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && 1168 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() &&
1159 actions_needing_window_.find(action) != actions_needing_window_.end()) { 1169 actions_needing_window_.find(action) != actions_needing_window_.end()) {
1160 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( 1170 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert(
1161 A11Y_ALERT_WINDOW_NEEDED); 1171 A11Y_ALERT_WINDOW_NEEDED);
1162 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 1172 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1163 } 1173 }
1164 return RESTRICTION_NONE; 1174 return RESTRICTION_NONE;
1165 } 1175 }
1166 1176
1167 mojom::VolumeController* AcceleratorController::GetVolumeController() {
1168 if (!volume_controller_ && WmShell::Get()->delegate()->GetShellConnector()) {
1169 WmShell::Get()->delegate()->GetShellConnector()->ConnectToInterface(
1170 content::mojom::kBrowserServiceName, &volume_controller_);
1171 volume_controller_.set_connection_error_handler(
1172 base::Bind(&AcceleratorController::OnVolumeControllerConnectionError,
1173 base::Unretained(this)));
1174 }
1175 return volume_controller_.get();
1176 }
1177
1178 void AcceleratorController::OnVolumeControllerConnectionError() {
1179 volume_controller_.reset();
1180 }
1181
1182 } // namespace ash 1177 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/accelerators/accelerator_controller.h ('k') | ash/common/mojo_interface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698