1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_
10 #include "ui/events/event_rewriter.h"
16 // Receives requests for spoken feedback enabled state and command dispatch.
17 class SpokenFeedbackEventRewriterDelegate
{
19 SpokenFeedbackEventRewriterDelegate();
20 virtual ~SpokenFeedbackEventRewriterDelegate() {}
22 // Returns true when ChromeVox is enabled.
23 virtual bool IsSpokenFeedbackEnabled() const;
25 // Returns true when |key_event| is dispatched to ChromeVox.
26 virtual bool DispatchKeyEventToChromeVox(const ui::KeyEvent
& key_event
);
29 // Whether the user previously hit a sequencing prefix command.
32 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriterDelegate
);
35 // SpokenFeedbackEventRewriter discards all keyboard events mapped by the spoken
36 // feedback manifest commands block. It dispatches the associated command name
37 // directly to spoken feedback. This only occurs whenever spoken feedback is
39 class SpokenFeedbackEventRewriter
: public ui::EventRewriter
{
41 SpokenFeedbackEventRewriter();
42 ~SpokenFeedbackEventRewriter() override
;
44 void SetDelegateForTest(
45 scoped_ptr
<SpokenFeedbackEventRewriterDelegate
> delegate
);
49 ui::EventRewriteStatus
RewriteEvent(
50 const ui::Event
& event
,
51 scoped_ptr
<ui::Event
>* new_event
) override
;
52 ui::EventRewriteStatus
NextDispatchEvent(
53 const ui::Event
& last_event
,
54 scoped_ptr
<ui::Event
>* new_event
) override
;
56 // Active delegate (used for testing).
57 scoped_ptr
<SpokenFeedbackEventRewriterDelegate
> delegate_
;
59 // Stores all key codes we've captured.
60 std::vector
<int> captured_key_codes_
;
62 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriter
);
65 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_