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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/accelerators/accelerator_commands.h" | 9 #include "ash/common/accelerators/accelerator_commands.h" |
10 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
11 #include "ash/common/accelerators/debug_commands.h" | 11 #include "ash/common/accelerators/debug_commands.h" |
12 #include "ash/common/accessibility_delegate.h" | 12 #include "ash/common/accessibility_delegate.h" |
13 #include "ash/common/accessibility_types.h" | 13 #include "ash/common/accessibility_types.h" |
14 #include "ash/common/focus_cycler.h" | 14 #include "ash/common/focus_cycler.h" |
15 #include "ash/common/ime_control_delegate.h" | 15 #include "ash/common/ime_control_delegate.h" |
16 #include "ash/common/media_controller.h" | 16 #include "ash/common/media_controller.h" |
17 #include "ash/common/multi_profile_uma.h" | 17 #include "ash/common/multi_profile_uma.h" |
18 #include "ash/common/new_window_controller.h" | 18 #include "ash/common/new_window_controller.h" |
19 #include "ash/common/palette_delegate.h" | 19 #include "ash/common/palette_delegate.h" |
20 #include "ash/common/session/session_state_delegate.h" | 20 #include "ash/common/session/session_controller.h" |
21 #include "ash/common/shelf/shelf_widget.h" | 21 #include "ash/common/shelf/shelf_widget.h" |
22 #include "ash/common/shelf/wm_shelf.h" | 22 #include "ash/common/shelf/wm_shelf.h" |
23 #include "ash/common/shell_delegate.h" | 23 #include "ash/common/shell_delegate.h" |
24 #include "ash/common/system/brightness_control_delegate.h" | 24 #include "ash/common/system/brightness_control_delegate.h" |
25 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" | 25 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
26 #include "ash/common/system/chromeos/palette/palette_tray.h" | 26 #include "ash/common/system/chromeos/palette/palette_tray.h" |
27 #include "ash/common/system/chromeos/palette/palette_utils.h" | 27 #include "ash/common/system/chromeos/palette/palette_utils.h" |
28 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 28 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
29 #include "ash/common/system/status_area_widget.h" | 29 #include "ash/common/system/status_area_widget.h" |
30 #include "ash/common/system/system_notifier.h" | 30 #include "ash/common/system/system_notifier.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // help page when the notification is clicked. | 78 // help page when the notification is clicked. |
79 class DeprecatedAcceleratorNotificationDelegate | 79 class DeprecatedAcceleratorNotificationDelegate |
80 : public message_center::NotificationDelegate { | 80 : public message_center::NotificationDelegate { |
81 public: | 81 public: |
82 DeprecatedAcceleratorNotificationDelegate() {} | 82 DeprecatedAcceleratorNotificationDelegate() {} |
83 | 83 |
84 // message_center::NotificationDelegate: | 84 // message_center::NotificationDelegate: |
85 bool HasClickedListener() override { return true; } | 85 bool HasClickedListener() override { return true; } |
86 | 86 |
87 void Click() override { | 87 void Click() override { |
88 if (!WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) | 88 if (!WmShell::Get()->session_controller()->IsUserSessionBlocked()) |
89 Shell::Get()->shell_delegate()->OpenKeyboardShortcutHelpPage(); | 89 Shell::Get()->shell_delegate()->OpenKeyboardShortcutHelpPage(); |
90 } | 90 } |
91 | 91 |
92 private: | 92 private: |
93 // Private destructor since NotificationDelegate is ref-counted. | 93 // Private destructor since NotificationDelegate is ref-counted. |
94 ~DeprecatedAcceleratorNotificationDelegate() override {} | 94 ~DeprecatedAcceleratorNotificationDelegate() override {} |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate); | 96 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorNotificationDelegate); |
97 }; | 97 }; |
98 | 98 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); | 494 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); |
495 | 495 |
496 WmShell::Get()->new_window_controller()->OpenFileManager(); | 496 WmShell::Get()->new_window_controller()->OpenFileManager(); |
497 } | 497 } |
498 | 498 |
499 void HandleGetHelp() { | 499 void HandleGetHelp() { |
500 WmShell::Get()->new_window_controller()->OpenGetHelp(); | 500 WmShell::Get()->new_window_controller()->OpenGetHelp(); |
501 } | 501 } |
502 | 502 |
503 bool CanHandleLock() { | 503 bool CanHandleLock() { |
504 return WmShell::Get()->GetSessionStateDelegate()->CanLockScreen(); | 504 return WmShell::Get()->session_controller()->CanLockScreen(); |
505 } | 505 } |
506 | 506 |
507 void HandleLock() { | 507 void HandleLock() { |
508 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); | 508 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
509 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); | 509 WmShell::Get()->session_controller()->LockScreen(); |
510 } | 510 } |
511 | 511 |
512 void HandleShowStylusTools() { | 512 void HandleShowStylusTools() { |
513 base::RecordAction(UserMetricsAction("Accel_Show_Stylus_Tools")); | 513 base::RecordAction(UserMetricsAction("Accel_Show_Stylus_Tools")); |
514 | 514 |
515 RootWindowController* root_window_controller = | 515 RootWindowController* root_window_controller = |
516 Shell::GetWmRootWindowForNewWindows()->GetRootWindowController(); | 516 Shell::GetWmRootWindowForNewWindows()->GetRootWindowController(); |
517 StatusAreaWidget* status_area_widget = | 517 StatusAreaWidget* status_area_widget = |
518 root_window_controller->GetShelf()->GetStatusAreaWidget(); | 518 root_window_controller->GetShelf()->GetStatusAreaWidget(); |
519 // Tests (clusterfuzz) can trigger this before the status area is ready. | 519 // Tests (clusterfuzz) can trigger this before the status area is ready. |
520 if (status_area_widget) | 520 if (status_area_widget) |
521 status_area_widget->palette_tray()->ShowPalette(); | 521 status_area_widget->palette_tray()->ShowPalette(); |
522 } | 522 } |
523 | 523 |
524 bool CanHandleShowStylusTools() { | 524 bool CanHandleShowStylusTools() { |
525 return Shell::GetInstance()->palette_delegate() && | 525 return Shell::GetInstance()->palette_delegate() && |
526 Shell::GetInstance()->palette_delegate()->ShouldShowPalette(); | 526 Shell::GetInstance()->palette_delegate()->ShouldShowPalette(); |
527 } | 527 } |
528 | 528 |
529 void HandleSuspend() { | 529 void HandleSuspend() { |
530 base::RecordAction(UserMetricsAction("Accel_Suspend")); | 530 base::RecordAction(UserMetricsAction("Accel_Suspend")); |
531 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); | 531 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); |
532 } | 532 } |
533 | 533 |
534 bool CanHandleCycleUser() { | 534 bool CanHandleCycleUser() { |
535 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && | 535 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && |
536 WmShell::Get()->GetSessionStateDelegate()->NumberOfLoggedInUsers() > 1; | 536 WmShell::Get()->session_controller()->NumberOfLoggedInUsers() > 1; |
537 } | 537 } |
538 | 538 |
539 void HandleCycleUser(CycleUserDirection direction) { | 539 void HandleCycleUser(CycleUserDirection direction) { |
540 MultiProfileUMA::RecordSwitchActiveUser( | 540 MultiProfileUMA::RecordSwitchActiveUser( |
541 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); | 541 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); |
542 switch (direction) { | 542 switch (direction) { |
543 case CycleUserDirection::NEXT: | 543 case CycleUserDirection::NEXT: |
544 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); | 544 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); |
545 break; | 545 break; |
546 case CycleUserDirection::PREVIOUS: | 546 case CycleUserDirection::PREVIOUS: |
547 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); | 547 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); |
548 break; | 548 break; |
549 } | 549 } |
550 WmShell::Get()->GetSessionStateDelegate()->CycleActiveUser(direction); | 550 WmShell::Get()->session_controller()->CycleActiveUser(direction); |
551 } | 551 } |
552 | 552 |
553 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, | 553 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, |
554 const ui::Accelerator& previous_accelerator) { | 554 const ui::Accelerator& previous_accelerator) { |
555 chromeos::input_method::InputMethodManager* ime = | 555 chromeos::input_method::InputMethodManager* ime = |
556 chromeos::input_method::InputMethodManager::Get(); | 556 chromeos::input_method::InputMethodManager::Get(); |
557 | 557 |
558 // This shortcust is set to be trigger on release. Either the current | 558 // This shortcust is set to be trigger on release. Either the current |
559 // accelerator is a Search release or Alt release. | 559 // accelerator is a Search release or Alt release. |
560 if (accelerator.key_code() == ui::VKEY_LWIN && | 560 if (accelerator.key_code() == ui::VKEY_LWIN && |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 } | 1220 } |
1221 | 1221 |
1222 AcceleratorController::AcceleratorProcessingRestriction | 1222 AcceleratorController::AcceleratorProcessingRestriction |
1223 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { | 1223 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
1224 WmShell* wm_shell = WmShell::Get(); | 1224 WmShell* wm_shell = WmShell::Get(); |
1225 if (wm_shell->IsPinned() && | 1225 if (wm_shell->IsPinned() && |
1226 actions_allowed_in_pinned_mode_.find(action) == | 1226 actions_allowed_in_pinned_mode_.find(action) == |
1227 actions_allowed_in_pinned_mode_.end()) { | 1227 actions_allowed_in_pinned_mode_.end()) { |
1228 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1228 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
1229 } | 1229 } |
1230 // TODO(xiyuan): Replace with SessionController. http://crbug.com/648964 | 1230 if (!wm_shell->session_controller()->IsActiveUserSessionStarted() && |
1231 if (!wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted() && | |
1232 actions_allowed_at_login_screen_.find(action) == | 1231 actions_allowed_at_login_screen_.find(action) == |
1233 actions_allowed_at_login_screen_.end()) { | 1232 actions_allowed_at_login_screen_.end()) { |
1234 return RESTRICTION_PREVENT_PROCESSING; | 1233 return RESTRICTION_PREVENT_PROCESSING; |
1235 } | 1234 } |
1236 if (wm_shell->GetSessionStateDelegate()->IsScreenLocked() && | 1235 if (wm_shell->session_controller()->IsScreenLocked() && |
1237 actions_allowed_at_lock_screen_.find(action) == | 1236 actions_allowed_at_lock_screen_.find(action) == |
1238 actions_allowed_at_lock_screen_.end()) { | 1237 actions_allowed_at_lock_screen_.end()) { |
1239 return RESTRICTION_PREVENT_PROCESSING; | 1238 return RESTRICTION_PREVENT_PROCESSING; |
1240 } | 1239 } |
1241 if (Shell::Get()->shell_delegate()->IsRunningInForcedAppMode() && | 1240 if (Shell::Get()->shell_delegate()->IsRunningInForcedAppMode() && |
1242 actions_allowed_in_app_mode_.find(action) == | 1241 actions_allowed_in_app_mode_.find(action) == |
1243 actions_allowed_in_app_mode_.end()) { | 1242 actions_allowed_in_app_mode_.end()) { |
1244 return RESTRICTION_PREVENT_PROCESSING; | 1243 return RESTRICTION_PREVENT_PROCESSING; |
1245 } | 1244 } |
1246 if (WmShell::Get()->IsSystemModalWindowOpen() && | 1245 if (WmShell::Get()->IsSystemModalWindowOpen() && |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 data->uma_histogram_name, data->notification_message_id, | 1292 data->uma_histogram_name, data->notification_message_id, |
1294 data->old_shortcut_id, data->new_shortcut_id); | 1293 data->old_shortcut_id, data->new_shortcut_id); |
1295 | 1294 |
1296 if (!data->deprecated_enabled) | 1295 if (!data->deprecated_enabled) |
1297 return AcceleratorProcessingStatus::STOP; | 1296 return AcceleratorProcessingStatus::STOP; |
1298 | 1297 |
1299 return AcceleratorProcessingStatus::PROCEED; | 1298 return AcceleratorProcessingStatus::PROCEED; |
1300 } | 1299 } |
1301 | 1300 |
1302 } // namespace ash | 1301 } // namespace ash |
OLD | NEW |