OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SELECT_TO_SPEAK_EVENT_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "ui/events/event_handler.h" | 11 #include "ui/events/event_handler.h" |
12 #include "ui/events/keycodes/keyboard_codes.h" | 12 #include "ui/events/keycodes/keyboard_codes.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
| 16 class SelectToSpeakForwardedEventDelegateForTesting { |
| 17 public: |
| 18 virtual void OnForwardEventToSelectToSpeakExtension( |
| 19 const ui::MouseEvent& event) = 0; |
| 20 }; |
| 21 |
16 // Intercepts mouse events while the Search key is held down, and sends | 22 // Intercepts mouse events while the Search key is held down, and sends |
17 // accessibility events to the Select-to-speak extension instead. | 23 // accessibility events to the Select-to-speak extension instead. |
18 class SelectToSpeakEventHandler : public ui::EventHandler { | 24 class SelectToSpeakEventHandler : public ui::EventHandler { |
19 public: | 25 public: |
20 SelectToSpeakEventHandler(); | 26 SelectToSpeakEventHandler(); |
21 ~SelectToSpeakEventHandler() override; | 27 ~SelectToSpeakEventHandler() override; |
22 | 28 |
| 29 // For testing, call the provided callback with any events that would have |
| 30 // been forwarded to the Select-to-speak extension instead. |
| 31 void CaptureForwardedEventsForTesting( |
| 32 SelectToSpeakForwardedEventDelegateForTesting* delegate); |
| 33 |
23 private: | 34 private: |
24 // EventHandler: | 35 // EventHandler: |
25 void OnKeyEvent(ui::KeyEvent* event) override; | 36 void OnKeyEvent(ui::KeyEvent* event) override; |
26 void OnMouseEvent(ui::MouseEvent* event) override; | 37 void OnMouseEvent(ui::MouseEvent* event) override; |
27 | 38 |
28 void CancelEvent(ui::Event* event); | 39 void CancelEvent(ui::Event* event); |
29 void SendCancelAXEvent(); | 40 void SendCancelAXEvent(); |
30 | 41 |
31 enum State { | 42 enum State { |
32 // Neither the Search key nor the mouse button are down. | 43 // Neither the Search key nor the mouse button are down. |
(...skipping 22 matching lines...) Expand all Loading... |
55 | 66 |
56 State state_ = INACTIVE; | 67 State state_ = INACTIVE; |
57 | 68 |
58 // The set of keys that are currently down. Updated whenever a key is | 69 // The set of keys that are currently down. Updated whenever a key is |
59 // pressed or released. | 70 // pressed or released. |
60 std::set<ui::KeyboardCode> keys_currently_down_; | 71 std::set<ui::KeyboardCode> keys_currently_down_; |
61 // The set of keys that have been pressed together. Updated whenever a key | 72 // The set of keys that have been pressed together. Updated whenever a key |
62 // is pressed, and only cleared when all keys are released. | 73 // is pressed, and only cleared when all keys are released. |
63 std::set<ui::KeyboardCode> keys_pressed_together_; | 74 std::set<ui::KeyboardCode> keys_pressed_together_; |
64 | 75 |
| 76 SelectToSpeakForwardedEventDelegateForTesting* event_delegate_for_testing_; |
| 77 |
65 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandler); | 78 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandler); |
66 }; | 79 }; |
67 | 80 |
68 } // namespace chromeos | 81 } // namespace chromeos |
69 | 82 |
70 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H
_ | 83 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H
_ |
OLD | NEW |