Chromium Code Reviews| 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 * | |
|
David Tseng
2015/11/17 20:42:00
nit: extra line
dmazzoni
2015/11/18 16:59:16
Done.
| |
| 417 * @param {Event} evt The key down event to process. | |
| 418 * @return {boolean} True if the default action should be performed. | |
| 419 */ | |
| 420 onKeyDown: function(evt) { | |
| 421 if (!cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) { | |
| 422 evt.preventDefault(); | |
| 423 evt.stopPropagation(); | |
| 424 } | |
| 425 }, | |
| 426 | |
| 427 /** | |
| 416 * Open the options page in a new tab. | 428 * Open the options page in a new tab. |
| 417 */ | 429 */ |
| 418 showOptionsPage: function() { | 430 showOptionsPage: function() { |
| 419 var optionsPage = {url: 'chromevox/background/options.html'}; | 431 var optionsPage = {url: 'chromevox/background/options.html'}; |
| 420 chrome.tabs.create(optionsPage); | 432 chrome.tabs.create(optionsPage); |
| 421 }, | 433 }, |
| 422 | 434 |
| 423 /** | 435 /** |
| 424 * Handles a braille command. | 436 * Handles a braille command. |
| 425 * @param {!cvox.BrailleKeyEvent} evt | 437 * @param {!cvox.BrailleKeyEvent} evt |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 671 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 683 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 672 .replace(/\*/g, '.*') | 684 .replace(/\*/g, '.*') |
| 673 .replace(/\?/g, '.'); | 685 .replace(/\?/g, '.'); |
| 674 }).join('|') + ')$'); | 686 }).join('|') + ')$'); |
| 675 }; | 687 }; |
| 676 | 688 |
| 677 /** @type {Background} */ | 689 /** @type {Background} */ |
| 678 global.backgroundObj = new Background(); | 690 global.backgroundObj = new Background(); |
| 679 | 691 |
| 680 }); // goog.scope | 692 }); // goog.scope |
| OLD | NEW |