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

Side by Side Diff: chrome/browser/chromeos/accessibility/select_to_speak_event_handler.h

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

Powered by Google App Engine
This is Rietveld 408576698