| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 get: function() { | 115 get: function() { |
| 116 return localStorage['active'] !== 'false'; | 116 return localStorage['active'] !== 'false'; |
| 117 }, | 117 }, |
| 118 set: function(value) { | 118 set: function(value) { |
| 119 localStorage['active'] = value; | 119 localStorage['active'] = value; |
| 120 } | 120 } |
| 121 }); | 121 }); |
| 122 | 122 |
| 123 cvox.ExtensionBridge.addMessageListener(this.onMessage_); | 123 cvox.ExtensionBridge.addMessageListener(this.onMessage_); |
| 124 | 124 |
| 125 document.addEventListener('keydown', this.onKeyDown.bind(this), true); | 125 document.addEventListener('keydown', this.onKeyDown.bind(this), false); |
| 126 document.addEventListener('keyup', this.onKeyUp.bind(this), true); | 126 document.addEventListener('keyup', this.onKeyUp.bind(this), false); |
| 127 cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); | 127 cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); |
| 128 | 128 |
| 129 // Classic keymap. | 129 // Classic keymap. |
| 130 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); | 130 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); |
| 131 | 131 |
| 132 // Live region handler. | 132 // Live region handler. |
| 133 this.liveRegions_ = new LiveRegions(this); | 133 this.liveRegions_ = new LiveRegions(this); |
| 134 | 134 |
| 135 /** @type {number} @private */ | 135 /** @type {number} @private */ |
| 136 this.passThroughKeyUpCount_ = 0; | 136 this.passThroughKeyUpCount_ = 0; |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 chrome.accessibilityPrivate.setKeyboardListener(true, false); | 511 chrome.accessibilityPrivate.setKeyboardListener(true, false); |
| 512 return false; | 512 return false; |
| 513 case 'passThroughMode': | 513 case 'passThroughMode': |
| 514 cvox.ChromeVox.passThroughMode = true; | 514 cvox.ChromeVox.passThroughMode = true; |
| 515 cvox.ChromeVox.tts.speak( | 515 cvox.ChromeVox.tts.speak( |
| 516 Msgs.getMsg('pass_through_key'), cvox.QueueMode.QUEUE); | 516 Msgs.getMsg('pass_through_key'), cvox.QueueMode.QUEUE); |
| 517 return true; | 517 return true; |
| 518 case 'openChromeVoxMenus': | 518 case 'openChromeVoxMenus': |
| 519 (new PanelCommand(PanelCommandType.OPEN_MENUS)).send(); | 519 (new PanelCommand(PanelCommandType.OPEN_MENUS)).send(); |
| 520 return false; | 520 return false; |
| 521 case 'showKbExplorerPage': |
| 522 var explorerPage = {url: 'chromevox/background/kbexplorer.html'}; |
| 523 chrome.tabs.create(explorerPage); |
| 524 break; |
| 521 case 'decreaseTtsRate': | 525 case 'decreaseTtsRate': |
| 522 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.RATE, false); | 526 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.RATE, false); |
| 523 break; | 527 break; |
| 524 case 'increaseTtsRate': | 528 case 'increaseTtsRate': |
| 525 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.RATE, true); | 529 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.RATE, true); |
| 526 break; | 530 break; |
| 527 case 'decreaseTtsPitch': | 531 case 'decreaseTtsPitch': |
| 528 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.PITCH, false); | 532 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.PITCH, false); |
| 529 break; | 533 break; |
| 530 case 'increaseTtsPitch': | 534 case 'increaseTtsPitch': |
| 531 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.PITCH, true); | 535 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.PITCH, true); |
| 532 break; | 536 break; |
| 533 case 'decreaseTtsVolume': | 537 case 'decreaseTtsVolume': |
| 534 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.VOLUME, false); | 538 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.VOLUME, false); |
| 535 break; | 539 break; |
| 536 case 'increaseTtsVolume': | 540 case 'increaseTtsVolume': |
| 537 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.VOLUME, true); | 541 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.VOLUME, true); |
| 538 break; | 542 break; |
| 543 case 'stopSpeech': |
| 544 cvox.ChromeVox.tts.stop(); |
| 545 global.isReadingContinuously = false; |
| 546 return false; |
| 539 default: | 547 default: |
| 540 return true; | 548 return true; |
| 541 } | 549 } |
| 542 | 550 |
| 543 if (pred) { | 551 if (pred) { |
| 544 var node = AutomationUtil.findNextNode( | 552 var node = AutomationUtil.findNextNode( |
| 545 current.getBound(dir).node, dir, pred); | 553 current.getBound(dir).node, dir, pred); |
| 546 | 554 |
| 547 if (node) { | 555 if (node) { |
| 548 current = cursors.Range.fromNode(node); | 556 current = cursors.Range.fromNode(node); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 840 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 833 .replace(/\*/g, '.*') | 841 .replace(/\*/g, '.*') |
| 834 .replace(/\?/g, '.'); | 842 .replace(/\?/g, '.'); |
| 835 }).join('|') + ')$'); | 843 }).join('|') + ')$'); |
| 836 }; | 844 }; |
| 837 | 845 |
| 838 /** @type {Background} */ | 846 /** @type {Background} */ |
| 839 global.backgroundObj = new Background(); | 847 global.backgroundObj = new Background(); |
| 840 | 848 |
| 841 }); // goog.scope | 849 }); // goog.scope |
| OLD | NEW |