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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/host/chrome/braille_background.js

Issue 2817313002: Support braille dot or chorded typing conversions to standard keyboard keys (Closed)
Patch Set: Address feedback. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Sends Braille commands to the Braille API. 6 * @fileoverview Sends Braille commands to the Braille API.
7 */ 7 */
8 8
9 goog.provide('cvox.BrailleBackground'); 9 goog.provide('cvox.BrailleBackground');
10 10
11 goog.require('BrailleKeyEventRewriter');
11 goog.require('ChromeVoxState'); 12 goog.require('ChromeVoxState');
12 goog.require('cvox.BrailleDisplayManager'); 13 goog.require('cvox.BrailleDisplayManager');
13 goog.require('cvox.BrailleInputHandler'); 14 goog.require('cvox.BrailleInputHandler');
14 goog.require('cvox.BrailleInterface'); 15 goog.require('cvox.BrailleInterface');
15 goog.require('cvox.BrailleKeyEvent'); 16 goog.require('cvox.BrailleKeyEvent');
16 goog.require('cvox.BrailleTranslatorManager'); 17 goog.require('cvox.BrailleTranslatorManager');
17 18
18
19 /** 19 /**
20 * @constructor 20 * @constructor
21 * @param {cvox.BrailleDisplayManager=} opt_displayManagerForTest 21 * @param {cvox.BrailleDisplayManager=} opt_displayManagerForTest
22 * Display manager (for mocking in tests). 22 * Display manager (for mocking in tests).
23 * @param {cvox.BrailleInputHandler=} opt_inputHandlerForTest Input handler 23 * @param {cvox.BrailleInputHandler=} opt_inputHandlerForTest Input handler
24 * (for mocking in tests). 24 * (for mocking in tests).
25 * @param {cvox.BrailleTranslatorManager=} opt_translatorManagerForTest 25 * @param {cvox.BrailleTranslatorManager=} opt_translatorManagerForTest
26 * Braille translator manager (for mocking in tests) 26 * Braille translator manager (for mocking in tests)
27 * @implements {cvox.BrailleInterface} 27 * @implements {cvox.BrailleInterface}
28 */ 28 */
(...skipping 25 matching lines...) Expand all
54 /** 54 /**
55 * @type {!cvox.BrailleInputHandler} 55 * @type {!cvox.BrailleInputHandler}
56 * @private 56 * @private
57 */ 57 */
58 this.inputHandler_ = opt_inputHandlerForTest || 58 this.inputHandler_ = opt_inputHandlerForTest ||
59 new cvox.BrailleInputHandler(this.translatorManager_); 59 new cvox.BrailleInputHandler(this.translatorManager_);
60 this.inputHandler_.init(); 60 this.inputHandler_.init();
61 61
62 /** @private {boolean} */ 62 /** @private {boolean} */
63 this.frozen_ = false; 63 this.frozen_ = false;
64
65 /** @private {BrailleKeyEventRewriter} */
66 this.keyEventRewriter_ = new BrailleKeyEventRewriter();
64 }; 67 };
65 goog.addSingletonGetter(cvox.BrailleBackground); 68 goog.addSingletonGetter(cvox.BrailleBackground);
66 69
67 70
68 /** @override */ 71 /** @override */
69 cvox.BrailleBackground.prototype.write = function(params) { 72 cvox.BrailleBackground.prototype.write = function(params) {
70 if (this.frozen_) { 73 if (this.frozen_) {
71 return; 74 return;
72 } 75 }
73 this.setContent_(params, null); 76 this.setContent_(params, null);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 145
143 /** 146 /**
144 * Handles braille key events by dispatching either to the input handler, 147 * Handles braille key events by dispatching either to the input handler,
145 * ChromeVox next's background object or ChromeVox classic's content script. 148 * ChromeVox next's background object or ChromeVox classic's content script.
146 * @param {!cvox.BrailleKeyEvent} brailleEvt The event. 149 * @param {!cvox.BrailleKeyEvent} brailleEvt The event.
147 * @param {!cvox.NavBraille} content Content of display when event fired. 150 * @param {!cvox.NavBraille} content Content of display when event fired.
148 * @private 151 * @private
149 */ 152 */
150 cvox.BrailleBackground.prototype.onBrailleKeyEvent_ = function( 153 cvox.BrailleBackground.prototype.onBrailleKeyEvent_ = function(
151 brailleEvt, content) { 154 brailleEvt, content) {
155 if (this.keyEventRewriter_.onBrailleKeyEvent(brailleEvt)) {
156 return;
157 }
158
152 if (this.inputHandler_.onBrailleKeyEvent(brailleEvt)) { 159 if (this.inputHandler_.onBrailleKeyEvent(brailleEvt)) {
153 return; 160 return;
154 } 161 }
155 if (ChromeVoxState.instance && 162 if (ChromeVoxState.instance &&
156 ChromeVoxState.instance.onBrailleKeyEvent(brailleEvt, content)) { 163 ChromeVoxState.instance.onBrailleKeyEvent(brailleEvt, content)) {
157 return; 164 return;
158 } 165 }
159 this.sendCommand_(brailleEvt, content); 166 this.sendCommand_(brailleEvt, content);
160 }; 167 };
161 168
162 169
163 /** 170 /**
164 * Dispatches braille input commands to the content script. 171 * Dispatches braille input commands to the content script.
165 * @param {!cvox.BrailleKeyEvent} brailleEvt The event. 172 * @param {!cvox.BrailleKeyEvent} brailleEvt The event.
166 * @param {cvox.NavBraille} content Content of display when event fired. 173 * @param {cvox.NavBraille} content Content of display when event fired.
167 * @private 174 * @private
168 */ 175 */
169 cvox.BrailleBackground.prototype.sendCommand_ = 176 cvox.BrailleBackground.prototype.sendCommand_ =
170 function(brailleEvt, content) { 177 function(brailleEvt, content) {
171 var msg = { 178 var msg = {
172 'message': 'BRAILLE', 179 'message': 'BRAILLE',
173 'args': brailleEvt 180 'args': brailleEvt
174 }; 181 };
175 if (content === this.lastContent_) { 182 if (content === this.lastContent_) {
176 msg.contentId = this.lastContentId_; 183 msg.contentId = this.lastContentId_;
177 } 184 }
178 cvox.ExtensionBridge.send(msg); 185 cvox.ExtensionBridge.send(msg);
179 }; 186 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698