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

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: Fixes corner cases (liblouis callbacks sometimes drop when called quickly). 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager_test.extjs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c1d472b107b44f5d0b43642fb5d5931e9fb8be0c 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,21 @@ 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) {
+ if (brailleTable && brailleTable === this.defaultTableId_) {
+ return;
+ }
+
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,30 +119,13 @@ 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);
-
var newDefaultTableId = table.id;
var newUncontractedTableId = table.id === uncontractedTable.id ?
null : uncontractedTable.id;
@@ -200,7 +190,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));
},
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/chromevox/braille/braille_translator_manager_test.extjs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698