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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js

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

Powered by Google App Engine
This is Rietveld 408576698