Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / accessibility / spoken_feedback_event_rewriter.h
blob02046f5445cfa0d3fe523995558c080f3282e252
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_
8 #include <vector>
10 #include "ui/events/event_rewriter.h"
12 namespace ui {
13 class KeyEvent;
16 // Receives requests for spoken feedback enabled state and command dispatch.
17 class SpokenFeedbackEventRewriterDelegate {
18 public:
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);
28 private:
29 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriterDelegate);
32 // SpokenFeedbackEventRewriter discards all keyboard events mapped by the spoken
33 // feedback manifest commands block. It dispatches the associated command name
34 // directly to spoken feedback. This only occurs whenever spoken feedback is
35 // enabled.
36 class SpokenFeedbackEventRewriter : public ui::EventRewriter {
37 public:
38 SpokenFeedbackEventRewriter();
39 ~SpokenFeedbackEventRewriter() override;
41 void SetDelegateForTest(
42 scoped_ptr<SpokenFeedbackEventRewriterDelegate> delegate);
44 private:
45 // EventRewriter:
46 ui::EventRewriteStatus RewriteEvent(
47 const ui::Event& event,
48 scoped_ptr<ui::Event>* new_event) override;
49 ui::EventRewriteStatus NextDispatchEvent(
50 const ui::Event& last_event,
51 scoped_ptr<ui::Event>* new_event) override;
53 // Active delegate (used for testing).
54 scoped_ptr<SpokenFeedbackEventRewriterDelegate> delegate_;
56 // Stores all key codes we've captured.
57 std::vector<int> captured_key_codes_;
59 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriter);
62 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_