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

Side by Side Diff: chrome/browser/chromeos/accessibility/switch_access_event_handler.cc

Issue 2711343005: Set keys to traverse accessibility tree. Using focus ring to highlight selected node. (Closed)
Patch Set: Fixing closure compilation error Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/accessibility/switch_access_event_handler.h"
6
7 #include "ash/shell.h"
8 #include "base/logging.h"
9 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
10 #include "chrome/browser/chromeos/accessibility/event_handler_common.h"
11 #include "chrome/common/extensions/extension_constants.h"
12 #include "extensions/browser/extension_host.h"
13 #include "ui/events/event.h"
14
15 namespace chromeos {
16
17 SwitchAccessEventHandler::SwitchAccessEventHandler() {
18 if (ash::Shell::HasInstance())
19 ash::Shell::GetInstance()->AddPreTargetHandler(this);
20 }
21
22 SwitchAccessEventHandler::~SwitchAccessEventHandler() {
23 if (ash::Shell::HasInstance())
24 ash::Shell::GetInstance()->RemovePreTargetHandler(this);
25 }
26
27 void SwitchAccessEventHandler::OnKeyEvent(ui::KeyEvent* event) {
28 DCHECK(event);
29
30 ui::KeyboardCode key_code = event->key_code();
31 if (key_code == ui::VKEY_1 || key_code == ui::VKEY_2 ||
32 key_code == ui::VKEY_3 || key_code == ui::VKEY_4 ||
33 key_code == ui::VKEY_5) {
34 CancelEvent(event);
35 LOG(ERROR) << "Dispatching key " << key_code - ui::VKEY_0
36 << " to switch access";
37 DispatchKeyEventToSwitchAccess(*event);
38 }
39 }
40
41 void SwitchAccessEventHandler::CancelEvent(ui::Event* event) {
42 DCHECK(event);
43 if (event->cancelable()) {
44 event->SetHandled();
45 event->StopPropagation();
46 }
47 }
48
49 void SwitchAccessEventHandler::DispatchKeyEventToSwitchAccess(
50 const ui::KeyEvent& event) {
51 extensions::ExtensionHost* host =
52 GetAccessibilityExtensionHost(extension_misc::kSwitchAccessExtensionId);
53 ForwardKeyToExtension(event, host);
54 }
55
56 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698