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

Unified Diff: chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js

Issue 2813743002: Switch to selected 8-dot braille table in email and url text fields (Closed)
Patch Set: Address feedback. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
diff --git a/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js b/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
index 2a152b228372ae2e03701b77057e5dd1556c14f2..14e88ddf449c7713247dbb97a5c7b62ae76df75a 100644
--- a/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
+++ b/chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager.js
@@ -82,14 +82,17 @@ cvox.BrailleTranslatorManager.prototype = {
* Refreshes the braille translator(s) used for input and output. This
* should be called when something has changed (such as a preference) to
* make sure that the correct translator is used.
+ * @param {string} brailleTable The table for this translator to use.
+ * @param {string=} opt_brailleTable8 Optionally specify an uncontracted
+ * table.
*/
- refresh: function() {
+ refresh: function(brailleTable, opt_brailleTable8) {
var tables = this.tables_;
if (tables.length == 0)
return;
- // First, see if we have a braille table set previously.
- var table = cvox.BrailleTable.forId(tables, localStorage['brailleTable']);
+ // Look for the table requested.
+ var table = cvox.BrailleTable.forId(tables, brailleTable);
if (!table) {
// Match table against current locale.
var currentLocale = chrome.i18n.getMessage('@@ui_locale').split(/[_-]/);
@@ -112,27 +115,11 @@ cvox.BrailleTranslatorManager.prototype = {
if (!table)
table = cvox.BrailleTable.forId(tables, 'en-US-comp8');
- // TODO(plundblad): Only update when user explicitly selects a table
- // so that switching locales changes table by default. crbug.com/441206.
- localStorage['brailleTable'] = table.id;
- if (!localStorage['brailleTable6'])
- localStorage['brailleTable6'] = 'en-US-g1';
- if (!localStorage['brailleTable8'])
- localStorage['brailleTable8'] = 'en-US-comp8';
-
- if (table.dots == '6') {
- localStorage['brailleTableType'] = 'brailleTable6';
- localStorage['brailleTable6'] = table.id;
- } else {
- localStorage['brailleTableType'] = 'brailleTable8';
- localStorage['brailleTable8'] = table.id;
- }
-
// If the user explicitly set an 8 dot table, use that when looking
// for an uncontracted table. Otherwise, use the current table and let
// getUncontracted find an appropriate corresponding table.
- var table8Dot = cvox.BrailleTable.forId(tables,
- localStorage['brailleTable8']);
+ var table8Dot = opt_brailleTable8 ?
+ cvox.BrailleTable.forId(tables, opt_brailleTable8) : null;
var uncontractedTable = cvox.BrailleTable.getUncontracted(
tables, table8Dot || table);
@@ -200,7 +187,9 @@ cvox.BrailleTranslatorManager.prototype = {
fetchTables_: function() {
cvox.BrailleTable.getAll(function(tables) {
this.tables_ = tables;
- this.refresh();
+
+ // Initial refresh; set options from user preferences.
+ this.refresh(localStorage['brailleTable'], localStorage['brailleTable8']);
}.bind(this));
},

Powered by Google App Engine
This is Rietveld 408576698