Chromium Code Reviews| 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 9583ece160470b68c050a698335651e00d982f19..90d9431633aeb1886dd8ffedaaf3fb2c16cbad32 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_); |
| + } |
| }; |
| /** |
| @@ -992,6 +997,67 @@ 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) { |
| + console.error('Gesture: ' + gesture); |
|
David Tseng
2016/05/05 22:30:39
nit: remove
dmazzoni
2016/05/06 19:06:09
Done.
|
| + |
| + if (this.mode_ == ChromeVoxMode.CLASSIC) { |
| + if (this.handleClassicGesture_(gesture)) |
| + return; |
|
David Tseng
2016/05/05 22:30:39
Are you going to allow for unhandled gestures?
dmazzoni
2016/05/06 19:06:09
Yes, it should return true if it shouldn't continu
|
| + } |
|
David Tseng
2016/05/05 22:30:39
Is this meant to fall through?
dmazzoni
2016/05/06 19:06:09
Yes, my thought was that some gestures might be un
|
| + |
| + var command; |
| + switch (gesture) { |
| + case 'swipeUp1': command = 'previousLine'; break; |
| + case 'swipeDown1': command = 'nextLine'; break; |
| + case 'swipeLeft1': command = 'previousObject'; break; |
| + case 'swipeRight1': command = 'nextObject'; break; |
| + case 'swipeUp2': command = 'jumpToTop'; break; |
| + case 'swipeDown2': command = 'jumpToBottom'; break; |
|
David Tseng
2016/05/05 22:30:39
This should be readFromHere
David Tseng
2016/05/05 22:30:39
Maybe just put these into an object dictionary?
dmazzoni
2016/05/06 19:06:08
Done.
dmazzoni
2016/05/06 19:06:08
Done.
|
| + } |
|
David Tseng
2016/05/05 22:30:39
default?
dmazzoni
2016/05/06 19:06:09
What do you want the default handler to do? I thin
|
| + |
| + console.error('Gesture command: ' + command); |
|
David Tseng
2016/05/05 22:30:39
nit: remove
dmazzoni
2016/05/06 19:06:09
Done.
|
| + |
| + 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; |
| + switch (gesture) { |
| + case 'swipeUp1': command = 'backward'; break; |
| + case 'swipeDown1': command = 'forward'; break; |
| + case 'swipeLeft1': command = 'left'; break; |
| + case 'swipeRight1': command = 'right'; break; |
| + case 'swipeUp2': command = 'jumpToTop'; break; |
| + case 'swipeDown2': command = 'jumpToBottom'; break; |
|
David Tseng
2016/05/05 22:30:39
Ditto; readFromHere.
dmazzoni
2016/05/06 19:06:08
Done.
|
| + } |
| + |
| + if (!command) |
| + return false; |
| + |
| + |
|
David Tseng
2016/05/05 22:30:39
nit: extra line
dmazzoni
2016/05/06 19:06:09
Done.
|
| + var msg = { |
| + 'message': 'USER_COMMAND', |
| + 'command': command |
| + }; |
| + cvox.ExtensionBridge.send(msg); |
| + return true; |
| + }, |
| }; |
| /** |