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" |
(...skipping 67 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()->session_controller()->IsUserSessionBlocked()) | 88 if (!Shell::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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); | 492 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); |
493 | 493 |
494 Shell::Get()->new_window_controller()->OpenFileManager(); | 494 Shell::Get()->new_window_controller()->OpenFileManager(); |
495 } | 495 } |
496 | 496 |
497 void HandleGetHelp() { | 497 void HandleGetHelp() { |
498 Shell::Get()->new_window_controller()->OpenGetHelp(); | 498 Shell::Get()->new_window_controller()->OpenGetHelp(); |
499 } | 499 } |
500 | 500 |
501 bool CanHandleLock() { | 501 bool CanHandleLock() { |
502 return WmShell::Get()->session_controller()->CanLockScreen(); | 502 return Shell::Get()->session_controller()->CanLockScreen(); |
503 } | 503 } |
504 | 504 |
505 void HandleLock() { | 505 void HandleLock() { |
506 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); | 506 base::RecordAction(UserMetricsAction("Accel_LockScreen_L")); |
507 WmShell::Get()->session_controller()->LockScreen(); | 507 Shell::Get()->session_controller()->LockScreen(); |
508 } | 508 } |
509 | 509 |
510 void HandleShowStylusTools() { | 510 void HandleShowStylusTools() { |
511 base::RecordAction(UserMetricsAction("Accel_Show_Stylus_Tools")); | 511 base::RecordAction(UserMetricsAction("Accel_Show_Stylus_Tools")); |
512 | 512 |
513 RootWindowController* root_window_controller = | 513 RootWindowController* root_window_controller = |
514 Shell::GetWmRootWindowForNewWindows()->GetRootWindowController(); | 514 Shell::GetWmRootWindowForNewWindows()->GetRootWindowController(); |
515 StatusAreaWidget* status_area_widget = | 515 StatusAreaWidget* status_area_widget = |
516 root_window_controller->GetShelf()->GetStatusAreaWidget(); | 516 root_window_controller->GetShelf()->GetStatusAreaWidget(); |
517 // Tests (clusterfuzz) can trigger this before the status area is ready. | 517 // Tests (clusterfuzz) can trigger this before the status area is ready. |
518 if (status_area_widget) | 518 if (status_area_widget) |
519 status_area_widget->palette_tray()->ShowPalette(); | 519 status_area_widget->palette_tray()->ShowPalette(); |
520 } | 520 } |
521 | 521 |
522 bool CanHandleShowStylusTools() { | 522 bool CanHandleShowStylusTools() { |
523 return Shell::GetInstance()->palette_delegate() && | 523 return Shell::GetInstance()->palette_delegate() && |
524 Shell::GetInstance()->palette_delegate()->ShouldShowPalette(); | 524 Shell::GetInstance()->palette_delegate()->ShouldShowPalette(); |
525 } | 525 } |
526 | 526 |
527 void HandleSuspend() { | 527 void HandleSuspend() { |
528 base::RecordAction(UserMetricsAction("Accel_Suspend")); | 528 base::RecordAction(UserMetricsAction("Accel_Suspend")); |
529 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); | 529 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestSuspend(); |
530 } | 530 } |
531 | 531 |
532 bool CanHandleCycleUser() { | 532 bool CanHandleCycleUser() { |
533 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && | 533 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && |
534 WmShell::Get()->session_controller()->NumberOfLoggedInUsers() > 1; | 534 Shell::Get()->session_controller()->NumberOfLoggedInUsers() > 1; |
535 } | 535 } |
536 | 536 |
537 void HandleCycleUser(CycleUserDirection direction) { | 537 void HandleCycleUser(CycleUserDirection direction) { |
538 MultiProfileUMA::RecordSwitchActiveUser( | 538 MultiProfileUMA::RecordSwitchActiveUser( |
539 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); | 539 MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR); |
540 switch (direction) { | 540 switch (direction) { |
541 case CycleUserDirection::NEXT: | 541 case CycleUserDirection::NEXT: |
542 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); | 542 base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User")); |
543 break; | 543 break; |
544 case CycleUserDirection::PREVIOUS: | 544 case CycleUserDirection::PREVIOUS: |
545 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); | 545 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); |
546 break; | 546 break; |
547 } | 547 } |
548 WmShell::Get()->session_controller()->CycleActiveUser(direction); | 548 Shell::Get()->session_controller()->CycleActiveUser(direction); |
549 } | 549 } |
550 | 550 |
551 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, | 551 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, |
552 const ui::Accelerator& previous_accelerator) { | 552 const ui::Accelerator& previous_accelerator) { |
553 chromeos::input_method::InputMethodManager* ime = | 553 chromeos::input_method::InputMethodManager* ime = |
554 chromeos::input_method::InputMethodManager::Get(); | 554 chromeos::input_method::InputMethodManager::Get(); |
555 | 555 |
556 // This shortcust is set to be trigger on release. Either the current | 556 // This shortcust is set to be trigger on release. Either the current |
557 // accelerator is a Search release or Alt release. | 557 // accelerator is a Search release or Alt release. |
558 if (accelerator.key_code() == ui::VKEY_LWIN && | 558 if (accelerator.key_code() == ui::VKEY_LWIN && |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 } | 1218 } |
1219 | 1219 |
1220 AcceleratorController::AcceleratorProcessingRestriction | 1220 AcceleratorController::AcceleratorProcessingRestriction |
1221 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { | 1221 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
1222 WmShell* wm_shell = WmShell::Get(); | 1222 WmShell* wm_shell = WmShell::Get(); |
1223 if (wm_shell->IsPinned() && | 1223 if (wm_shell->IsPinned() && |
1224 actions_allowed_in_pinned_mode_.find(action) == | 1224 actions_allowed_in_pinned_mode_.find(action) == |
1225 actions_allowed_in_pinned_mode_.end()) { | 1225 actions_allowed_in_pinned_mode_.end()) { |
1226 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1226 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
1227 } | 1227 } |
1228 if (!wm_shell->session_controller()->IsActiveUserSessionStarted() && | 1228 if (!Shell::Get()->session_controller()->IsActiveUserSessionStarted() && |
1229 actions_allowed_at_login_screen_.find(action) == | 1229 actions_allowed_at_login_screen_.find(action) == |
1230 actions_allowed_at_login_screen_.end()) { | 1230 actions_allowed_at_login_screen_.end()) { |
1231 return RESTRICTION_PREVENT_PROCESSING; | 1231 return RESTRICTION_PREVENT_PROCESSING; |
1232 } | 1232 } |
1233 if (wm_shell->session_controller()->IsScreenLocked() && | 1233 if (Shell::Get()->session_controller()->IsScreenLocked() && |
1234 actions_allowed_at_lock_screen_.find(action) == | 1234 actions_allowed_at_lock_screen_.find(action) == |
1235 actions_allowed_at_lock_screen_.end()) { | 1235 actions_allowed_at_lock_screen_.end()) { |
1236 return RESTRICTION_PREVENT_PROCESSING; | 1236 return RESTRICTION_PREVENT_PROCESSING; |
1237 } | 1237 } |
1238 if (Shell::Get()->shell_delegate()->IsRunningInForcedAppMode() && | 1238 if (Shell::Get()->shell_delegate()->IsRunningInForcedAppMode() && |
1239 actions_allowed_in_app_mode_.find(action) == | 1239 actions_allowed_in_app_mode_.find(action) == |
1240 actions_allowed_in_app_mode_.end()) { | 1240 actions_allowed_in_app_mode_.end()) { |
1241 return RESTRICTION_PREVENT_PROCESSING; | 1241 return RESTRICTION_PREVENT_PROCESSING; |
1242 } | 1242 } |
1243 if (wm_shell->IsSystemModalWindowOpen() && | 1243 if (wm_shell->IsSystemModalWindowOpen() && |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 data->uma_histogram_name, data->notification_message_id, | 1290 data->uma_histogram_name, data->notification_message_id, |
1291 data->old_shortcut_id, data->new_shortcut_id); | 1291 data->old_shortcut_id, data->new_shortcut_id); |
1292 | 1292 |
1293 if (!data->deprecated_enabled) | 1293 if (!data->deprecated_enabled) |
1294 return AcceleratorProcessingStatus::STOP; | 1294 return AcceleratorProcessingStatus::STOP; |
1295 | 1295 |
1296 return AcceleratorProcessingStatus::PROCEED; | 1296 return AcceleratorProcessingStatus::PROCEED; |
1297 } | 1297 } |
1298 | 1298 |
1299 } // namespace ash | 1299 } // namespace ash |
OLD | NEW |