Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6252)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js

Issue 1213513003: Revert of Support Compat mode inside of the desktop tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commands_alt
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
- });
}
},

Powered by Google App Engine
This is Rietveld 408576698