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

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

Issue 78763003: Record user actions for Ash accelerators. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 | « no previous file | no next file » | 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/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 <iostream> 9 #include <iostream>
10 #include <string> 10 #include <string>
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 // You *MUST* return true when some action is performed. Otherwise, this 546 // You *MUST* return true when some action is performed. Otherwise, this
547 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent 547 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent
548 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. 548 // and BrowserView::HandleKeyboardEvent, for a single accelerator press.
549 // 549 //
550 // If your accelerator invokes more than one line of code, please either 550 // If your accelerator invokes more than one line of code, please either
551 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE 551 // implement it in your module's controller code (like TOGGLE_MIRROR_MODE
552 // below) or pull it into a HandleFoo() function above. 552 // below) or pull it into a HandleFoo() function above.
553 switch (action) { 553 switch (action) {
554 case ACCESSIBLE_FOCUS_NEXT: 554 case ACCESSIBLE_FOCUS_NEXT:
555 content::RecordAction(
556 content::UserMetricsAction("Accel_Accessible_Focus_Next"));
555 return HandleAccessibleFocusCycle(false); 557 return HandleAccessibleFocusCycle(false);
556 case ACCESSIBLE_FOCUS_PREVIOUS: 558 case ACCESSIBLE_FOCUS_PREVIOUS:
559 content::RecordAction(
560 content::UserMetricsAction("Accel_Accessible_Focus_Previous"));
557 return HandleAccessibleFocusCycle(true); 561 return HandleAccessibleFocusCycle(true);
558 case CYCLE_BACKWARD_MRU: 562 case CYCLE_BACKWARD_MRU:
559 HandleCycleBackwardMRU(accelerator); 563 HandleCycleBackwardMRU(accelerator);
SteveT 2013/11/20 18:43:17 Some of these Handle...() methods do the logging i
James Cook 2013/11/20 19:14:28 Given that this switch statement is way way way to
560 return true; 564 return true;
561 case CYCLE_FORWARD_MRU: 565 case CYCLE_FORWARD_MRU:
562 HandleCycleForwardMRU(accelerator); 566 HandleCycleForwardMRU(accelerator);
563 return true; 567 return true;
564 case CYCLE_LINEAR: 568 case CYCLE_LINEAR:
565 HandleCycleLinear(accelerator); 569 HandleCycleLinear(accelerator);
566 return true; 570 return true;
567 #if defined(OS_CHROMEOS) 571 #if defined(OS_CHROMEOS)
568 case ADD_REMOVE_DISPLAY: 572 case ADD_REMOVE_DISPLAY:
573 content::RecordAction(
574 content::UserMetricsAction("Accel_Add_Remove_Display"));
569 Shell::GetInstance()->display_manager()->AddRemoveDisplay(); 575 Shell::GetInstance()->display_manager()->AddRemoveDisplay();
570 return true; 576 return true;
571 case TOGGLE_MIRROR_MODE: 577 case TOGGLE_MIRROR_MODE:
578 content::RecordAction(
579 content::UserMetricsAction("Accel_Toggle_Mirror_Mode"));
572 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); 580 Shell::GetInstance()->display_controller()->ToggleMirrorMode();
573 return true; 581 return true;
574 case LOCK_SCREEN: 582 case LOCK_SCREEN:
575 if (key_code == ui::VKEY_L) 583 if (key_code == ui::VKEY_L)
576 content::RecordAction(content::UserMetricsAction("Accel_LockScreen_L")); 584 content::RecordAction(content::UserMetricsAction("Accel_LockScreen_L"));
577 return HandleLock(); 585 return HandleLock();
578 case OPEN_FILE_MANAGER: 586 case OPEN_FILE_MANAGER:
587 content::RecordAction(
588 content::UserMetricsAction("Accel_Handle_File_Manager"));
579 return HandleFileManager(); 589 return HandleFileManager();
580 case OPEN_CROSH: 590 case OPEN_CROSH:
591 content::RecordAction(
592 content::UserMetricsAction("Accel_Open_Crosh"));
581 return HandleCrosh(); 593 return HandleCrosh();
582 case SILENCE_SPOKEN_FEEDBACK: 594 case SILENCE_SPOKEN_FEEDBACK:
595 content::RecordAction(
596 content::UserMetricsAction("Accel_Silence_Spoken_Feedback"));
583 HandleSilenceSpokenFeedback(); 597 HandleSilenceSpokenFeedback();
584 break; 598 break;
585 case SWAP_PRIMARY_DISPLAY: 599 case SWAP_PRIMARY_DISPLAY:
600 content::RecordAction(
601 content::UserMetricsAction("Accel_Swap_Primary_Display"));
586 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); 602 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
587 return true; 603 return true;
588 case SWITCH_TO_NEXT_USER: 604 case SWITCH_TO_NEXT_USER:
605 content::RecordAction(
606 content::UserMetricsAction("Accel_Switch_To_Next_User"));
589 return SwitchToNextUser(); 607 return SwitchToNextUser();
590 case TOGGLE_SPOKEN_FEEDBACK: 608 case TOGGLE_SPOKEN_FEEDBACK:
609 content::RecordAction(
610 content::UserMetricsAction("Accel_Toggle_Spoken_Feedback"));
591 return HandleToggleSpokenFeedback(); 611 return HandleToggleSpokenFeedback();
592 case TOGGLE_WIFI: 612 case TOGGLE_WIFI:
613 content::RecordAction(content::UserMetricsAction("Accel_Toggle_Wifi"));
SteveT 2013/11/20 18:43:17 Do you know anything about this hotkey? (Ctrl+Alt+
James Cook 2013/11/20 19:14:28 Ctrl+Alt+W should only exist in a Debug build. Sho
593 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi(); 614 Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi();
594 return true; 615 return true;
595 case TOUCH_HUD_CLEAR: { 616 case TOUCH_HUD_CLEAR: {
617 content::RecordAction(
618 content::UserMetricsAction("Accel_Touch_Hud_Clear"));
596 internal::RootWindowController* controller = 619 internal::RootWindowController* controller =
597 internal::RootWindowController::ForTargetRootWindow(); 620 internal::RootWindowController::ForTargetRootWindow();
598 if (controller->touch_hud_debug()) { 621 if (controller->touch_hud_debug()) {
599 controller->touch_hud_debug()->Clear(); 622 controller->touch_hud_debug()->Clear();
600 return true; 623 return true;
601 } 624 }
602 return false; 625 return false;
603 } 626 }
604 case TOUCH_HUD_MODE_CHANGE: { 627 case TOUCH_HUD_MODE_CHANGE: {
628 content::RecordAction(
629 content::UserMetricsAction("Accel_Touch_Hud_Mode_Change"));
605 internal::RootWindowController* controller = 630 internal::RootWindowController* controller =
606 internal::RootWindowController::ForTargetRootWindow(); 631 internal::RootWindowController::ForTargetRootWindow();
607 if (controller->touch_hud_debug()) { 632 if (controller->touch_hud_debug()) {
608 controller->touch_hud_debug()->ChangeToNextMode(); 633 controller->touch_hud_debug()->ChangeToNextMode();
609 return true; 634 return true;
610 } 635 }
611 return false; 636 return false;
612 } 637 }
613 case TOUCH_HUD_PROJECTION_TOGGLE: { 638 case TOUCH_HUD_PROJECTION_TOGGLE: {
639 content::RecordAction(
640 content::UserMetricsAction("Accel_Touch_Hud_Clear"));
614 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled(); 641 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled();
615 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); 642 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled);
616 return true; 643 return true;
617 } 644 }
618 case DISABLE_GPU_WATCHDOG: 645 case DISABLE_GPU_WATCHDOG:
646 content::RecordAction(
647 content::UserMetricsAction("Accel_Disable_Gpu_Watchdog"));
619 content::GpuDataManager::GetInstance()->DisableGpuWatchdog(); 648 content::GpuDataManager::GetInstance()->DisableGpuWatchdog();
620 return true; 649 return true;
621 #endif 650 #endif
622 case OPEN_FEEDBACK_PAGE: 651 case OPEN_FEEDBACK_PAGE:
652 content::RecordAction(
653 content::UserMetricsAction("Accel_Open_Feedback_Page"));
623 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); 654 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
624 return true; 655 return true;
625 case EXIT: 656 case EXIT:
626 // UMA metrics are recorded in the handler. 657 // UMA metrics are recorded in the handler.
627 exit_warning_handler_.HandleAccelerator(); 658 exit_warning_handler_.HandleAccelerator();
628 return true; 659 return true;
629 case NEW_INCOGNITO_WINDOW: { 660 case NEW_INCOGNITO_WINDOW: {
661 content::RecordAction(
662 content::UserMetricsAction("Accel_New_Incognito_Window"));
630 bool incognito_allowed = 663 bool incognito_allowed =
631 Shell::GetInstance()->delegate()->IsIncognitoAllowed(); 664 Shell::GetInstance()->delegate()->IsIncognitoAllowed();
632 if (incognito_allowed) 665 if (incognito_allowed)
633 Shell::GetInstance()->new_window_delegate()->NewWindow( 666 Shell::GetInstance()->new_window_delegate()->NewWindow(
634 true /* is_incognito */); 667 true /* is_incognito */);
635 return incognito_allowed; 668 return incognito_allowed;
636 } 669 }
637 case NEW_TAB: 670 case NEW_TAB:
638 if (key_code == ui::VKEY_T) 671 if (key_code == ui::VKEY_T)
SteveT 2013/11/20 18:43:17 I am trying to figure out why this does an additio
James Cook 2013/11/20 19:14:28 I have no idea why this checks for 'T'. Maybe ther
639 content::RecordAction(content::UserMetricsAction("Accel_NewTab_T")); 672 content::RecordAction(content::UserMetricsAction("Accel_NewTab_T"));
640 Shell::GetInstance()->new_window_delegate()->NewTab(); 673 Shell::GetInstance()->new_window_delegate()->NewTab();
641 return true; 674 return true;
642 case NEW_WINDOW: 675 case NEW_WINDOW:
676 content::RecordAction(content::UserMetricsAction("Accel_New_Window"));
SteveT 2013/11/20 18:43:17 To follow up with the above comment, should I be c
James Cook 2013/11/20 19:14:28 I don't think so.
643 Shell::GetInstance()->new_window_delegate()->NewWindow( 677 Shell::GetInstance()->new_window_delegate()->NewWindow(
644 false /* is_incognito */); 678 false /* is_incognito */);
645 return true; 679 return true;
646 case RESTORE_TAB: 680 case RESTORE_TAB:
681 content::RecordAction(content::UserMetricsAction("Accel_Restore_Tab"));
647 Shell::GetInstance()->new_window_delegate()->RestoreTab(); 682 Shell::GetInstance()->new_window_delegate()->RestoreTab();
648 return true; 683 return true;
649 case TAKE_SCREENSHOT: 684 case TAKE_SCREENSHOT:
685 content::RecordAction(
686 content::UserMetricsAction("Accel_Take_Screenshot"));
650 if (screenshot_delegate_.get() && 687 if (screenshot_delegate_.get() &&
651 screenshot_delegate_->CanTakeScreenshot()) { 688 screenshot_delegate_->CanTakeScreenshot()) {
652 screenshot_delegate_->HandleTakeScreenshotForAllRootWindows(); 689 screenshot_delegate_->HandleTakeScreenshotForAllRootWindows();
653 } 690 }
654 // Return true to prevent propagation of the key event. 691 // Return true to prevent propagation of the key event.
655 return true; 692 return true;
656 case TAKE_PARTIAL_SCREENSHOT: 693 case TAKE_PARTIAL_SCREENSHOT:
694 content::RecordAction(
695 content::UserMetricsAction("Accel_Take_Partial_Screenshot"));
657 if (screenshot_delegate_) { 696 if (screenshot_delegate_) {
658 ash::PartialScreenshotView::StartPartialScreenshot( 697 ash::PartialScreenshotView::StartPartialScreenshot(
659 screenshot_delegate_.get()); 698 screenshot_delegate_.get());
660 } 699 }
661 // Return true to prevent propagation of the key event because 700 // Return true to prevent propagation of the key event because
662 // this key combination is reserved for partial screenshot. 701 // this key combination is reserved for partial screenshot.
663 return true; 702 return true;
664 case TOGGLE_APP_LIST: 703 case TOGGLE_APP_LIST:
665 // If something else was pressed between the Search key (LWIN) 704 // If something else was pressed between the Search key (LWIN)
666 // being pressed and released, then ignore the release of the 705 // being pressed and released, then ignore the release of the
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 keyboard_brightness_control_delegate) { 1035 keyboard_brightness_control_delegate) {
997 keyboard_brightness_control_delegate_ = 1036 keyboard_brightness_control_delegate_ =
998 keyboard_brightness_control_delegate.Pass(); 1037 keyboard_brightness_control_delegate.Pass();
999 } 1038 }
1000 1039
1001 bool AcceleratorController::CanHandleAccelerators() const { 1040 bool AcceleratorController::CanHandleAccelerators() const {
1002 return true; 1041 return true;
1003 } 1042 }
1004 1043
1005 } // namespace ash 1044 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698