Commit f72134ae authored by dtseng's avatar dtseng Committed by Commit bot

Eat all keys involving Search when ChromeVox is on and add a pass through mode command.

In ChromeVox Next, Search+Shift+Esc activates pass through mode. The subsequent key will be passed through directly to the system. In particular, the key needs to be a ChromeVox command. For example, Search+Shift+Esc followed by any number of key (e.g. Ctrl+L), then ended by Search+L would result in the screen locking since the passed through key is the last ChromeVox command.

This cl also makes all key events involving Search captured.

TEST=hit Search+L. Verify the key gets eaten (no screen lock) and ChromeVox tries to move to the next link.
Press Search+Shift+Esc; then Search+L. Verify screen locks.
Do the same with sticky mode on. Double tap Search. Press Shift+Esc. Verify pass through activates. Press Search+L and see that screen locks.

Review URL: https://codereview.chromium.org/1636243002

Cr-Commit-Position: refs/heads/master@{#372205}
parent 41c0b663
...@@ -53,6 +53,9 @@ bool SpokenFeedbackEventRewriterDelegate::DispatchKeyEventToChromeVox( ...@@ -53,6 +53,9 @@ bool SpokenFeedbackEventRewriterDelegate::DispatchKeyEventToChromeVox(
content::RenderViewHost* rvh = host->render_view_host(); content::RenderViewHost* rvh = host->render_view_host();
// Always capture the Search key.
capture |= key_event.IsCommandDown();
// Listen for any unhandled keyboard events from ChromeVox's background page // Listen for any unhandled keyboard events from ChromeVox's background page
// when capturing keys to reinject. // when capturing keys to reinject.
if (capture) if (capture)
......
...@@ -339,6 +339,16 @@ ...@@ -339,6 +339,16 @@
}, },
"platformFilter": 10 "platformFilter": 10
} }
},
{
"command": "passThroughMode",
"sequence": {
"cvoxModifier": true,
"keys": {
"keyCode": [27],
"shiftKey": [true]
}
}
} }
] ]
} }
...@@ -116,6 +116,7 @@ Background = function() { ...@@ -116,6 +116,7 @@ Background = function() {
cvox.ExtensionBridge.addMessageListener(this.onMessage_); cvox.ExtensionBridge.addMessageListener(this.onMessage_);
document.addEventListener('keydown', this.onKeyDown.bind(this), true); document.addEventListener('keydown', this.onKeyDown.bind(this), true);
document.addEventListener('keyup', this.onKeyUp.bind(this), true);
cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this); cvox.ChromeVoxKbHandler.commandHandler = this.onGotCommand.bind(this);
// Classic keymap. // Classic keymap.
...@@ -124,6 +125,9 @@ Background = function() { ...@@ -124,6 +125,9 @@ Background = function() {
// Live region handler. // Live region handler.
this.liveRegions_ = new LiveRegions(this); this.liveRegions_ = new LiveRegions(this);
/** @type {number} @private */
this.passThroughKeyUpCount_ = 0;
if (!chrome.accessibilityPrivate.setKeyboardListener) if (!chrome.accessibilityPrivate.setKeyboardListener)
chrome.accessibilityPrivate.setKeyboardListener = function() {}; chrome.accessibilityPrivate.setKeyboardListener = function() {};
}; };
...@@ -476,6 +480,11 @@ Background.prototype = { ...@@ -476,6 +480,11 @@ Background.prototype = {
else else
chrome.accessibilityPrivate.setKeyboardListener(true, false); chrome.accessibilityPrivate.setKeyboardListener(true, false);
return false; return false;
case 'passThroughMode':
cvox.ChromeVox.passThroughMode = true;
cvox.ChromeVox.tts.speak(
Msgs.getMsg('pass_through_key'), cvox.QueueMode.QUEUE);
return true;
default: default:
return true; return true;
} }
...@@ -525,15 +534,35 @@ Background.prototype = { ...@@ -525,15 +534,35 @@ Background.prototype = {
*/ */
onKeyDown: function(evt) { onKeyDown: function(evt) {
evt.stickyMode = cvox.ChromeVox.isStickyModeOn() && cvox.ChromeVox.isActive; evt.stickyMode = cvox.ChromeVox.isStickyModeOn() && cvox.ChromeVox.isActive;
if (cvox.ChromeVox.passThroughMode)
return false;
if (this.mode_ != ChromeVoxMode.CLASSIC && if (this.mode_ != ChromeVoxMode.CLASSIC &&
!cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) { !cvox.ChromeVoxKbHandler.basicKeyDownActionsListener(evt)) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
} }
Output.flushNextSpeechUtterance(); Output.flushNextSpeechUtterance();
}, },
/**
* Handles key up events.
* @param {Event} evt The key down event to process.
* @return {boolean} True if the default action should be performed.
*/
onKeyUp: function(evt) {
// Reset pass through mode once a keyup (not involving the pass through key)
// is seen. The pass through command involves three keys.
if (cvox.ChromeVox.passThroughMode) {
if (this.passThroughKeyUpCount_ >= 3) {
cvox.ChromeVox.passThroughMode = false;
this.passThroughKeyUpCount_ = 0;
} else {
this.passThroughKeyUpCount_++;
}
}
},
/** /**
* Open the options page in a new tab. * Open the options page in a new tab.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment