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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 cvox.ChromeVox.earcons.cancelEarcon(cvox.Earcon.PAGE_START_LOADING); | 201 cvox.ChromeVox.earcons.cancelEarcon(cvox.Earcon.PAGE_START_LOADING); |
202 } | 202 } |
203 | 203 |
204 if (mode === ChromeVoxMode.NEXT || | 204 if (mode === ChromeVoxMode.NEXT || |
205 mode === ChromeVoxMode.FORCE_NEXT) { | 205 mode === ChromeVoxMode.FORCE_NEXT) { |
206 (new PanelCommand(PanelCommandType.ENABLE_MENUS)).send(); | 206 (new PanelCommand(PanelCommandType.ENABLE_MENUS)).send(); |
207 } else { | 207 } else { |
208 (new PanelCommand(PanelCommandType.DISABLE_MENUS)).send(); | 208 (new PanelCommand(PanelCommandType.DISABLE_MENUS)).send(); |
209 } | 209 } |
210 | 210 |
| 211 // If switching to Classic from any automation-API-based mode, |
| 212 // clear the focus ring. |
| 213 if (mode === ChromeVoxMode.CLASSIC && mode != this.mode_) { |
| 214 if (cvox.ChromeVox.isChromeOS) |
| 215 chrome.accessibilityPrivate.setFocusRing([]); |
| 216 } |
| 217 |
| 218 // If switching away from Classic to any automation-API-based mode, |
| 219 // update the range based on what's focused. |
| 220 if (this.mode_ === ChromeVoxMode.CLASSIC && mode != this.mode_) { |
| 221 chrome.automation.getFocus((function(focus) { |
| 222 if (focus) |
| 223 this.setCurrentRange(cursors.Range.fromNode(focus)); |
| 224 }).bind(this)); |
| 225 } |
| 226 |
211 this.mode_ = mode; | 227 this.mode_ = mode; |
212 }, | 228 }, |
213 | 229 |
214 /** | 230 /** |
215 * Mode refreshes takes into account both |url| and the current ChromeVox | 231 * Mode refreshes takes into account both |url| and the current ChromeVox |
216 * range. The latter gets used to decide if the user is or isn't in web | 232 * range. The latter gets used to decide if the user is or isn't in web |
217 * content. The focused state also needs to be set for this info to be | 233 * content. The focused state also needs to be set for this info to be |
218 * reliable. | 234 * reliable. |
219 * @override | 235 * @override |
220 */ | 236 */ |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 newMode = ChromeVoxMode.FORCE_NEXT; | 508 newMode = ChromeVoxMode.FORCE_NEXT; |
493 } | 509 } |
494 this.setMode(newMode, true); | 510 this.setMode(newMode, true); |
495 | 511 |
496 var isClassic = | 512 var isClassic = |
497 newMode == ChromeVoxMode.CLASSIC || newMode == ChromeVoxMode.COMPAT; | 513 newMode == ChromeVoxMode.CLASSIC || newMode == ChromeVoxMode.COMPAT; |
498 | 514 |
499 // Leaving unlocalized as 'next' isn't an official name. | 515 // Leaving unlocalized as 'next' isn't an official name. |
500 cvox.ChromeVox.tts.speak(isClassic ? | 516 cvox.ChromeVox.tts.speak(isClassic ? |
501 'classic' : 'next', cvox.QueueMode.FLUSH, {doNotInterrupt: true}); | 517 'classic' : 'next', cvox.QueueMode.FLUSH, {doNotInterrupt: true}); |
| 518 |
| 519 // If the new mode is Classic, return now so we don't announce |
| 520 // anything more. |
| 521 if (newMode == ChromeVoxMode.CLASSIC) |
| 522 return false; |
502 break; | 523 break; |
503 case 'toggleStickyMode': | 524 case 'toggleStickyMode': |
504 cvox.ChromeVoxBackground.setPref('sticky', | 525 cvox.ChromeVoxBackground.setPref('sticky', |
505 !cvox.ChromeVox.isStickyPrefOn, | 526 !cvox.ChromeVox.isStickyPrefOn, |
506 true); | 527 true); |
507 | 528 |
508 if (cvox.ChromeVox.isStickyPrefOn) | 529 if (cvox.ChromeVox.isStickyPrefOn) |
509 chrome.accessibilityPrivate.setKeyboardListener(true, true); | 530 chrome.accessibilityPrivate.setKeyboardListener(true, true); |
510 else | 531 else |
511 chrome.accessibilityPrivate.setKeyboardListener(true, false); | 532 chrome.accessibilityPrivate.setKeyboardListener(true, false); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 861 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
841 .replace(/\*/g, '.*') | 862 .replace(/\*/g, '.*') |
842 .replace(/\?/g, '.'); | 863 .replace(/\?/g, '.'); |
843 }).join('|') + ')$'); | 864 }).join('|') + ')$'); |
844 }; | 865 }; |
845 | 866 |
846 /** @type {Background} */ | 867 /** @type {Background} */ |
847 global.backgroundObj = new Background(); | 868 global.backgroundObj = new Background(); |
848 | 869 |
849 }); // goog.scope | 870 }); // goog.scope |
OLD | NEW |