| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 * @private | 167 * @private |
| 168 */ | 168 */ |
| 169 this.focusRecoveryMap_ = new WeakMap(); | 169 this.focusRecoveryMap_ = new WeakMap(); |
| 170 | 170 |
| 171 chrome.automation.getDesktop(function(desktop) { | 171 chrome.automation.getDesktop(function(desktop) { |
| 172 /** @type {string} */ | 172 /** @type {string} */ |
| 173 this.chromeChannel_ = desktop.chromeChannel; | 173 this.chromeChannel_ = desktop.chromeChannel; |
| 174 }.bind(this)); | 174 }.bind(this)); |
| 175 | 175 |
| 176 // Record a metric with the mode we're in on startup. | 176 // Record a metric with the mode we're in on startup. |
| 177 var useNext = localStorage['useNext'] !== 'false'; | 177 var useNext = localStorage['useClassic'] != 'true'; |
| 178 chrome.metricsPrivate.recordValue( | 178 chrome.metricsPrivate.recordValue( |
| 179 { metricName: 'Accessibility.CrosChromeVoxNext', | 179 { metricName: 'Accessibility.CrosChromeVoxNext', |
| 180 type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, | 180 type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 181 min: 1, // According to histogram.h, this should be 1 for enums. | 181 min: 1, // According to histogram.h, this should be 1 for enums. |
| 182 max: 2, // Maximum should be exclusive. | 182 max: 2, // Maximum should be exclusive. |
| 183 buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2. | 183 buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2. |
| 184 useNext ? 1 : 0); | 184 useNext ? 1 : 0); |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 /** | 187 /** |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 * @type {WeakMap<AutomationNode>} | 224 * @type {WeakMap<AutomationNode>} |
| 225 */ | 225 */ |
| 226 get focusRecoveryMap() { | 226 get focusRecoveryMap() { |
| 227 return this.focusRecoveryMap_; | 227 return this.focusRecoveryMap_; |
| 228 }, | 228 }, |
| 229 | 229 |
| 230 /** | 230 /** |
| 231 * @override | 231 * @override |
| 232 */ | 232 */ |
| 233 getMode: function() { | 233 getMode: function() { |
| 234 var useNext = localStorage['useNext'] !== 'false'; | 234 var useNext = localStorage['useClassic'] !== 'true'; |
| 235 | 235 |
| 236 var target; | 236 var target; |
| 237 if (!this.getCurrentRange()) { | 237 if (!this.getCurrentRange()) { |
| 238 chrome.automation.getFocus(function(focus) { | 238 chrome.automation.getFocus(function(focus) { |
| 239 target = focus; | 239 target = focus; |
| 240 }); | 240 }); |
| 241 } else { | 241 } else { |
| 242 target = this.getCurrentRange().start.node; | 242 target = this.getCurrentRange().start.node; |
| 243 } | 243 } |
| 244 | 244 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 * the start of the current range. | 349 * the start of the current range. |
| 350 * @param {boolean=} opt_setValue Directly set to force next (true) or | 350 * @param {boolean=} opt_setValue Directly set to force next (true) or |
| 351 * classic/compat (false). | 351 * classic/compat (false). |
| 352 * @return {boolean} True to announce current position. | 352 * @return {boolean} True to announce current position. |
| 353 */ | 353 */ |
| 354 toggleNext: function(opt_setValue) { | 354 toggleNext: function(opt_setValue) { |
| 355 var useNext; | 355 var useNext; |
| 356 if (opt_setValue !== undefined) | 356 if (opt_setValue !== undefined) |
| 357 useNext = opt_setValue; | 357 useNext = opt_setValue; |
| 358 else | 358 else |
| 359 useNext = localStorage['useNext'] !== 'true'; | 359 useNext = localStorage['useClassic'] == 'true'; |
| 360 | 360 |
| 361 if (useNext) { | 361 if (useNext) { |
| 362 chrome.metricsPrivate.recordUserAction( | 362 chrome.metricsPrivate.recordUserAction( |
| 363 'Accessibility.ChromeVox.ToggleNextOn'); | 363 'Accessibility.ChromeVox.ToggleNextOn'); |
| 364 } else { | 364 } else { |
| 365 chrome.metricsPrivate.recordUserAction( | 365 chrome.metricsPrivate.recordUserAction( |
| 366 'Accessibility.ChromeVox.ToggleNextOff'); | 366 'Accessibility.ChromeVox.ToggleNextOff'); |
| 367 } | 367 } |
| 368 | 368 |
| 369 localStorage['useNext'] = useNext; | 369 localStorage['useClassic'] = !useNext; |
| 370 if (useNext) | 370 if (useNext) |
| 371 this.setCurrentRangeToFocus_(); | 371 this.setCurrentRangeToFocus_(); |
| 372 else | 372 else |
| 373 this.setCurrentRange(null); | 373 this.setCurrentRange(null); |
| 374 | 374 |
| 375 var announce = Msgs.getMsg(useNext ? | 375 var announce = Msgs.getMsg(useNext ? |
| 376 'switch_to_next' : 'switch_to_classic'); | 376 'switch_to_next' : 'switch_to_classic'); |
| 377 cvox.ChromeVox.tts.speak( | 377 cvox.ChromeVox.tts.speak( |
| 378 announce, cvox.QueueMode.FLUSH, {doNotInterrupt: true}); | 378 announce, cvox.QueueMode.FLUSH, {doNotInterrupt: true}); |
| 379 | 379 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 return new RegExp('^(' + globs.map(function(glob) { | 843 return new RegExp('^(' + globs.map(function(glob) { |
| 844 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 844 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 845 .replace(/\*/g, '.*') | 845 .replace(/\*/g, '.*') |
| 846 .replace(/\?/g, '.'); | 846 .replace(/\?/g, '.'); |
| 847 }).join('|') + ')$'); | 847 }).join('|') + ')$'); |
| 848 }; | 848 }; |
| 849 | 849 |
| 850 new Background(); | 850 new Background(); |
| 851 | 851 |
| 852 }); // goog.scope | 852 }); // goog.scope |
| OLD | NEW |