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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 get: function() { | 112 get: function() { |
113 return localStorage['active'] !== 'false'; | 113 return localStorage['active'] !== 'false'; |
114 }, | 114 }, |
115 set: function(value) { | 115 set: function(value) { |
116 localStorage['active'] = value; | 116 localStorage['active'] = value; |
117 } | 117 } |
118 }); | 118 }); |
119 | 119 |
120 cvox.ExtensionBridge.addMessageListener(this.onMessage_); | 120 cvox.ExtensionBridge.addMessageListener(this.onMessage_); |
121 | 121 |
122 document.addEventListener( | 122 document.addEventListener('keydown', this.onKeyDown.bind(this), true); |
123 'keydown', cvox.ChromeVoxKbHandler.basicKeyDownActionsListener, true); | |
124 cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); | 123 cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); |
125 | 124 |
126 // Classic keymap. | 125 // Classic keymap. |
127 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); | 126 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); |
128 | 127 |
129 chrome.automation.addTreeChangeObserver(this.onTreeChange); | 128 chrome.automation.addTreeChangeObserver(this.onTreeChange); |
130 }; | 129 }; |
131 | 130 |
132 Background.prototype = { | 131 Background.prototype = { |
133 /** Forces ChromeVox Next to be active for all tabs. */ | 132 /** Forces ChromeVox Next to be active for all tabs. */ |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 | 405 |
407 new Output().withSpeechAndBraille( | 406 new Output().withSpeechAndBraille( |
408 this.currentRange_, prevRange, Output.EventType.NAVIGATE) | 407 this.currentRange_, prevRange, Output.EventType.NAVIGATE) |
409 .go(); | 408 .go(); |
410 } | 409 } |
411 | 410 |
412 return false; | 411 return false; |
413 }, | 412 }, |
414 | 413 |
415 /** | 414 /** |
415 * Handles key down events. | |
416 * @param {Event} evt The key down event to process. | |
417 * @return {boolean} True if the default action should be performed. | |
418 */ | |
419 onKeyDown: function(evt) { | |
420 if (!cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) { | |
David Tseng
2015/11/19 01:11:50
Sorry missed something here. This needs to be mode
| |
421 evt.preventDefault(); | |
422 evt.stopPropagation(); | |
423 } | |
424 }, | |
425 | |
426 /** | |
416 * Open the options page in a new tab. | 427 * Open the options page in a new tab. |
417 */ | 428 */ |
418 showOptionsPage: function() { | 429 showOptionsPage: function() { |
419 var optionsPage = {url: 'chromevox/background/options.html'}; | 430 var optionsPage = {url: 'chromevox/background/options.html'}; |
420 chrome.tabs.create(optionsPage); | 431 chrome.tabs.create(optionsPage); |
421 }, | 432 }, |
422 | 433 |
423 /** | 434 /** |
424 * Handles a braille command. | 435 * Handles a braille command. |
425 * @param {!cvox.BrailleKeyEvent} evt | 436 * @param {!cvox.BrailleKeyEvent} evt |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 682 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
672 .replace(/\*/g, '.*') | 683 .replace(/\*/g, '.*') |
673 .replace(/\?/g, '.'); | 684 .replace(/\?/g, '.'); |
674 }).join('|') + ')$'); | 685 }).join('|') + ')$'); |
675 }; | 686 }; |
676 | 687 |
677 /** @type {Background} */ | 688 /** @type {Background} */ |
678 global.backgroundObj = new Background(); | 689 global.backgroundObj = new Background(); |
679 | 690 |
680 }); // goog.scope | 691 }); // goog.scope |
OLD | NEW |