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

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

Issue 2118593002: mash: Migrate ShellDelegate ownership and access to WmShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 5 months 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
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/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "ash/accelerators/accelerator_commands.h" 12 #include "ash/accelerators/accelerator_commands.h"
13 #include "ash/accelerators/debug_commands.h" 13 #include "ash/accelerators/debug_commands.h"
14 #include "ash/common/accessibility_delegate.h" 14 #include "ash/common/accessibility_delegate.h"
15 #include "ash/common/accessibility_types.h" 15 #include "ash/common/accessibility_types.h"
16 #include "ash/common/ash_switches.h" 16 #include "ash/common/ash_switches.h"
17 #include "ash/common/focus_cycler.h" 17 #include "ash/common/focus_cycler.h"
18 #include "ash/common/media_delegate.h" 18 #include "ash/common/media_delegate.h"
19 #include "ash/common/session/session_state_delegate.h" 19 #include "ash/common/session/session_state_delegate.h"
20 #include "ash/common/shelf/shelf_model.h" 20 #include "ash/common/shelf/shelf_model.h"
21 #include "ash/common/shell_delegate.h"
21 #include "ash/common/shell_window_ids.h" 22 #include "ash/common/shell_window_ids.h"
22 #include "ash/common/system/system_notifier.h" 23 #include "ash/common/system/system_notifier.h"
23 #include "ash/common/system/tray/system_tray_delegate.h" 24 #include "ash/common/system/tray/system_tray_delegate.h"
24 #include "ash/common/system/tray/system_tray_notifier.h" 25 #include "ash/common/system/tray/system_tray_notifier.h"
25 #include "ash/common/system/volume_control_delegate.h" 26 #include "ash/common/system/volume_control_delegate.h"
26 #include "ash/common/system/web_notification/web_notification_tray.h" 27 #include "ash/common/system/web_notification/web_notification_tray.h"
27 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 28 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
28 #include "ash/common/wm/mru_window_tracker.h" 29 #include "ash/common/wm/mru_window_tracker.h"
29 #include "ash/common/wm/overview/window_selector_controller.h" 30 #include "ash/common/wm/overview/window_selector_controller.h"
30 #include "ash/common/wm/window_state.h" 31 #include "ash/common/wm/window_state.h"
31 #include "ash/common/wm/wm_event.h" 32 #include "ash/common/wm/wm_event.h"
32 #include "ash/common/wm_shell.h" 33 #include "ash/common/wm_shell.h"
33 #include "ash/debug.h" 34 #include "ash/debug.h"
34 #include "ash/display/window_tree_host_manager.h" 35 #include "ash/display/window_tree_host_manager.h"
35 #include "ash/gpu_support.h" 36 #include "ash/gpu_support.h"
36 #include "ash/ime_control_delegate.h" 37 #include "ash/ime_control_delegate.h"
37 #include "ash/magnifier/magnification_controller.h" 38 #include "ash/magnifier/magnification_controller.h"
38 #include "ash/magnifier/partial_magnification_controller.h" 39 #include "ash/magnifier/partial_magnification_controller.h"
39 #include "ash/multi_profile_uma.h" 40 #include "ash/multi_profile_uma.h"
40 #include "ash/new_window_delegate.h" 41 #include "ash/new_window_delegate.h"
41 #include "ash/root_window_controller.h" 42 #include "ash/root_window_controller.h"
42 #include "ash/rotator/screen_rotation_animator.h" 43 #include "ash/rotator/screen_rotation_animator.h"
43 #include "ash/rotator/window_rotation.h" 44 #include "ash/rotator/window_rotation.h"
44 #include "ash/screen_util.h" 45 #include "ash/screen_util.h"
45 #include "ash/screenshot_delegate.h" 46 #include "ash/screenshot_delegate.h"
46 #include "ash/shelf/shelf.h" 47 #include "ash/shelf/shelf.h"
47 #include "ash/shelf/shelf_delegate.h" 48 #include "ash/shelf/shelf_delegate.h"
48 #include "ash/shelf/shelf_widget.h" 49 #include "ash/shelf/shelf_widget.h"
49 #include "ash/shell.h" 50 #include "ash/shell.h"
50 #include "ash/shell_delegate.h"
51 #include "ash/system/brightness_control_delegate.h" 51 #include "ash/system/brightness_control_delegate.h"
52 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" 52 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
53 #include "ash/system/status_area_widget.h" 53 #include "ash/system/status_area_widget.h"
54 #include "ash/system/tray/system_tray.h" 54 #include "ash/system/tray/system_tray.h"
55 #include "ash/touch/touch_hud_debug.h" 55 #include "ash/touch/touch_hud_debug.h"
56 #include "ash/utility/screenshot_controller.h" 56 #include "ash/utility/screenshot_controller.h"
57 #include "ash/wm/power_button_controller.h" 57 #include "ash/wm/power_button_controller.h"
58 #include "ash/wm/window_cycle_controller.h" 58 #include "ash/wm/window_cycle_controller.h"
59 #include "ash/wm/window_state_aura.h" 59 #include "ash/wm/window_state_aura.h"
60 #include "ash/wm/window_util.h" 60 #include "ash/wm/window_util.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 class DeprecatedAcceleratorNotificationDelegate 99 class DeprecatedAcceleratorNotificationDelegate
100 : public message_center::NotificationDelegate { 100 : public message_center::NotificationDelegate {
101 public: 101 public:
102 DeprecatedAcceleratorNotificationDelegate() {} 102 DeprecatedAcceleratorNotificationDelegate() {}
103 103
104 // message_center::NotificationDelegate: 104 // message_center::NotificationDelegate:
105 bool HasClickedListener() override { return true; } 105 bool HasClickedListener() override { return true; }
106 106
107 void Click() override { 107 void Click() override {
108 if (!WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) 108 if (!WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked())
109 Shell::GetInstance()->delegate()->OpenKeyboardShortcutHelpPage(); 109 WmShell::Get()->delegate()->OpenKeyboardShortcutHelpPage();
110 } 110 }
111 111
112 private: 112 private:
113 // Private destructor since NotificationDelegate is ref-counted. 113 // Private destructor since NotificationDelegate is ref-counted.
114 ~DeprecatedAcceleratorNotificationDelegate() override {} 114 ~DeprecatedAcceleratorNotificationDelegate() override {}
115 115
116 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate); 116 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate);
117 }; 117 };
118 118
119 ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode, 119 ui::Accelerator CreateAccelerator(ui::KeyboardCode keycode,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void ShowDeprecatedAcceleratorNotification(const char* const notification_id, 164 void ShowDeprecatedAcceleratorNotification(const char* const notification_id,
165 int message_id, 165 int message_id,
166 int old_shortcut_id, 166 int old_shortcut_id,
167 int new_shortcut_id) { 167 int new_shortcut_id) {
168 const base::string16 message = 168 const base::string16 message =
169 GetNotificationText(message_id, old_shortcut_id, new_shortcut_id); 169 GetNotificationText(message_id, old_shortcut_id, new_shortcut_id);
170 std::unique_ptr<message_center::Notification> notification( 170 std::unique_ptr<message_center::Notification> notification(
171 new message_center::Notification( 171 new message_center::Notification(
172 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, 172 message_center::NOTIFICATION_TYPE_SIMPLE, notification_id,
173 base::string16(), message, 173 base::string16(), message,
174 Shell::GetInstance()->delegate()->GetDeprecatedAcceleratorImage(), 174 WmShell::Get()->delegate()->GetDeprecatedAcceleratorImage(),
175 base::string16(), GURL(), 175 base::string16(), GURL(),
176 message_center::NotifierId( 176 message_center::NotifierId(
177 message_center::NotifierId::SYSTEM_COMPONENT, 177 message_center::NotifierId::SYSTEM_COMPONENT,
178 system_notifier::kNotifierDeprecatedAccelerator), 178 system_notifier::kNotifierDeprecatedAccelerator),
179 message_center::RichNotificationData(), 179 message_center::RichNotificationData(),
180 new DeprecatedAcceleratorNotificationDelegate)); 180 new DeprecatedAcceleratorNotificationDelegate));
181 message_center::MessageCenter::Get()->AddNotification( 181 message_center::MessageCenter::Get()->AddNotification(
182 std::move(notification)); 182 std::move(notification));
183 } 183 }
184 184
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 void HandleMediaPlayPause() { 271 void HandleMediaPlayPause() {
272 WmShell::Get()->media_delegate()->HandleMediaPlayPause(); 272 WmShell::Get()->media_delegate()->HandleMediaPlayPause();
273 } 273 }
274 274
275 void HandleMediaPrevTrack() { 275 void HandleMediaPrevTrack() {
276 WmShell::Get()->media_delegate()->HandleMediaPrevTrack(); 276 WmShell::Get()->media_delegate()->HandleMediaPrevTrack();
277 } 277 }
278 278
279 bool CanHandleNewIncognitoWindow() { 279 bool CanHandleNewIncognitoWindow() {
280 return Shell::GetInstance()->delegate()->IsIncognitoAllowed(); 280 return WmShell::Get()->delegate()->IsIncognitoAllowed();
281 } 281 }
282 282
283 void HandleNewIncognitoWindow() { 283 void HandleNewIncognitoWindow() {
284 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window")); 284 base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window"));
285 Shell::GetInstance()->new_window_delegate()->NewWindow( 285 Shell::GetInstance()->new_window_delegate()->NewWindow(
286 true /* is_incognito */); 286 true /* is_incognito */);
287 } 287 }
288 288
289 void HandleNewTab(const ui::Accelerator& accelerator) { 289 void HandleNewTab(const ui::Accelerator& accelerator) {
290 if (accelerator.key_code() == ui::VKEY_T) 290 if (accelerator.key_code() == ui::VKEY_T)
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 Shell::GetInstance()->new_window_delegate()->OpenGetHelp(); 632 Shell::GetInstance()->new_window_delegate()->OpenGetHelp();
633 } 633 }
634 634
635 void HandleSwapPrimaryDisplay() { 635 void HandleSwapPrimaryDisplay() {
636 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); 636 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
637 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId( 637 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId(
638 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */); 638 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */);
639 } 639 }
640 640
641 bool CanHandleCycleUser() { 641 bool CanHandleCycleUser() {
642 Shell* shell = Shell::GetInstance(); 642 return WmShell::Get()->delegate()->IsMultiProfilesEnabled() &&
643 return shell->delegate()->IsMultiProfilesEnabled() &&
644 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1; 643 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1;
645 } 644 }
646 645
647 void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) { 646 void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) {
648 MultiProfileUMA::RecordSwitchActiveUser( 647 MultiProfileUMA::RecordSwitchActiveUser(
649 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); 648 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR);
650 switch (cycle_user) { 649 switch (cycle_user) {
651 case SessionStateDelegate::CYCLE_TO_NEXT_USER: 650 case SessionStateDelegate::CYCLE_TO_NEXT_USER:
652 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); 651 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User"));
653 break; 652 break;
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 return true; 1396 return true;
1398 } 1397 }
1399 1398
1400 AcceleratorController::AcceleratorProcessingRestriction 1399 AcceleratorController::AcceleratorProcessingRestriction
1401 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { 1400 AcceleratorController::GetAcceleratorProcessingRestriction(int action) {
1402 if (WmShell::Get()->IsPinned() && 1401 if (WmShell::Get()->IsPinned() &&
1403 actions_allowed_in_pinned_mode_.find(action) == 1402 actions_allowed_in_pinned_mode_.find(action) ==
1404 actions_allowed_in_pinned_mode_.end()) { 1403 actions_allowed_in_pinned_mode_.end()) {
1405 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 1404 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1406 } 1405 }
1407 Shell* shell = Shell::GetInstance();
1408 WmShell* wm_shell = WmShell::Get(); 1406 WmShell* wm_shell = WmShell::Get();
1409 if (!wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted() && 1407 if (!wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted() &&
1410 actions_allowed_at_login_screen_.find(action) == 1408 actions_allowed_at_login_screen_.find(action) ==
1411 actions_allowed_at_login_screen_.end()) { 1409 actions_allowed_at_login_screen_.end()) {
1412 return RESTRICTION_PREVENT_PROCESSING; 1410 return RESTRICTION_PREVENT_PROCESSING;
1413 } 1411 }
1414 if (wm_shell->GetSessionStateDelegate()->IsScreenLocked() && 1412 if (wm_shell->GetSessionStateDelegate()->IsScreenLocked() &&
1415 actions_allowed_at_lock_screen_.find(action) == 1413 actions_allowed_at_lock_screen_.find(action) ==
1416 actions_allowed_at_lock_screen_.end()) { 1414 actions_allowed_at_lock_screen_.end()) {
1417 return RESTRICTION_PREVENT_PROCESSING; 1415 return RESTRICTION_PREVENT_PROCESSING;
1418 } 1416 }
1419 if (shell->delegate()->IsRunningInForcedAppMode() && 1417 if (wm_shell->delegate()->IsRunningInForcedAppMode() &&
1420 actions_allowed_in_app_mode_.find(action) == 1418 actions_allowed_in_app_mode_.find(action) ==
1421 actions_allowed_in_app_mode_.end()) { 1419 actions_allowed_in_app_mode_.end()) {
1422 return RESTRICTION_PREVENT_PROCESSING; 1420 return RESTRICTION_PREVENT_PROCESSING;
1423 } 1421 }
1424 if (WmShell::Get()->IsSystemModalWindowOpen() && 1422 if (WmShell::Get()->IsSystemModalWindowOpen() &&
1425 actions_allowed_at_modal_window_.find(action) == 1423 actions_allowed_at_modal_window_.find(action) ==
1426 actions_allowed_at_modal_window_.end()) { 1424 actions_allowed_at_modal_window_.end()) {
1427 // Note we prevent the shortcut from propagating so it will not 1425 // Note we prevent the shortcut from propagating so it will not
1428 // be passed to the modal window. This is important for things like 1426 // be passed to the modal window. This is important for things like
1429 // Alt+Tab that would cause an undesired effect in the modal window by 1427 // Alt+Tab that would cause an undesired effect in the modal window by
(...skipping 10 matching lines...) Expand all
1440 } 1438 }
1441 1439
1442 void AcceleratorController::SetKeyboardBrightnessControlDelegate( 1440 void AcceleratorController::SetKeyboardBrightnessControlDelegate(
1443 std::unique_ptr<KeyboardBrightnessControlDelegate> 1441 std::unique_ptr<KeyboardBrightnessControlDelegate>
1444 keyboard_brightness_control_delegate) { 1442 keyboard_brightness_control_delegate) {
1445 keyboard_brightness_control_delegate_ = 1443 keyboard_brightness_control_delegate_ =
1446 std::move(keyboard_brightness_control_delegate); 1444 std::move(keyboard_brightness_control_delegate);
1447 } 1445 }
1448 1446
1449 } // namespace ash 1447 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698