Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
index ffcf394d5830f59385781d7f78cabd8aaa8d6124..8a38cab8557e04ce40e88c567d371da44b0f12a7 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
@@ -140,6 +140,11 @@ Background = function() { |
if (!chrome.accessibilityPrivate.setKeyboardListener) |
chrome.accessibilityPrivate.setKeyboardListener = function() {}; |
+ |
+ if (cvox.ChromeVox.isChromeOS) { |
+ chrome.accessibilityPrivate.onAccessibilityGesture.addListener( |
+ this.onAccessibilityGesture_); |
+ } |
}; |
/** |
@@ -150,6 +155,36 @@ Background.ISSUE_URL = 'https://code.google.com/p/chromium/issues/entry?' + |
'components=UI>accessibility&' + |
'description='; |
+/** |
+ * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl) |
+ * to commands when in Classic mode. |
+ * @type {Object<string, string>} |
+ * @const |
+ */ |
+Background.GESTURE_CLASSIC_COMMAND_MAP = { |
+ 'swipeUp1': 'backward', |
+ 'swipeDown1': 'forward', |
+ 'swipeLeft1': 'left', |
+ 'swipeRight1': 'right', |
+ 'swipeUp2': 'jumpToTop', |
+ 'swipeDown2': 'readFromhere', |
+}; |
+ |
+/** |
+ * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl) |
+ * to commands when in Classic mode. |
+ * @type {Object<string, string>} |
+ * @const |
+ */ |
+Background.GESTURE_NEXT_COMMAND_MAP = { |
+ 'swipeUp1': 'previousLine', |
+ 'swipeDown1': 'nextLine', |
+ 'swipeLeft1': 'previousObject', |
+ 'swipeRight1': 'nextObject', |
+ 'swipeUp2': 'jumpToTop', |
+ 'swipeDown2': 'readFromHere', |
+}; |
+ |
Background.prototype = { |
__proto__: ChromeVoxState.prototype, |
@@ -1015,6 +1050,47 @@ Background.prototype = { |
this.savedRange_ = |
new cursors.Range(this.currentRange_.start, this.currentRange_.end); |
}, |
+ |
+ /** |
+ * Handles accessibility gestures from the touch screen. |
+ * @param {string} gesture The gesture to handle, based on the AXGesture enum |
+ * defined in ui/accessibility/ax_enums.idl |
+ * @private |
+ */ |
+ onAccessibilityGesture_: function(gesture) { |
+ // If we're in classic mode, some gestures need to be handled by the |
+ // content script. Other gestures are universal and will be handled in |
+ // this function. |
+ if (this.mode_ == ChromeVoxMode.CLASSIC) { |
+ if (this.handleClassicGesture_(gesture)) |
+ return; |
+ } |
+ |
+ var command = Background.GESTURE_NEXT_COMMAND_MAP[gesture]; |
+ if (command) |
+ this.onGotCommand(command); |
+ }, |
+ |
+ /** |
+ * Handles accessibility gestures from the touch screen when in CLASSIC |
+ * mode, by forwarding a command to the content script. |
+ * @param {string} gesture The gesture to handle, based on the AXGesture enum |
+ * defined in ui/accessibility/ax_enums.idl |
+ * @return {boolean} True if this gesture was handled. |
+ * @private |
+ */ |
+ handleClassicGesture_: function(gesture) { |
+ var command = Background.GESTURE_CLASSIC_COMMAND_MAP[gesture]; |
+ if (!command) |
+ return false; |
+ |
+ var msg = { |
+ 'message': 'USER_COMMAND', |
+ 'command': command |
+ }; |
+ cvox.ExtensionBridge.send(msg); |
+ return true; |
+ }, |
}; |
/** |