| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "ui/events/event_rewriter.h" |
| 11 |
| 12 namespace ui { |
| 13 class KeyEvent; |
| 14 } |
| 15 |
| 16 // Receives requests for spoken feedback enabled state and command dispatch. |
| 17 class SpokenFeedbackEventRewriterDelegate { |
| 18 public: |
| 19 // Returns true when ChromeVox is enabled. |
| 20 virtual bool IsSpokenFeedbackEnabled() const = 0; |
| 21 |
| 22 // Returns true when |key_event| is dispatched to ChromeVox. |
| 23 virtual bool DispatchKeyToChromeVox(const ui::KeyEvent key_event) = 0; |
| 24 }; |
| 25 |
| 26 // SpokenFeedbackEventRewriter discards all keyboard events mapped by the spoken |
| 27 // feedback manifest commands block. It dispatches the associated command name |
| 28 // directly to spoken feedback. This only occurs whenever spoken feedback is |
| 29 // enabled. |
| 30 class SpokenFeedbackEventRewriter : public ui::EventRewriter, |
| 31 public SpokenFeedbackEventRewriterDelegate { |
| 32 public: |
| 33 explicit SpokenFeedbackEventRewriter( |
| 34 SpokenFeedbackEventRewriterDelegate* delegate); |
| 35 ~SpokenFeedbackEventRewriter() override; |
| 36 |
| 37 // EventRewriter: |
| 38 ui::EventRewriteStatus RewriteEvent( |
| 39 const ui::Event& event, |
| 40 scoped_ptr<ui::Event>* new_event) override; |
| 41 ui::EventRewriteStatus NextDispatchEvent( |
| 42 const ui::Event& last_event, |
| 43 scoped_ptr<ui::Event>* new_event) override; |
| 44 |
| 45 // SpokenFeedbackEventRewriterDelegate: |
| 46 bool IsSpokenFeedbackEnabled() const override; |
| 47 bool DispatchKeyToChromeVox(const ui::KeyEvent key_event) override; |
| 48 |
| 49 private: |
| 50 // Modifier keys held down as a result of a ChromeVox command. |
| 51 int modifiers_down_; |
| 52 |
| 53 // Provides dispatch and state services. |
| 54 SpokenFeedbackEventRewriterDelegate* delegate_; |
| 55 |
| 56 // Stores all key codes we've cpatured. |
| 57 std::vector<int> captured_key_codes_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriter); |
| 60 }; |
| 61 |
| 62 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_
H_ |
| OLD | NEW |