| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 this.onAccessibilityGesture_); | 161 this.onAccessibilityGesture_); |
| 162 | 162 |
| 163 /** | 163 /** |
| 164 * Maps a non-desktop root automation node to a range position suitable for | 164 * Maps a non-desktop root automation node to a range position suitable for |
| 165 * restoration. | 165 * restoration. |
| 166 * @type {WeakMap<AutomationNode, cursors.Range>} | 166 * @type {WeakMap<AutomationNode, cursors.Range>} |
| 167 * @private | 167 * @private |
| 168 */ | 168 */ |
| 169 this.focusRecoveryMap_ = new WeakMap(); | 169 this.focusRecoveryMap_ = new WeakMap(); |
| 170 | 170 |
| 171 chrome.automation.getDesktop(function(desktop) { |
| 172 /** @type {string} */ |
| 173 this.chromeChannel_ = desktop.chromeChannel; |
| 174 }.bind(this)); |
| 175 |
| 171 // Record a metric with the mode we're in on startup. | 176 // Record a metric with the mode we're in on startup. |
| 172 var useNext = localStorage['useNext'] !== 'false'; | 177 var useNext = localStorage['useNext'] !== 'false'; |
| 173 chrome.metricsPrivate.recordValue( | 178 chrome.metricsPrivate.recordValue( |
| 174 { metricName: 'Accessibility.CrosChromeVoxNext', | 179 { metricName: 'Accessibility.CrosChromeVoxNext', |
| 175 type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, | 180 type: chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 176 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. |
| 177 max: 2, // Maximum should be exclusive. | 182 max: 2, // Maximum should be exclusive. |
| 178 buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2. | 183 buckets: 3 }, // Number of buckets: 0, 1 and overflowing 2. |
| 179 useNext ? 1 : 0); | 184 useNext ? 1 : 0); |
| 180 }; | 185 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 206 'swipeUp1': 'previousLine', | 211 'swipeUp1': 'previousLine', |
| 207 'swipeDown1': 'nextLine', | 212 'swipeDown1': 'nextLine', |
| 208 'swipeLeft1': 'previousObject', | 213 'swipeLeft1': 'previousObject', |
| 209 'swipeRight1': 'nextObject', | 214 'swipeRight1': 'nextObject', |
| 210 'swipeUp2': 'jumpToTop', | 215 'swipeUp2': 'jumpToTop', |
| 211 'swipeDown2': 'readFromHere', | 216 'swipeDown2': 'readFromHere', |
| 212 }; | 217 }; |
| 213 | 218 |
| 214 Background.prototype = { | 219 Background.prototype = { |
| 215 __proto__: ChromeVoxState.prototype, | 220 __proto__: ChromeVoxState.prototype, |
| 221 |
| 216 /** | 222 /** |
| 217 * Maps the last node with range in a given root. | 223 * Maps the last node with range in a given root. |
| 218 * @type {WeakMap<AutomationNode>} | 224 * @type {WeakMap<AutomationNode>} |
| 219 */ | 225 */ |
| 220 get focusRecoveryMap() { | 226 get focusRecoveryMap() { |
| 221 return this.focusRecoveryMap_; | 227 return this.focusRecoveryMap_; |
| 222 }, | 228 }, |
| 223 | 229 |
| 224 /** | 230 /** |
| 225 * @override | 231 * @override |
| (...skipping 14 matching lines...) Expand all Loading... |
| 240 return useNext ? ChromeVoxMode.FORCE_NEXT : ChromeVoxMode.CLASSIC; | 246 return useNext ? ChromeVoxMode.FORCE_NEXT : ChromeVoxMode.CLASSIC; |
| 241 | 247 |
| 242 // Closure complains, but clearly, |target| is not null. | 248 // Closure complains, but clearly, |target| is not null. |
| 243 var topLevelRoot = | 249 var topLevelRoot = |
| 244 AutomationUtil.getTopLevelRoot(/** @type {!AutomationNode} */(target)); | 250 AutomationUtil.getTopLevelRoot(/** @type {!AutomationNode} */(target)); |
| 245 if (!topLevelRoot) | 251 if (!topLevelRoot) |
| 246 return useNext ? ChromeVoxMode.FORCE_NEXT : | 252 return useNext ? ChromeVoxMode.FORCE_NEXT : |
| 247 ChromeVoxMode.CLASSIC_COMPAT; | 253 ChromeVoxMode.CLASSIC_COMPAT; |
| 248 | 254 |
| 249 var nextSite = this.isWhitelistedForNext_(topLevelRoot.docUrl); | 255 var nextSite = this.isWhitelistedForNext_(topLevelRoot.docUrl); |
| 250 var nextCompat = this.nextCompatRegExp_.test(topLevelRoot.docUrl); | 256 var nextCompat = this.nextCompatRegExp_.test(topLevelRoot.docUrl) && |
| 257 this.chromeChannel_ != 'dev'; |
| 251 var classicCompat = | 258 var classicCompat = |
| 252 this.isWhitelistedForClassicCompat_(topLevelRoot.docUrl); | 259 this.isWhitelistedForClassicCompat_(topLevelRoot.docUrl); |
| 253 if (nextCompat && useNext) | 260 if (nextCompat && useNext) |
| 254 return ChromeVoxMode.NEXT_COMPAT; | 261 return ChromeVoxMode.NEXT_COMPAT; |
| 255 else if (classicCompat && !useNext) | 262 else if (classicCompat && !useNext) |
| 256 return ChromeVoxMode.CLASSIC_COMPAT; | 263 return ChromeVoxMode.CLASSIC_COMPAT; |
| 257 else if (nextSite) | 264 else if (nextSite) |
| 258 return ChromeVoxMode.NEXT; | 265 return ChromeVoxMode.NEXT; |
| 259 else if (!useNext) | 266 else if (!useNext) |
| 260 return ChromeVoxMode.CLASSIC; | 267 return ChromeVoxMode.CLASSIC; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 567 } |
| 561 return true; | 568 return true; |
| 562 }, | 569 }, |
| 563 | 570 |
| 564 /** | 571 /** |
| 565 * Returns true if the url should have Classic running. | 572 * Returns true if the url should have Classic running. |
| 566 * @return {boolean} | 573 * @return {boolean} |
| 567 * @private | 574 * @private |
| 568 */ | 575 */ |
| 569 shouldEnableClassicForUrl_: function(url) { | 576 shouldEnableClassicForUrl_: function(url) { |
| 570 return this.nextCompatRegExp_.test(url) || | 577 return (this.nextCompatRegExp_.test(url) &&this.chromeChannel_ != 'dev') || |
| 571 (this.mode != ChromeVoxMode.FORCE_NEXT && | 578 (this.mode != ChromeVoxMode.FORCE_NEXT && |
| 572 !this.isBlacklistedForClassic_(url) && | 579 !this.isBlacklistedForClassic_(url) && |
| 573 !this.isWhitelistedForNext_(url)); | 580 !this.isWhitelistedForNext_(url)); |
| 574 }, | 581 }, |
| 575 | 582 |
| 576 /** | 583 /** |
| 577 * Compat mode is on if any of the following are true: | 584 * Compat mode is on if any of the following are true: |
| 578 * 1. a url is blacklisted for Classic. | 585 * 1. a url is blacklisted for Classic. |
| 579 * 2. the current range is not within web content. | 586 * 2. the current range is not within web content. |
| 580 * @param {string} url | 587 * @param {string} url |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 return new RegExp('^(' + globs.map(function(glob) { | 843 return new RegExp('^(' + globs.map(function(glob) { |
| 837 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 844 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 838 .replace(/\*/g, '.*') | 845 .replace(/\*/g, '.*') |
| 839 .replace(/\?/g, '.'); | 846 .replace(/\?/g, '.'); |
| 840 }).join('|') + ')$'); | 847 }).join('|') + ')$'); |
| 841 }; | 848 }; |
| 842 | 849 |
| 843 new Background(); | 850 new Background(); |
| 844 | 851 |
| 845 }); // goog.scope | 852 }); // goog.scope |
| OLD | NEW |