OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H_ | |
7 | |
8 #include <vector> | |
David Tseng
2016/11/11 19:18:30
Unused?
dmazzoni
2016/11/14 22:11:42
Done.
| |
9 | |
10 #include "base/macros.h" | |
11 #include "ui/events/event_handler.h" | |
12 | |
13 namespace chromeos { | |
14 | |
15 // Intercepts mouse events while the Search key is held down, and sends | |
16 // accessibility events to the Select-to-speak extension instead. | |
17 class SelectToSpeakEventHandler : public ui::EventHandler { | |
18 public: | |
19 SelectToSpeakEventHandler(); | |
20 ~SelectToSpeakEventHandler() override; | |
21 | |
22 private: | |
23 // EventHandler: | |
24 void OnKeyEvent(ui::KeyEvent* event) override; | |
25 void OnMouseEvent(ui::MouseEvent* event) override; | |
26 | |
27 void CancelEvent(ui::Event* event); | |
28 void SendCancelAXEvent(); | |
29 | |
30 enum State { | |
31 // The Search key is not held down and the mouse button is not down. | |
32 INACTIVE, | |
33 | |
34 // The Search key is down but the mouse button is not. | |
35 SEARCH_DOWN, | |
36 | |
37 // The user held down Search and clicked the mouse button. We're capturing | |
38 // all events from now on until either Search or the mouse button is | |
39 // released. | |
40 CAPTURING, | |
41 | |
42 // The mouse was released, but Search is still held down. If the user | |
43 // clicks again, we'll go back to the state CAPTURING. This is different | |
44 // than the state SEARCH_DOWN because we know the user clicked at least | |
45 // once, so when Search is released we'll handle that event too, so as | |
46 // to not trigger opening the Search UI. | |
47 MOUSE_RELEASED, | |
48 | |
49 // The Search key was released while the mouse was still down, cancelling | |
50 // the Select-to-Speak event. Stay in this mode until the mouse button | |
51 // is released, too. | |
52 WAIT_FOR_MOUSE_RELEASE | |
53 }; | |
54 | |
55 State state_ = INACTIVE; | |
56 | |
57 int last_view_storage_id_ = 0; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(SelectToSpeakEventHandler); | |
60 }; | |
61 | |
62 } // namespace chromeos | |
63 | |
64 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SELECT_TO_SPEAK_EVENT_HANDLER_H _ | |
OLD | NEW |