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

Unified Diff: chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h

Issue 1185753008: Proposed alternative for supporting ChromeVox keyboard commands. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ui/events/* changes. Created 5 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h
diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h b/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..2d6fcf060604b5d2ae1eb5d5936bdd442387ea2d
--- /dev/null
+++ b/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter.h
@@ -0,0 +1,63 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_
+#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_
+
+#include <vector>
+
+#include "ui/events/event_rewriter.h"
+
+namespace ui {
+class KeyEvent;
+}
+
+// Receives requests for spoken feedback enabled state and command dispatch.
+class SpokenFeedbackEventRewriterDelegate {
+ public:
+ SpokenFeedbackEventRewriterDelegate() {}
+ virtual ~SpokenFeedbackEventRewriterDelegate() {}
+
+ // Returns true when ChromeVox is enabled.
+ virtual bool IsSpokenFeedbackEnabled() const;
+
+ // Returns true when |key_event| is dispatched to ChromeVox.
+ virtual bool DispatchKeyToChromeVox(const ui::KeyEvent key_event);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriterDelegate);
+};
+
+// SpokenFeedbackEventRewriter discards all keyboard events mapped by the spoken
+// feedback manifest commands block. It dispatches the associated command name
+// directly to spoken feedback. This only occurs whenever spoken feedback is
+// enabled.
+class SpokenFeedbackEventRewriter : public ui::EventRewriter {
+ public:
+ explicit SpokenFeedbackEventRewriter(
+ SpokenFeedbackEventRewriterDelegate* delegate);
+ ~SpokenFeedbackEventRewriter() override;
+
+ // EventRewriter:
+ ui::EventRewriteStatus RewriteEvent(
+ const ui::Event& event,
+ scoped_ptr<ui::Event>* new_event) override;
+ ui::EventRewriteStatus NextDispatchEvent(
+ const ui::Event& last_event,
+ scoped_ptr<ui::Event>* new_event) override;
+
+ private:
+ // Default delegate implementation.
+ SpokenFeedbackEventRewriterDelegate default_delegate_;
+
+ // Active delegate (used for testing).
+ SpokenFeedbackEventRewriterDelegate* delegate_;
+
+ // Stores all key codes we've captured.
+ std::vector<int> captured_key_codes_;
+
+ DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriter);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPOKEN_FEEDBACK_EVENT_REWRITER_H_

Powered by Google App Engine
This is Rietveld 408576698