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

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: Rebase 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 this.restoreCurrentRange_(); 1043 this.restoreCurrentRange_();
1009 }, 1044 },
1010 1045
1011 /** 1046 /**
1012 * Move ChromeVox back to the last saved range. 1047 * Move ChromeVox back to the last saved range.
1013 */ 1048 */
1014 saveExcursion: function() { 1049 saveExcursion: function() {
1015 this.savedRange_ = 1050 this.savedRange_ =
1016 new cursors.Range(this.currentRange_.start, this.currentRange_.end); 1051 new cursors.Range(this.currentRange_.start, this.currentRange_.end);
1017 }, 1052 },
1053
1054 /**
1055 * Handles accessibility gestures from the touch screen.
1056 * @param {string} gesture The gesture to handle, based on the AXGesture enum
1057 * defined in ui/accessibility/ax_enums.idl
1058 * @private
1059 */
1060 onAccessibilityGesture_: function(gesture) {
1061 // If we're in classic mode, some gestures need to be handled by the
1062 // content script. Other gestures are universal and will be handled in
1063 // this function.
1064 if (this.mode_ == ChromeVoxMode.CLASSIC) {
1065 if (this.handleClassicGesture_(gesture))
1066 return;
1067 }
1068
1069 var command = Background.GESTURE_NEXT_COMMAND_MAP[gesture];
1070 if (command)
1071 this.onGotCommand(command);
1072 },
1073
1074 /**
1075 * Handles accessibility gestures from the touch screen when in CLASSIC
1076 * mode, by forwarding a command to the content script.
1077 * @param {string} gesture The gesture to handle, based on the AXGesture enum
1078 * defined in ui/accessibility/ax_enums.idl
1079 * @return {boolean} True if this gesture was handled.
1080 * @private
1081 */
1082 handleClassicGesture_: function(gesture) {
1083 var command = Background.GESTURE_CLASSIC_COMMAND_MAP[gesture];
1084 if (!command)
1085 return false;
1086
1087 var msg = {
1088 'message': 'USER_COMMAND',
1089 'command': command
1090 };
1091 cvox.ExtensionBridge.send(msg);
1092 return true;
1093 },
1018 }; 1094 };
1019 1095
1020 /** 1096 /**
1021 * Converts a list of globs, as used in the extension manifest, to a regular 1097 * Converts a list of globs, as used in the extension manifest, to a regular
1022 * expression that matches if and only if any of the globs in the list matches. 1098 * expression that matches if and only if any of the globs in the list matches.
1023 * @param {!Array<string>} globs 1099 * @param {!Array<string>} globs
1024 * @return {!RegExp} 1100 * @return {!RegExp}
1025 * @private 1101 * @private
1026 */ 1102 */
1027 Background.globsToRegExp_ = function(globs) { 1103 Background.globsToRegExp_ = function(globs) {
1028 return new RegExp('^(' + globs.map(function(glob) { 1104 return new RegExp('^(' + globs.map(function(glob) {
1029 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') 1105 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&')
1030 .replace(/\*/g, '.*') 1106 .replace(/\*/g, '.*')
1031 .replace(/\?/g, '.'); 1107 .replace(/\?/g, '.');
1032 }).join('|') + ')$'); 1108 }).join('|') + ')$');
1033 }; 1109 };
1034 1110
1035 /** @type {Background} */ 1111 /** @type {Background} */
1036 global.backgroundObj = new Background(); 1112 global.backgroundObj = new Background();
1037 1113
1038 }); // goog.scope 1114 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698