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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 chrome.accessibilityPrivate.onAccessibilityGesture.addListener( | 168 chrome.accessibilityPrivate.onAccessibilityGesture.addListener( |
169 this.onAccessibilityGesture_); | 169 this.onAccessibilityGesture_); |
170 | 170 |
171 /** | 171 /** |
172 * Maps a non-desktop root automation node to a range position suitable for | 172 * Maps a non-desktop root automation node to a range position suitable for |
173 * restoration. | 173 * restoration. |
174 * @type {WeakMap<AutomationNode, cursors.Range>} | 174 * @type {WeakMap<AutomationNode, cursors.Range>} |
175 * @private | 175 * @private |
176 */ | 176 */ |
177 this.focusRecoveryMap_ = new WeakMap(); | 177 this.focusRecoveryMap_ = new WeakMap(); |
| 178 |
| 179 // Record a metric with the mode we're in on startup. |
| 180 var useNext = localStorage['useNext'] !== 'false'; |
| 181 chrome.metricsPrivate.recordValue( |
| 182 { metricName: 'Accessibility.CrosChromeVoxNext', |
| 183 type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 184 min: 1, // According to histogram.h, this should be 1 for enums. |
| 185 max: 2, // Maximum should be exclusive. |
| 186 buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2. |
| 187 useNext ? 1 : 0); |
178 }; | 188 }; |
179 | 189 |
180 /** | 190 /** |
181 * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl) | 191 * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl) |
182 * to commands when in Classic mode. | 192 * to commands when in Classic mode. |
183 * @type {Object<string, string>} | 193 * @type {Object<string, string>} |
184 * @const | 194 * @const |
185 */ | 195 */ |
186 Background.GESTURE_CLASSIC_COMMAND_MAP = { | 196 Background.GESTURE_CLASSIC_COMMAND_MAP = { |
187 'click': 'forceClickOnCurrentItem', | 197 'click': 'forceClickOnCurrentItem', |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 * classic/compat (false). | 352 * classic/compat (false). |
343 * @return {boolean} True to announce current position. | 353 * @return {boolean} True to announce current position. |
344 */ | 354 */ |
345 toggleNext: function(opt_setValue) { | 355 toggleNext: function(opt_setValue) { |
346 var useNext; | 356 var useNext; |
347 if (opt_setValue !== undefined) | 357 if (opt_setValue !== undefined) |
348 useNext = opt_setValue; | 358 useNext = opt_setValue; |
349 else | 359 else |
350 useNext = localStorage['useNext'] !== 'true'; | 360 useNext = localStorage['useNext'] !== 'true'; |
351 | 361 |
| 362 if (useNext) { |
| 363 chrome.metricsPrivate.recordUserAction( |
| 364 'Accessibility.ChromeVox.ToggleNextOn'); |
| 365 } else { |
| 366 chrome.metricsPrivate.recordUserAction( |
| 367 'Accessibility.ChromeVox.ToggleNextOff'); |
| 368 } |
| 369 |
352 localStorage['useNext'] = useNext; | 370 localStorage['useNext'] = useNext; |
353 if (useNext) | 371 if (useNext) |
354 this.setCurrentRangeToFocus_(); | 372 this.setCurrentRangeToFocus_(); |
355 else | 373 else |
356 this.setCurrentRange(null); | 374 this.setCurrentRange(null); |
357 | 375 |
358 var announce = Msgs.getMsg(useNext ? | 376 var announce = Msgs.getMsg(useNext ? |
359 'switch_to_next' : 'switch_to_classic'); | 377 'switch_to_next' : 'switch_to_classic'); |
360 cvox.ChromeVox.tts.speak( | 378 cvox.ChromeVox.tts.speak( |
361 announce, cvox.QueueMode.FLUSH, {doNotInterrupt: true}); | 379 announce, cvox.QueueMode.FLUSH, {doNotInterrupt: true}); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 return new RegExp('^(' + globs.map(function(glob) { | 845 return new RegExp('^(' + globs.map(function(glob) { |
828 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 846 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
829 .replace(/\*/g, '.*') | 847 .replace(/\*/g, '.*') |
830 .replace(/\?/g, '.'); | 848 .replace(/\?/g, '.'); |
831 }).join('|') + ')$'); | 849 }).join('|') + ')$'); |
832 }; | 850 }; |
833 | 851 |
834 new Background(); | 852 new Background(); |
835 | 853 |
836 }); // goog.scope | 854 }); // goog.scope |
OLD | NEW |