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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js

Issue 1953613002: Make touch accessibility gestures work with ChromeVox Next (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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
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
158 /**
159 * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl)
160 * to commands when in Classic mode.
161 * @type {Object<string, string>}
162 * @const
163 */
164 Background.GESTURE_CLASSIC_COMMAND_MAP = {
165 'swipeUp1': 'backward',
166 'swipeDown1': 'forward',
167 'swipeLeft1': 'left',
168 'swipeRight1': 'right',
169 'swipeUp2': 'jumpToTop',
170 'swipeDown2': 'readFromhere',
171 };
172
173 /**
174 * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl)
175 * to commands when in Classic mode.
176 * @type {Object<string, string>}
177 * @const
178 */
179 Background.GESTURE_NEXT_COMMAND_MAP = {
180 'swipeUp1': 'previousLine',
181 'swipeDown1': 'nextLine',
182 'swipeLeft1': 'previousObject',
183 'swipeRight1': 'nextObject',
184 'swipeUp2': 'jumpToTop',
185 'swipeDown2': 'readFromHere',
186 };
187
153 Background.prototype = { 188 Background.prototype = {
154 __proto__: ChromeVoxState.prototype, 189 __proto__: ChromeVoxState.prototype,
155 190
156 /** 191 /**
157 * @override 192 * @override
158 */ 193 */
159 getMode: function() { 194 getMode: function() {
160 return this.mode_; 195 return this.mode_;
161 }, 196 },
162 197
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 this.restoreCurrentRange_(); 1020 this.restoreCurrentRange_();
986 }, 1021 },
987 1022
988 /** 1023 /**
989 * Move ChromeVox back to the last saved range. 1024 * Move ChromeVox back to the last saved range.
990 */ 1025 */
991 saveExcursion: function() { 1026 saveExcursion: function() {
992 this.savedRange_ = 1027 this.savedRange_ =
993 new cursors.Range(this.currentRange_.start, this.currentRange_.end); 1028 new cursors.Range(this.currentRange_.start, this.currentRange_.end);
994 }, 1029 },
1030
1031 /**
1032 * Handles accessibility gestures from the touch screen.
1033 * @param {string} gesture The gesture to handle, based on the AXGesture enum
1034 * defined in ui/accessibility/ax_enums.idl
1035 * @private
1036 */
1037 onAccessibilityGesture_: function(gesture) {
1038 // If we're in classic mode, some gestures need to be handled by the
1039 // content script. Other gestures are universal and will be handled in
1040 // this function.
1041 if (this.mode_ == ChromeVoxMode.CLASSIC) {
1042 if (this.handleClassicGesture_(gesture))
1043 return;
1044 }
1045
1046 var command = Background.GESTURE_NEXT_COMMAND_MAP[gesture];
1047 if (command)
1048 this.onGotCommand(command);
1049 },
1050
1051 /**
1052 * Handles accessibility gestures from the touch screen when in CLASSIC
1053 * mode, by forwarding a command to the content script.
1054 * @param {string} gesture The gesture to handle, based on the AXGesture enum
1055 * defined in ui/accessibility/ax_enums.idl
1056 * @return {boolean} True if this gesture was handled.
1057 * @private
1058 */
1059 handleClassicGesture_: function(gesture) {
1060 var command = Background.GESTURE_CLASSIC_COMMAND_MAP[gesture];
1061 if (!command)
1062 return false;
1063
1064 var msg = {
1065 'message': 'USER_COMMAND',
1066 'command': command
1067 };
1068 cvox.ExtensionBridge.send(msg);
1069 return true;
1070 },
995 }; 1071 };
996 1072
997 /** 1073 /**
998 * Converts a list of globs, as used in the extension manifest, to a regular 1074 * 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. 1075 * expression that matches if and only if any of the globs in the list matches.
1000 * @param {!Array<string>} globs 1076 * @param {!Array<string>} globs
1001 * @return {!RegExp} 1077 * @return {!RegExp}
1002 * @private 1078 * @private
1003 */ 1079 */
1004 Background.globsToRegExp_ = function(globs) { 1080 Background.globsToRegExp_ = function(globs) {
1005 return new RegExp('^(' + globs.map(function(glob) { 1081 return new RegExp('^(' + globs.map(function(glob) {
1006 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') 1082 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&')
1007 .replace(/\*/g, '.*') 1083 .replace(/\*/g, '.*')
1008 .replace(/\?/g, '.'); 1084 .replace(/\?/g, '.');
1009 }).join('|') + ')$'); 1085 }).join('|') + ')$');
1010 }; 1086 };
1011 1087
1012 /** @type {Background} */ 1088 /** @type {Background} */
1013 global.backgroundObj = new Background(); 1089 global.backgroundObj = new Background();
1014 1090
1015 }); // goog.scope 1091 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698