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

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

Issue 14674002: Support Shift+Search+Arrows to navigate and Control to silence speech everywhere (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "ui/base/accelerators/accelerator.h" 54 #include "ui/base/accelerators/accelerator.h"
55 #include "ui/base/accelerators/accelerator_manager.h" 55 #include "ui/base/accelerators/accelerator_manager.h"
56 #include "ui/base/events/event.h" 56 #include "ui/base/events/event.h"
57 #include "ui/base/keycodes/keyboard_codes.h" 57 #include "ui/base/keycodes/keyboard_codes.h"
58 #include "ui/compositor/debug_utils.h" 58 #include "ui/compositor/debug_utils.h"
59 #include "ui/compositor/layer.h" 59 #include "ui/compositor/layer.h"
60 #include "ui/compositor/layer_animation_sequence.h" 60 #include "ui/compositor/layer_animation_sequence.h"
61 #include "ui/compositor/layer_animator.h" 61 #include "ui/compositor/layer_animator.h"
62 #include "ui/gfx/screen.h" 62 #include "ui/gfx/screen.h"
63 #include "ui/oak/oak.h" 63 #include "ui/oak/oak.h"
64 #include "ui/views/controls/webview/webview.h"
64 #include "ui/views/debug_utils.h" 65 #include "ui/views/debug_utils.h"
65 #include "ui/views/widget/widget.h" 66 #include "ui/views/widget/widget.h"
66 67
67 #if defined(OS_CHROMEOS) 68 #if defined(OS_CHROMEOS)
68 #include "ash/system/chromeos/keyboard_brightness_controller.h" 69 #include "ash/system/chromeos/keyboard_brightness_controller.h"
69 #include "base/chromeos/chromeos_version.h" 70 #include "base/chromeos/chromeos_version.h"
70 #endif // defined(OS_CHROMEOS) 71 #endif // defined(OS_CHROMEOS)
71 72
72 namespace ash { 73 namespace ash {
73 namespace { 74 namespace {
(...skipping 15 matching lines...) Expand all
89 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); 90 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down);
90 // Always report we handled the key, even if the window didn't change. 91 // Always report we handled the key, even if the window didn't change.
91 return true; 92 return true;
92 } 93 }
93 94
94 void HandleCycleWindowLinear(CycleDirection direction) { 95 void HandleCycleWindowLinear(CycleDirection direction) {
95 Shell::GetInstance()-> 96 Shell::GetInstance()->
96 window_cycle_controller()->HandleLinearCycleWindow(); 97 window_cycle_controller()->HandleLinearCycleWindow();
97 } 98 }
98 99
100 bool HandleAccessibleFocusCycle(bool reverse) {
101 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled())
102 return false;
103 aura::Window* active_window = ash::wm::GetActiveWindow();
104 if (!active_window)
105 return false;
106 views::Widget* widget =
107 views::Widget::GetWidgetForNativeWindow(active_window);
108 if (!widget)
109 return false;
110 views::FocusManager* focus_manager = widget->GetFocusManager();
111 if (!focus_manager)
112 return false;
113 views::View* view = focus_manager->GetFocusedView();
114 if (view->GetClassName() == views::WebView::kViewClassName)
115 return false;
116
117 focus_manager->AdvanceFocus(reverse);
118 return true;
119 }
120
121 void HandleSilenceSpokenFeedback() {
122 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled())
123 return;
124
125 Shell::GetInstance()->delegate()->SilenceSpokenFeedback();
126 }
127
99 #if defined(OS_CHROMEOS) 128 #if defined(OS_CHROMEOS)
100 bool HandleLock() { 129 bool HandleLock() {
101 Shell::GetInstance()->session_state_delegate()->LockScreen(); 130 Shell::GetInstance()->session_state_delegate()->LockScreen();
102 return true; 131 return true;
103 } 132 }
104 133
105 bool HandleFileManager(bool as_dialog) { 134 bool HandleFileManager(bool as_dialog) {
106 Shell::GetInstance()->delegate()->OpenFileManager(as_dialog); 135 Shell::GetInstance()->delegate()->OpenFileManager(as_dialog);
107 return true; 136 return true;
108 } 137 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK. 496 // Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK.
468 const ui::EventType previous_event_type = 497 const ui::EventType previous_event_type =
469 context_.previous_accelerator().type(); 498 context_.previous_accelerator().type();
470 const ui::KeyboardCode previous_key_code = 499 const ui::KeyboardCode previous_key_code =
471 context_.previous_accelerator().key_code(); 500 context_.previous_accelerator().key_code();
472 501
473 // You *MUST* return true when some action is performed. Otherwise, this 502 // You *MUST* return true when some action is performed. Otherwise, this
474 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent 503 // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent
475 // and BrowserView::HandleKeyboardEvent, for a single accelerator press. 504 // and BrowserView::HandleKeyboardEvent, for a single accelerator press.
476 switch (action) { 505 switch (action) {
506 case ACCESSIBLE_NEXT:
507 return HandleAccessibleFocusCycle(false);
508 case ACCESSIBLE_PREVIOUS:
509 return HandleAccessibleFocusCycle(true);
477 case CYCLE_BACKWARD_MRU: 510 case CYCLE_BACKWARD_MRU:
478 if (key_code == ui::VKEY_TAB) 511 if (key_code == ui::VKEY_TAB)
479 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB); 512 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB);
480 return HandleCycleWindowMRU(WindowCycleController::BACKWARD, 513 return HandleCycleWindowMRU(WindowCycleController::BACKWARD,
481 accelerator.IsAltDown()); 514 accelerator.IsAltDown());
482 case CYCLE_FORWARD_MRU: 515 case CYCLE_FORWARD_MRU:
483 if (key_code == ui::VKEY_TAB) 516 if (key_code == ui::VKEY_TAB)
484 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_TAB); 517 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_TAB);
485 return HandleCycleWindowMRU(WindowCycleController::FORWARD, 518 return HandleCycleWindowMRU(WindowCycleController::FORWARD,
486 accelerator.IsAltDown()); 519 accelerator.IsAltDown());
(...skipping 14 matching lines...) Expand all
501 case LOCK_SCREEN: 534 case LOCK_SCREEN:
502 if (key_code == ui::VKEY_L) 535 if (key_code == ui::VKEY_L)
503 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_LOCK_SCREEN_L); 536 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_LOCK_SCREEN_L);
504 return HandleLock(); 537 return HandleLock();
505 case OPEN_FILE_DIALOG: 538 case OPEN_FILE_DIALOG:
506 return HandleFileManager(true /* as_dialog */); 539 return HandleFileManager(true /* as_dialog */);
507 case OPEN_FILE_MANAGER: 540 case OPEN_FILE_MANAGER:
508 return HandleFileManager(false /* as_dialog */); 541 return HandleFileManager(false /* as_dialog */);
509 case OPEN_CROSH: 542 case OPEN_CROSH:
510 return HandleCrosh(); 543 return HandleCrosh();
544 case SILENCE_SPOKEN_FEEDBACK:
545 HandleSilenceSpokenFeedback();
546 break;
511 case SWAP_PRIMARY_DISPLAY: 547 case SWAP_PRIMARY_DISPLAY:
512 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); 548 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
513 return true; 549 return true;
514 case TOGGLE_SPOKEN_FEEDBACK: 550 case TOGGLE_SPOKEN_FEEDBACK:
515 return HandleToggleSpokenFeedback(); 551 return HandleToggleSpokenFeedback();
516 case TOGGLE_WIFI: 552 case TOGGLE_WIFI:
517 Shell::GetInstance()->system_tray_delegate()->ToggleWifi(); 553 Shell::GetInstance()->system_tray_delegate()->ToggleWifi();
518 return true; 554 return true;
519 case TOUCH_HUD_CLEAR: { 555 case TOUCH_HUD_CLEAR: {
520 internal::RootWindowController* controller = 556 internal::RootWindowController* controller =
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 keyboard_brightness_control_delegate) { 956 keyboard_brightness_control_delegate) {
921 keyboard_brightness_control_delegate_ = 957 keyboard_brightness_control_delegate_ =
922 keyboard_brightness_control_delegate.Pass(); 958 keyboard_brightness_control_delegate.Pass();
923 } 959 }
924 960
925 bool AcceleratorController::CanHandleAccelerators() const { 961 bool AcceleratorController::CanHandleAccelerators() const {
926 return true; 962 return true;
927 } 963 }
928 964
929 } // namespace ash 965 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_table.h » ('j') | ash/accelerators/accelerator_table.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698