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

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

Issue 2168733002: Splits debug_commands into aura and non-aura parts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar 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 "ash/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/accelerators/accelerator_controller_delegate.h" 8 #include "ash/accelerators/accelerator_controller_delegate.h"
9 #include "ash/accelerators/debug_commands.h" 9 #include "ash/accelerators/debug_commands.h"
10 #include "ash/common/accessibility_delegate.h" 10 #include "ash/common/accessibility_delegate.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 const ui::Accelerator& previous_accelerator = 559 const ui::Accelerator& previous_accelerator =
560 accelerator_history_->previous_accelerator(); 560 accelerator_history_->previous_accelerator();
561 561
562 // True should be returned if running |action| does something. Otherwise, 562 // True should be returned if running |action| does something. Otherwise,
563 // false should be returned to give the web contents a chance at handling the 563 // false should be returned to give the web contents a chance at handling the
564 // accelerator. 564 // accelerator.
565 switch (action) { 565 switch (action) {
566 case DEBUG_PRINT_LAYER_HIERARCHY: 566 case DEBUG_PRINT_LAYER_HIERARCHY:
567 case DEBUG_PRINT_VIEW_HIERARCHY: 567 case DEBUG_PRINT_VIEW_HIERARCHY:
568 case DEBUG_PRINT_WINDOW_HIERARCHY: 568 case DEBUG_PRINT_WINDOW_HIERARCHY:
569 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
570 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
571 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
572 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
573 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
574 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
575 return debug::DebugAcceleratorsEnabled(); 569 return debug::DebugAcceleratorsEnabled();
576 case NEXT_IME: 570 case NEXT_IME:
577 return CanHandleNextIme(ime_control_delegate_.get()); 571 return CanHandleNextIme(ime_control_delegate_.get());
578 case PREVIOUS_IME: 572 case PREVIOUS_IME:
579 return CanHandlePreviousIme(ime_control_delegate_.get()); 573 return CanHandlePreviousIme(ime_control_delegate_.get());
580 case SWITCH_IME: 574 case SWITCH_IME:
581 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); 575 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator);
582 case WINDOW_CYCLE_SNAP_DOCK_LEFT: 576 case WINDOW_CYCLE_SNAP_DOCK_LEFT:
583 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: 577 case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
584 return CanHandleWindowSnapOrDock(); 578 return CanHandleWindowSnapOrDock();
585 case WINDOW_POSITION_CENTER: 579 case WINDOW_POSITION_CENTER:
586 return CanHandlePositionCenter(); 580 return CanHandlePositionCenter();
587 #if defined(OS_CHROMEOS) 581 #if defined(OS_CHROMEOS)
588 case DEBUG_ADD_REMOVE_DISPLAY:
589 case DEBUG_SHOW_TOAST: 582 case DEBUG_SHOW_TOAST:
590 case DEBUG_TOGGLE_TOUCH_PAD: 583 case DEBUG_TOGGLE_TOUCH_PAD:
591 case DEBUG_TOGGLE_TOUCH_SCREEN: 584 case DEBUG_TOGGLE_TOUCH_SCREEN:
592 case DEBUG_TOGGLE_TOUCH_VIEW: 585 case DEBUG_TOGGLE_TOUCH_VIEW:
593 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
594 return debug::DebugAcceleratorsEnabled(); 586 return debug::DebugAcceleratorsEnabled();
595 case DISABLE_CAPS_LOCK: 587 case DISABLE_CAPS_LOCK:
596 return CanHandleDisableCapsLock(previous_accelerator); 588 return CanHandleDisableCapsLock(previous_accelerator);
597 case LOCK_SCREEN: 589 case LOCK_SCREEN:
598 return CanHandleLock(); 590 return CanHandleLock();
599 case SWITCH_TO_PREVIOUS_USER: 591 case SWITCH_TO_PREVIOUS_USER:
600 case SWITCH_TO_NEXT_USER: 592 case SWITCH_TO_NEXT_USER:
601 return CanHandleCycleUser(); 593 return CanHandleCycleUser();
602 case TOGGLE_CAPS_LOCK: 594 case TOGGLE_CAPS_LOCK:
603 return CanHandleToggleCapsLock(accelerator, previous_accelerator); 595 return CanHandleToggleCapsLock(accelerator, previous_accelerator);
(...skipping 25 matching lines...) Expand all
629 #else 621 #else
630 case DUMMY_FOR_RESERVED: 622 case DUMMY_FOR_RESERVED:
631 #endif 623 #endif
632 return true; 624 return true;
633 625
634 default: 626 default:
635 // Default switch is temporary until mash transition complete. Needed as 627 // Default switch is temporary until mash transition complete. Needed as
636 // some actions don't yet work with mash. 628 // some actions don't yet work with mash.
637 break; 629 break;
638 } 630 }
639 DCHECK(delegate_ && delegate_->HandlesAction(action)); 631 return delegate_ && delegate_->HandlesAction(action) &&
640 return delegate_->CanPerformAction(action, accelerator, previous_accelerator); 632 delegate_->CanPerformAction(action, accelerator, previous_accelerator);
641 } 633 }
642 634
643 void AcceleratorController::PerformAction(AcceleratorAction action, 635 void AcceleratorController::PerformAction(AcceleratorAction action,
644 const ui::Accelerator& accelerator) { 636 const ui::Accelerator& accelerator) {
645 AcceleratorProcessingRestriction restriction = 637 AcceleratorProcessingRestriction restriction =
646 GetAcceleratorProcessingRestriction(action); 638 GetAcceleratorProcessingRestriction(action);
647 if (restriction != RESTRICTION_NONE) 639 if (restriction != RESTRICTION_NONE)
648 return; 640 return;
649 641
650 // If your accelerator invokes more than one line of code, please either 642 // If your accelerator invokes more than one line of code, please either
651 // implement it in your module's controller code or pull it into a HandleFoo() 643 // implement it in your module's controller code or pull it into a HandleFoo()
652 // function above. 644 // function above.
653 switch (action) { 645 switch (action) {
654 case CYCLE_BACKWARD_MRU: 646 case CYCLE_BACKWARD_MRU:
655 HandleCycleBackwardMRU(accelerator); 647 HandleCycleBackwardMRU(accelerator);
656 break; 648 break;
657 case CYCLE_FORWARD_MRU: 649 case CYCLE_FORWARD_MRU:
658 HandleCycleForwardMRU(accelerator); 650 HandleCycleForwardMRU(accelerator);
659 break; 651 break;
660 case DEBUG_PRINT_LAYER_HIERARCHY: 652 case DEBUG_PRINT_LAYER_HIERARCHY:
661 case DEBUG_PRINT_VIEW_HIERARCHY: 653 case DEBUG_PRINT_VIEW_HIERARCHY:
662 case DEBUG_PRINT_WINDOW_HIERARCHY: 654 case DEBUG_PRINT_WINDOW_HIERARCHY:
663 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
664 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
665 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
666 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
667 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
668 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
669 debug::PerformDebugActionIfEnabled(action); 655 debug::PerformDebugActionIfEnabled(action);
670 break; 656 break;
671 case EXIT: 657 case EXIT:
672 // UMA metrics are recorded in the handler. 658 // UMA metrics are recorded in the handler.
673 exit_warning_handler_.HandleAccelerator(); 659 exit_warning_handler_.HandleAccelerator();
674 break; 660 break;
675 case FOCUS_NEXT_PANE: 661 case FOCUS_NEXT_PANE:
676 HandleRotatePaneFocus(FocusCycler::FORWARD); 662 HandleRotatePaneFocus(FocusCycler::FORWARD);
677 break; 663 break;
678 case FOCUS_PREVIOUS_PANE: 664 case FOCUS_PREVIOUS_PANE:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 delegate->HandleBrightnessDown(accelerator); 712 delegate->HandleBrightnessDown(accelerator);
727 break; 713 break;
728 } 714 }
729 case BRIGHTNESS_UP: { 715 case BRIGHTNESS_UP: {
730 BrightnessControlDelegate* delegate = 716 BrightnessControlDelegate* delegate =
731 WmShell::Get()->brightness_control_delegate(); 717 WmShell::Get()->brightness_control_delegate();
732 if (delegate) 718 if (delegate)
733 delegate->HandleBrightnessUp(accelerator); 719 delegate->HandleBrightnessUp(accelerator);
734 break; 720 break;
735 } 721 }
736 case DEBUG_ADD_REMOVE_DISPLAY:
737 case DEBUG_SHOW_TOAST: 722 case DEBUG_SHOW_TOAST:
738 case DEBUG_TOGGLE_TOUCH_PAD: 723 case DEBUG_TOGGLE_TOUCH_PAD:
739 case DEBUG_TOGGLE_TOUCH_SCREEN: 724 case DEBUG_TOGGLE_TOUCH_SCREEN:
740 case DEBUG_TOGGLE_TOUCH_VIEW: 725 case DEBUG_TOGGLE_TOUCH_VIEW:
741 case DEBUG_TOGGLE_UNIFIED_DESKTOP:
742 debug::PerformDebugActionIfEnabled(action); 726 debug::PerformDebugActionIfEnabled(action);
743 break; 727 break;
744 case DISABLE_CAPS_LOCK: 728 case DISABLE_CAPS_LOCK:
745 HandleDisableCapsLock(); 729 HandleDisableCapsLock();
746 break; 730 break;
747 case KEYBOARD_BRIGHTNESS_DOWN: { 731 case KEYBOARD_BRIGHTNESS_DOWN: {
748 KeyboardBrightnessControlDelegate* delegate = 732 KeyboardBrightnessControlDelegate* delegate =
749 WmShell::Get()->keyboard_brightness_control_delegate(); 733 WmShell::Get()->keyboard_brightness_control_delegate();
750 if (delegate) 734 if (delegate)
751 delegate->HandleKeyboardBrightnessDown(accelerator); 735 delegate->HandleKeyboardBrightnessDown(accelerator);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && 827 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() &&
844 actions_needing_window_.find(action) != actions_needing_window_.end()) { 828 actions_needing_window_.find(action) != actions_needing_window_.end()) {
845 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( 829 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert(
846 A11Y_ALERT_WINDOW_NEEDED); 830 A11Y_ALERT_WINDOW_NEEDED);
847 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 831 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
848 } 832 }
849 return RESTRICTION_NONE; 833 return RESTRICTION_NONE;
850 } 834 }
851 835
852 } // namespace ash 836 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698