Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview The entry point for all ChromeVox2 related code for the | 6 * @fileoverview The entry point for all ChromeVox2 related code for the |
| 7 * background page. | 7 * background page. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 goog.provide('Background'); | 10 goog.provide('Background'); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 this.liveRegions_ = new LiveRegions(this); | 133 this.liveRegions_ = new LiveRegions(this); |
| 134 | 134 |
| 135 /** @type {number} @private */ | 135 /** @type {number} @private */ |
| 136 this.passThroughKeyUpCount_ = 0; | 136 this.passThroughKeyUpCount_ = 0; |
| 137 | 137 |
| 138 /** @type {boolean} @private */ | 138 /** @type {boolean} @private */ |
| 139 this.inExcursion_ = false; | 139 this.inExcursion_ = false; |
| 140 | 140 |
| 141 if (!chrome.accessibilityPrivate.setKeyboardListener) | 141 if (!chrome.accessibilityPrivate.setKeyboardListener) |
| 142 chrome.accessibilityPrivate.setKeyboardListener = function() {}; | 142 chrome.accessibilityPrivate.setKeyboardListener = function() {}; |
| 143 | |
| 144 if (cvox.ChromeVox.isChromeOS) { | |
| 145 chrome.accessibilityPrivate.onAccessibilityGesture.addListener( | |
| 146 this.onAccessibilityGesture_); | |
| 147 } | |
| 143 }; | 148 }; |
| 144 | 149 |
| 145 /** | 150 /** |
| 146 * @const {string} | 151 * @const {string} |
| 147 */ | 152 */ |
| 148 Background.ISSUE_URL = 'https://code.google.com/p/chromium/issues/entry?' + | 153 Background.ISSUE_URL = 'https://code.google.com/p/chromium/issues/entry?' + |
| 149 'labels=Type-Bug,Pri-2,cvox2,OS-Chrome&' + | 154 'labels=Type-Bug,Pri-2,cvox2,OS-Chrome&' + |
| 150 'components=UI>accessibility&' + | 155 'components=UI>accessibility&' + |
| 151 'description='; | 156 'description='; |
| 152 | 157 |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 this.restoreCurrentRange_(); | 990 this.restoreCurrentRange_(); |
| 986 }, | 991 }, |
| 987 | 992 |
| 988 /** | 993 /** |
| 989 * Move ChromeVox back to the last saved range. | 994 * Move ChromeVox back to the last saved range. |
| 990 */ | 995 */ |
| 991 saveExcursion: function() { | 996 saveExcursion: function() { |
| 992 this.savedRange_ = | 997 this.savedRange_ = |
| 993 new cursors.Range(this.currentRange_.start, this.currentRange_.end); | 998 new cursors.Range(this.currentRange_.start, this.currentRange_.end); |
| 994 }, | 999 }, |
| 1000 | |
| 1001 /** | |
| 1002 * Handles accessibility gestures from the touch screen. | |
| 1003 * @param {string} gesture The gesture to handle, based on the AXGesture enum | |
| 1004 * defined in ui/accessibility/ax_enums.idl | |
| 1005 * @private | |
| 1006 */ | |
| 1007 onAccessibilityGesture_: function(gesture) { | |
| 1008 console.error('Gesture: ' + gesture); | |
|
David Tseng
2016/05/05 22:30:39
nit: remove
dmazzoni
2016/05/06 19:06:09
Done.
| |
| 1009 | |
| 1010 if (this.mode_ == ChromeVoxMode.CLASSIC) { | |
| 1011 if (this.handleClassicGesture_(gesture)) | |
| 1012 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
| |
| 1013 } | |
|
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
| |
| 1014 | |
| 1015 var command; | |
| 1016 switch (gesture) { | |
| 1017 case 'swipeUp1': command = 'previousLine'; break; | |
| 1018 case 'swipeDown1': command = 'nextLine'; break; | |
| 1019 case 'swipeLeft1': command = 'previousObject'; break; | |
| 1020 case 'swipeRight1': command = 'nextObject'; break; | |
| 1021 case 'swipeUp2': command = 'jumpToTop'; break; | |
| 1022 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.
| |
| 1023 } | |
|
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
| |
| 1024 | |
| 1025 console.error('Gesture command: ' + command); | |
|
David Tseng
2016/05/05 22:30:39
nit: remove
dmazzoni
2016/05/06 19:06:09
Done.
| |
| 1026 | |
| 1027 if (command) | |
| 1028 this.onGotCommand(command); | |
| 1029 }, | |
| 1030 | |
| 1031 /** | |
| 1032 * Handles accessibility gestures from the touch screen when in CLASSIC | |
| 1033 * mode, by forwarding a command to the content script. | |
| 1034 * @param {string} gesture The gesture to handle, based on the AXGesture enum | |
| 1035 * defined in ui/accessibility/ax_enums.idl | |
| 1036 * @return {boolean} True if this gesture was handled. | |
| 1037 * @private | |
| 1038 */ | |
| 1039 handleClassicGesture_: function(gesture) { | |
| 1040 var command; | |
| 1041 switch (gesture) { | |
| 1042 case 'swipeUp1': command = 'backward'; break; | |
| 1043 case 'swipeDown1': command = 'forward'; break; | |
| 1044 case 'swipeLeft1': command = 'left'; break; | |
| 1045 case 'swipeRight1': command = 'right'; break; | |
| 1046 case 'swipeUp2': command = 'jumpToTop'; break; | |
| 1047 case 'swipeDown2': command = 'jumpToBottom'; break; | |
|
David Tseng
2016/05/05 22:30:39
Ditto; readFromHere.
dmazzoni
2016/05/06 19:06:08
Done.
| |
| 1048 } | |
| 1049 | |
| 1050 if (!command) | |
| 1051 return false; | |
| 1052 | |
| 1053 | |
|
David Tseng
2016/05/05 22:30:39
nit: extra line
dmazzoni
2016/05/06 19:06:09
Done.
| |
| 1054 var msg = { | |
| 1055 'message': 'USER_COMMAND', | |
| 1056 'command': command | |
| 1057 }; | |
| 1058 cvox.ExtensionBridge.send(msg); | |
| 1059 return true; | |
| 1060 }, | |
| 995 }; | 1061 }; |
| 996 | 1062 |
| 997 /** | 1063 /** |
| 998 * Converts a list of globs, as used in the extension manifest, to a regular | 1064 * Converts a list of globs, as used in the extension manifest, to a regular |
| 999 * expression that matches if and only if any of the globs in the list matches. | 1065 * expression that matches if and only if any of the globs in the list matches. |
| 1000 * @param {!Array<string>} globs | 1066 * @param {!Array<string>} globs |
| 1001 * @return {!RegExp} | 1067 * @return {!RegExp} |
| 1002 * @private | 1068 * @private |
| 1003 */ | 1069 */ |
| 1004 Background.globsToRegExp_ = function(globs) { | 1070 Background.globsToRegExp_ = function(globs) { |
| 1005 return new RegExp('^(' + globs.map(function(glob) { | 1071 return new RegExp('^(' + globs.map(function(glob) { |
| 1006 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 1072 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 1007 .replace(/\*/g, '.*') | 1073 .replace(/\*/g, '.*') |
| 1008 .replace(/\?/g, '.'); | 1074 .replace(/\?/g, '.'); |
| 1009 }).join('|') + ')$'); | 1075 }).join('|') + ')$'); |
| 1010 }; | 1076 }; |
| 1011 | 1077 |
| 1012 /** @type {Background} */ | 1078 /** @type {Background} */ |
| 1013 global.backgroundObj = new Background(); | 1079 global.backgroundObj = new Background(); |
| 1014 | 1080 |
| 1015 }); // goog.scope | 1081 }); // goog.scope |
| OLD | NEW |