Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | |
|
Devlin
2017/05/30 19:22:03
not needed
elichtenberg
2017/05/31 00:58:43
Done.
| |
| 9 #include <unordered_set> | |
| 10 | |
| 8 #include "base/macros.h" | 11 #include "base/macros.h" |
| 9 #include "ui/events/event_handler.h" | 12 #include "ui/events/event_handler.h" |
| 10 | 13 |
| 11 namespace chromeos { | 14 namespace chromeos { |
| 12 | 15 |
| 13 // When Switch Access is enabled, intercepts a few keys before the rest of the | 16 // When Switch Access is enabled, intercepts a few keys before the rest of the |
| 14 // OS has a chance to handle them, as a method for controlling the entire OS | 17 // OS has a chance to handle them, as a method for controlling the entire OS |
| 15 // with a small number of switches. The key events do not propagate to the rest | 18 // with a small number of switches. The key events do not propagate to the rest |
| 16 // of the system. | 19 // of the system. |
| 17 // | 20 // |
| 18 // This class just intercepts the keys and forwards them to the component | 21 // This class just intercepts the keys and forwards them to the component |
| 19 // extension. | 22 // extension. |
| 20 class SwitchAccessEventHandler : public ui::EventHandler { | 23 class SwitchAccessEventHandler : public ui::EventHandler { |
| 21 public: | 24 public: |
| 22 SwitchAccessEventHandler(); | 25 SwitchAccessEventHandler(); |
| 23 ~SwitchAccessEventHandler() override; | 26 ~SwitchAccessEventHandler() override; |
| 24 | 27 |
| 28 void SetKeysToCapture(const std::unordered_set<int>& key_codes); | |
|
Devlin
2017/05/30 19:22:03
Any reason to use std::unordered_set over std::set
elichtenberg
2017/05/31 00:58:43
I believe unordered_sets are faster than sets. I t
Devlin
2017/05/31 01:33:32
"faster" depends entirely on data set size. The a
elichtenberg
2017/06/01 19:55:26
Fair point. Changed it to std::set.
| |
| 29 | |
| 25 private: | 30 private: |
| 26 // EventHandler: | 31 // EventHandler: |
| 27 void OnKeyEvent(ui::KeyEvent* event) override; | 32 void OnKeyEvent(ui::KeyEvent* event) override; |
| 28 | 33 |
| 29 void CancelEvent(ui::Event* event); | 34 void CancelEvent(ui::Event* event); |
| 30 void DispatchKeyEventToSwitchAccess(const ui::KeyEvent& event); | 35 void DispatchKeyEventToSwitchAccess(const ui::KeyEvent& event); |
| 31 | 36 |
| 37 std::unordered_set<int> captured_keys_; | |
| 38 | |
| 32 DISALLOW_COPY_AND_ASSIGN(SwitchAccessEventHandler); | 39 DISALLOW_COPY_AND_ASSIGN(SwitchAccessEventHandler); |
| 33 }; | 40 }; |
| 34 | 41 |
| 35 } // namespace chromeos | 42 } // namespace chromeos |
| 36 | 43 |
| 37 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ | 44 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ |
| OLD | NEW |