| 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> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "ui/events/event_handler.h" | 11 #include "ui/events/event_handler.h" |
| 10 | 12 |
| 11 namespace chromeos { | 13 namespace chromeos { |
| 12 | 14 |
| 13 // When Switch Access is enabled, intercepts a few keys before the rest of the | 15 // 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 | 16 // 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 | 17 // with a small number of switches. The key events do not propagate to the rest |
| 16 // of the system. | 18 // of the system. |
| 17 // | 19 // |
| 18 // This class just intercepts the keys and forwards them to the component | 20 // This class just intercepts the keys and forwards them to the component |
| 19 // extension. | 21 // extension. |
| 20 class SwitchAccessEventHandler : public ui::EventHandler { | 22 class SwitchAccessEventHandler : public ui::EventHandler { |
| 21 public: | 23 public: |
| 22 SwitchAccessEventHandler(); | 24 SwitchAccessEventHandler(); |
| 23 ~SwitchAccessEventHandler() override; | 25 ~SwitchAccessEventHandler() override; |
| 24 | 26 |
| 27 void SetKeysToCapture(const std::vector<int>& key_codes); |
| 28 |
| 25 private: | 29 private: |
| 26 // EventHandler: | 30 // EventHandler: |
| 27 void OnKeyEvent(ui::KeyEvent* event) override; | 31 void OnKeyEvent(ui::KeyEvent* event) override; |
| 28 | 32 |
| 29 void CancelEvent(ui::Event* event); | 33 void CancelEvent(ui::Event* event); |
| 30 void DispatchKeyEventToSwitchAccess(const ui::KeyEvent& event); | 34 void DispatchKeyEventToSwitchAccess(const ui::KeyEvent& event); |
| 31 | 35 |
| 36 std::vector<int> captured_keys_; |
| 37 |
| 32 DISALLOW_COPY_AND_ASSIGN(SwitchAccessEventHandler); | 38 DISALLOW_COPY_AND_ASSIGN(SwitchAccessEventHandler); |
| 33 }; | 39 }; |
| 34 | 40 |
| 35 } // namespace chromeos | 41 } // namespace chromeos |
| 36 | 42 |
| 37 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ | 43 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SWITCH_ACCESS_EVENT_HANDLER_H_ |
| OLD | NEW |