| 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('ChromeVox.ToggleNextOn'); |
| 364 } else { |
| 365 chrome.metricsPrivate.recordUserAction('ChromeVox.ToggleNextOff'); |
| 366 } |
| 367 |
| 352 localStorage['useNext'] = useNext; | 368 localStorage['useNext'] = useNext; |
| 353 if (useNext) | 369 if (useNext) |
| 354 this.setCurrentRangeToFocus_(); | 370 this.setCurrentRangeToFocus_(); |
| 355 else | 371 else |
| 356 this.setCurrentRange(null); | 372 this.setCurrentRange(null); |
| 357 | 373 |
| 358 var announce = Msgs.getMsg(useNext ? | 374 var announce = Msgs.getMsg(useNext ? |
| 359 'switch_to_next' : 'switch_to_classic'); | 375 'switch_to_next' : 'switch_to_classic'); |
| 360 cvox.ChromeVox.tts.speak( | 376 cvox.ChromeVox.tts.speak( |
| 361 announce, cvox.QueueMode.FLUSH, {doNotInterrupt: true}); | 377 announce, cvox.QueueMode.FLUSH, {doNotInterrupt: true}); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 return new RegExp('^(' + globs.map(function(glob) { | 841 return new RegExp('^(' + globs.map(function(glob) { |
| 826 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 842 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 827 .replace(/\*/g, '.*') | 843 .replace(/\*/g, '.*') |
| 828 .replace(/\?/g, '.'); | 844 .replace(/\?/g, '.'); |
| 829 }).join('|') + ')$'); | 845 }).join('|') + ')$'); |
| 830 }; | 846 }; |
| 831 | 847 |
| 832 new Background(); | 848 new Background(); |
| 833 | 849 |
| 834 }); // goog.scope | 850 }); // goog.scope |
| OLD | NEW |