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

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

Issue 1191783002: Support Compat mode inside of the desktop tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commands_alt
Patch Set: Rebase. 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 dae832c0c9ca66b3e93f1cabf9b23e077e46777e..8259e05a2dd619a4b51dfd0461ad61c6f6630c05 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/classic_compatibility.js
@@ -9,19 +9,16 @@
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(opt_active) {
- /** @type {boolean} */
- this.active = !!opt_active;
-
+var ClassicCompatibility = function() {
/**
* @type {!Array<{description: string, name: string, shortcut: string}>}
* @private
@@ -43,25 +40,45 @@ ClassicCompatibility.prototype = {
* @return {boolean} Whether the command was successfully processed.
*/
onGotCommand: function(command) {
- if (!this.active)
+ var evt = this.buildKeyEvent_(command);
+ if (!evt)
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 false;
+ return null;
var shortcut = commandInfo.shortcut;
- var evt = this.convertCommandShortcutToKeyEvent_(shortcut);
- this.simulateKeyDown_(evt);
- return true;
+ return this.convertCommandShortcutToKeyEvent_(shortcut);
},
/**
* @param {cvox.SimpleKeyEvent} evt
* @private
*/
- simulateKeyDown_: function(evt) {
+ simulateKeyDownNext_: function(evt) {
var keySequence = cvox.KeyUtil.keyEventToKeySequence(evt);
var classicCommand = this.keyMap.commandForKey(keySequence);
if (classicCommand) {
@@ -72,6 +89,21 @@ ClassicCompatibility.prototype = {
},
/**
+ * @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
+ });
+ }
+ },
+
+ /**
* @param {string} shortcut
* @return {cvox.SimpleKeyEvent}
* @private

Powered by Google App Engine
This is Rietveld 408576698