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 var focus = chrome.automation.getFocus(); |
| 222 if (focus) |
| 223 this.setCurrentRange(cursors.Range.fromNode(focus)); |
| 224 } |
| 225 |
211 this.mode_ = mode; | 226 this.mode_ = mode; |
212 }, | 227 }, |
213 | 228 |
214 /** | 229 /** |
215 * Mode refreshes takes into account both |url| and the current ChromeVox | 230 * 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 | 231 * 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 | 232 * content. The focused state also needs to be set for this info to be |
218 * reliable. | 233 * reliable. |
219 * @override | 234 * @override |
220 */ | 235 */ |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 newMode = ChromeVoxMode.FORCE_NEXT; | 507 newMode = ChromeVoxMode.FORCE_NEXT; |
493 } | 508 } |
494 this.setMode(newMode, true); | 509 this.setMode(newMode, true); |
495 | 510 |
496 var isClassic = | 511 var isClassic = |
497 newMode == ChromeVoxMode.CLASSIC || newMode == ChromeVoxMode.COMPAT; | 512 newMode == ChromeVoxMode.CLASSIC || newMode == ChromeVoxMode.COMPAT; |
498 | 513 |
499 // Leaving unlocalized as 'next' isn't an official name. | 514 // Leaving unlocalized as 'next' isn't an official name. |
500 cvox.ChromeVox.tts.speak(isClassic ? | 515 cvox.ChromeVox.tts.speak(isClassic ? |
501 'classic' : 'next', cvox.QueueMode.FLUSH, {doNotInterrupt: true}); | 516 'classic' : 'next', cvox.QueueMode.FLUSH, {doNotInterrupt: true}); |
| 517 |
| 518 // If the new mode is Classic, return now so we don't announce |
| 519 // anything more. |
| 520 if (newMode == ChromeVoxMode.CLASSIC) |
| 521 return false; |
502 break; | 522 break; |
503 case 'toggleStickyMode': | 523 case 'toggleStickyMode': |
504 cvox.ChromeVoxBackground.setPref('sticky', | 524 cvox.ChromeVoxBackground.setPref('sticky', |
505 !cvox.ChromeVox.isStickyPrefOn, | 525 !cvox.ChromeVox.isStickyPrefOn, |
506 true); | 526 true); |
507 | 527 |
508 if (cvox.ChromeVox.isStickyPrefOn) | 528 if (cvox.ChromeVox.isStickyPrefOn) |
509 chrome.accessibilityPrivate.setKeyboardListener(true, true); | 529 chrome.accessibilityPrivate.setKeyboardListener(true, true); |
510 else | 530 else |
511 chrome.accessibilityPrivate.setKeyboardListener(true, false); | 531 chrome.accessibilityPrivate.setKeyboardListener(true, false); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 852 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
833 .replace(/\*/g, '.*') | 853 .replace(/\*/g, '.*') |
834 .replace(/\?/g, '.'); | 854 .replace(/\?/g, '.'); |
835 }).join('|') + ')$'); | 855 }).join('|') + ')$'); |
836 }; | 856 }; |
837 | 857 |
838 /** @type {Background} */ | 858 /** @type {Background} */ |
839 global.backgroundObj = new Background(); | 859 global.backgroundObj = new Background(); |
840 | 860 |
841 }); // goog.scope | 861 }); // goog.scope |
OLD | NEW |