| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js
|
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js
|
| index 8259e05a2dd619a4b51dfd0461ad61c6f6630c05..dae832c0c9ca66b3e93f1cabf9b23e077e46777e 100644
|
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js
|
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js
|
| @@ -9,16 +9,19 @@
|
|
|
| goog.provide('ClassicCompatibility');
|
|
|
| -goog.require('cvox.ExtensionBridge');
|
| goog.require('cvox.KeyMap');
|
| goog.require('cvox.KeySequence');
|
| goog.require('cvox.KeyUtil');
|
| goog.require('cvox.SimpleKeyEvent');
|
|
|
| /**
|
| + * @param {boolean=} opt_active Whether compatibility is currently active.
|
| * @constructor
|
| */
|
| -var ClassicCompatibility = function() {
|
| +var ClassicCompatibility = function(opt_active) {
|
| + /** @type {boolean} */
|
| + this.active = !!opt_active;
|
| +
|
| /**
|
| * @type {!Array<{description: string, name: string, shortcut: string}>}
|
| * @private
|
| @@ -40,66 +43,31 @@
|
| * @return {boolean} Whether the command was successfully processed.
|
| */
|
| onGotCommand: function(command) {
|
| - var evt = this.buildKeyEvent_(command);
|
| - if (!evt)
|
| + if (!this.active)
|
| return false;
|
| - this.simulateKeyDownNext_(evt);
|
| - return true;
|
| - },
|
|
|
| - /**
|
| - * Processes a ChromeVox Next command while in CLASSIC mode.
|
| - * @param {string} command
|
| - * @return {boolean} Whether the command was successfully processed.
|
| - */
|
| - onGotClassicCommand: function(command) {
|
| - var evt = this.buildKeyEvent_(command);
|
| - if (!evt)
|
| - return false;
|
| - this.simulateKeyDownClassic_(evt);
|
| - return true;
|
| - },
|
| -
|
| - /**
|
| - * @param {string} command
|
| - * @return {cvox.SimpleKeyEvent?}
|
| - */
|
| - buildKeyEvent_: function(command) {
|
| var commandInfo = this.commands_.filter(function(c) {
|
| return c.name == command;
|
| }.bind(this))[0];
|
| if (!commandInfo)
|
| - return null;
|
| + return false;
|
| var shortcut = commandInfo.shortcut;
|
| - return this.convertCommandShortcutToKeyEvent_(shortcut);
|
| + var evt = this.convertCommandShortcutToKeyEvent_(shortcut);
|
| + this.simulateKeyDown_(evt);
|
| + return true;
|
| },
|
|
|
| /**
|
| * @param {cvox.SimpleKeyEvent} evt
|
| * @private
|
| */
|
| - simulateKeyDownNext_: function(evt) {
|
| + simulateKeyDown_: function(evt) {
|
| var keySequence = cvox.KeyUtil.keyEventToKeySequence(evt);
|
| var classicCommand = this.keyMap.commandForKey(keySequence);
|
| if (classicCommand) {
|
| var nextCommand = this.getNextCommand_(classicCommand);
|
| if (nextCommand)
|
| global.backgroundObj.onGotCommand(nextCommand, true);
|
| - }
|
| - },
|
| -
|
| - /**
|
| - * @param {cvox.SimpleKeyEvent} evt
|
| - * @private
|
| - */
|
| - simulateKeyDownClassic_: function(evt) {
|
| - var keySequence = cvox.KeyUtil.keyEventToKeySequence(evt);
|
| - var classicCommand = this.keyMap.commandForKey(keySequence);
|
| - if (classicCommand) {
|
| - cvox.ExtensionBridge.send({
|
| - 'message': 'USER_COMMAND',
|
| - 'command': classicCommand
|
| - });
|
| }
|
| },
|
|
|
|
|