OLD | NEW |
---|---|
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 The entry point for all ChromeVox2 related code for the | 6 * @fileoverview The entry point for all ChromeVox2 related code for the |
7 * background page. | 7 * background page. |
8 */ | 8 */ |
9 | 9 |
10 goog.provide('Background'); | 10 goog.provide('Background'); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); | 119 cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); |
120 | 120 |
121 // Classic keymap. | 121 // Classic keymap. |
122 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); | 122 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); |
123 | 123 |
124 // Live region handler. | 124 // Live region handler. |
125 this.liveRegions_ = new LiveRegions(this); | 125 this.liveRegions_ = new LiveRegions(this); |
126 | 126 |
127 if (!chrome.accessibilityPrivate.setKeyboardListener) | 127 if (!chrome.accessibilityPrivate.setKeyboardListener) |
128 chrome.accessibilityPrivate.setKeyboardListener = function() {}; | 128 chrome.accessibilityPrivate.setKeyboardListener = function() {}; |
129 | |
130 var focus = chrome.automation.getFocus(); | |
131 if (focus) | |
132 this.setCurrentRange(cursors.Range.fromNode(focus)); | |
129 }; | 133 }; |
130 | 134 |
131 Background.prototype = { | 135 Background.prototype = { |
132 __proto__: ChromeVoxState.prototype, | 136 __proto__: ChromeVoxState.prototype, |
133 | 137 |
134 /** | 138 /** |
135 * @override | 139 * @override |
136 */ | 140 */ |
137 getMode: function() { | 141 getMode: function() { |
138 return this.mode_; | 142 return this.mode_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 }.bind(this)); | 187 }.bind(this)); |
184 | 188 |
185 // If switching out of a ChromeVox Next mode, make sure we cancel | 189 // If switching out of a ChromeVox Next mode, make sure we cancel |
186 // the progress loading sound just in case. | 190 // the progress loading sound just in case. |
187 if ((this.mode_ === ChromeVoxMode.NEXT || | 191 if ((this.mode_ === ChromeVoxMode.NEXT || |
188 this.mode_ === ChromeVoxMode.FORCE_NEXT) && | 192 this.mode_ === ChromeVoxMode.FORCE_NEXT) && |
189 this.mode_ != mode) { | 193 this.mode_ != mode) { |
190 cvox.ChromeVox.earcons.cancelEarcon(cvox.Earcon.PAGE_START_LOADING); | 194 cvox.ChromeVox.earcons.cancelEarcon(cvox.Earcon.PAGE_START_LOADING); |
191 } | 195 } |
192 | 196 |
197 // If switching to Classic from any automation-API-based mode, | |
198 // clear the focus ring. | |
199 if (mode === ChromeVoxMode.CLASSIC && mode != this.mode_) { | |
200 if (cvox.ChromeVox.isChromeOS) | |
201 chrome.accessibilityPrivate.setFocusRing([]); | |
202 } | |
203 | |
204 // If switching away from Classic to any automation-API-based mode, | |
205 // update the range based on what's focused. | |
206 if (this.mode_ === ChromeVoxMode.CLASSIC && mode != this.mode_) { | |
207 var focus = chrome.automation.getFocus(); | |
208 if (focus) | |
209 this.setCurrentRange(cursors.Range.fromNode(focus)); | |
210 } | |
211 | |
193 this.mode_ = mode; | 212 this.mode_ = mode; |
194 }, | 213 }, |
195 | 214 |
196 /** | 215 /** |
197 * Mode refreshes takes into account both |url| and the current ChromeVox | 216 * Mode refreshes takes into account both |url| and the current ChromeVox |
198 * range. The latter gets used to decide if the user is or isn't in web | 217 * range. The latter gets used to decide if the user is or isn't in web |
199 * content. The focused state also needs to be set for this info to be | 218 * content. The focused state also needs to be set for this info to be |
200 * reliable. | 219 * reliable. |
201 * @override | 220 * @override |
202 */ | 221 */ |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 newMode = ChromeVoxMode.FORCE_NEXT; | 477 newMode = ChromeVoxMode.FORCE_NEXT; |
459 } | 478 } |
460 this.setMode(newMode, true); | 479 this.setMode(newMode, true); |
461 | 480 |
462 var isClassic = | 481 var isClassic = |
463 newMode == ChromeVoxMode.CLASSIC || newMode == ChromeVoxMode.COMPAT; | 482 newMode == ChromeVoxMode.CLASSIC || newMode == ChromeVoxMode.COMPAT; |
464 | 483 |
465 // Leaving unlocalized as 'next' isn't an official name. | 484 // Leaving unlocalized as 'next' isn't an official name. |
466 cvox.ChromeVox.tts.speak(isClassic ? | 485 cvox.ChromeVox.tts.speak(isClassic ? |
467 'classic' : 'next', cvox.QueueMode.FLUSH, {doNotInterrupt: true}); | 486 'classic' : 'next', cvox.QueueMode.FLUSH, {doNotInterrupt: true}); |
487 | |
488 // If the new mode is Classic, return now so we don't announce | |
David Tseng
2016/01/28 02:00:56
Maybe add something to queue the next utterance?
dmazzoni
2016/01/30 00:02:41
For Classic? Did you have something specific in mi
| |
489 // anything more. | |
490 if (newMode == ChromeVoxMode.CLASSIC) | |
491 return false; | |
492 | |
David Tseng
2016/01/28 02:00:56
nit: extra line
dmazzoni
2016/01/30 00:02:41
Done.
| |
468 break; | 493 break; |
469 case 'toggleStickyMode': | 494 case 'toggleStickyMode': |
470 cvox.ChromeVoxBackground.setPref('sticky', | 495 cvox.ChromeVoxBackground.setPref('sticky', |
471 !cvox.ChromeVox.isStickyPrefOn, | 496 !cvox.ChromeVox.isStickyPrefOn, |
472 true); | 497 true); |
473 | 498 |
474 if (cvox.ChromeVox.isStickyPrefOn) | 499 if (cvox.ChromeVox.isStickyPrefOn) |
475 chrome.accessibilityPrivate.setKeyboardListener(true, true); | 500 chrome.accessibilityPrivate.setKeyboardListener(true, true); |
476 else | 501 else |
477 chrome.accessibilityPrivate.setKeyboardListener(true, false); | 502 chrome.accessibilityPrivate.setKeyboardListener(true, false); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 720 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
696 .replace(/\*/g, '.*') | 721 .replace(/\*/g, '.*') |
697 .replace(/\?/g, '.'); | 722 .replace(/\?/g, '.'); |
698 }).join('|') + ')$'); | 723 }).join('|') + ')$'); |
699 }; | 724 }; |
700 | 725 |
701 /** @type {Background} */ | 726 /** @type {Background} */ |
702 global.backgroundObj = new Background(); | 727 global.backgroundObj = new Background(); |
703 | 728 |
704 }); // goog.scope | 729 }); // goog.scope |
OLD | NEW |