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

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

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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 Common page for reading and writing preferences from 6 * @fileoverview Common page for reading and writing preferences from
7 * the background context (background page or options page). 7 * the background context (background page or options page).
8 * 8 *
9 */ 9 */
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 'audioStrategy': 'audioNormal', 63 'audioStrategy': 'audioNormal',
64 'autoRead': false, 64 'autoRead': false,
65 'brailleCaptions': false, 65 'brailleCaptions': false,
66 'brailleSideBySide': true, 66 'brailleSideBySide': true,
67 'brailleTableType': 'brailleTable8', 67 'brailleTableType': 'brailleTable8',
68 'brailleTable6': 'en-UEB-g2', 68 'brailleTable6': 'en-UEB-g2',
69 'brailleTable8': 'en-US-comp8', 69 'brailleTable8': 'en-US-comp8',
70 // TODO(dtseng): Leaking state about multiple key maps here until we have a 70 // TODO(dtseng): Leaking state about multiple key maps here until we have a
71 // class to manage multiple key maps. Also, this doesn't belong as a pref; 71 // class to manage multiple key maps. Also, this doesn't belong as a pref;
72 // should just store in local storage. 72 // should just store in local storage.
73 'currentKeyMap' : cvox.KeyMap.DEFAULT_KEYMAP, 73 'currentKeyMap': cvox.KeyMap.DEFAULT_KEYMAP,
74 'cvoxKey': '', 74 'cvoxKey': '',
75 'earcons': true, 75 'earcons': true,
76 'focusFollowsMouse': false, 76 'focusFollowsMouse': false,
77 'granularity': undefined, 77 'granularity': undefined,
78 'position': '{}', 78 'position': '{}',
79 'siteSpecificEnhancements': true, 79 'siteSpecificEnhancements': true,
80 'siteSpecificScriptBase': 80 'siteSpecificScriptBase':
81 'https://ssl.gstatic.com/accessibility/javascript/ext/', 81 'https://ssl.gstatic.com/accessibility/javascript/ext/',
82 'siteSpecificScriptLoader': 82 'siteSpecificScriptLoader':
83 'https://ssl.gstatic.com/accessibility/javascript/ext/loader.js', 83 'https://ssl.gstatic.com/accessibility/javascript/ext/loader.js',
(...skipping 20 matching lines...) Expand all
104 if (localStorage[pref] === undefined) { 104 if (localStorage[pref] === undefined) {
105 localStorage[pref] = cvox.ChromeVoxPrefs.DEFAULT_PREFS[pref]; 105 localStorage[pref] = cvox.ChromeVoxPrefs.DEFAULT_PREFS[pref];
106 } 106 }
107 } 107 }
108 }; 108 };
109 109
110 /** 110 /**
111 * Switches to another key map. 111 * Switches to another key map.
112 * @param {string} selectedKeyMap The id of the keymap in 112 * @param {string} selectedKeyMap The id of the keymap in
113 * cvox.KeyMap.AVAIABLE_KEYMAP_INFO. 113 * cvox.KeyMap.AVAIABLE_KEYMAP_INFO.
114 */ 114 */
115 cvox.ChromeVoxPrefs.prototype.switchToKeyMap = function(selectedKeyMap) { 115 cvox.ChromeVoxPrefs.prototype.switchToKeyMap = function(selectedKeyMap) {
116 // Switching key maps potentially affects the key codes that involve 116 // Switching key maps potentially affects the key codes that involve
117 // sequencing. Without resetting this list, potentially stale key 117 // sequencing. Without resetting this list, potentially stale key
118 // codes remain. The key codes themselves get pushed in 118 // codes remain. The key codes themselves get pushed in
119 // cvox.KeySequence.deserialize which gets called by cvox.KeyMap. 119 // cvox.KeySequence.deserialize which gets called by cvox.KeyMap.
120 cvox.ChromeVox.sequenceSwitchKeyCodes = []; 120 cvox.ChromeVox.sequenceSwitchKeyCodes = [];
121 121
122 // TODO(dtseng): Leaking state about multiple key maps here until we have a 122 // TODO(dtseng): Leaking state about multiple key maps here until we have a
123 // class to manage multiple key maps. 123 // class to manage multiple key maps.
124 localStorage['currentKeyMap'] = selectedKeyMap; 124 localStorage['currentKeyMap'] = selectedKeyMap;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 this.keyMap_.toLocalStorage(); 177 this.keyMap_.toLocalStorage();
178 this.sendPrefsToAllTabs(false, true); 178 this.sendPrefsToAllTabs(false, true);
179 }; 179 };
180 180
181 181
182 /** 182 /**
183 * Send all of the settings to all tabs. 183 * Send all of the settings to all tabs.
184 * @param {boolean} sendPrefs Whether to send the prefs. 184 * @param {boolean} sendPrefs Whether to send the prefs.
185 * @param {boolean} sendKeyBindings Whether to send the key bindings. 185 * @param {boolean} sendKeyBindings Whether to send the key bindings.
186 */ 186 */
187 cvox.ChromeVoxPrefs.prototype.sendPrefsToAllTabs = 187 cvox.ChromeVoxPrefs.prototype.sendPrefsToAllTabs = function(
188 function(sendPrefs, sendKeyBindings) { 188 sendPrefs, sendKeyBindings) {
189 var context = this; 189 var context = this;
190 var message = {}; 190 var message = {};
191 if (sendPrefs) { 191 if (sendPrefs) {
192 message['prefs'] = context.getPrefs(); 192 message['prefs'] = context.getPrefs();
193 } 193 }
194 if (sendKeyBindings) { 194 if (sendKeyBindings) {
195 // Note that cvox.KeyMap stringifies to a minimal object when message gets 195 // Note that cvox.KeyMap stringifies to a minimal object when message gets
196 // passed to the content script. 196 // passed to the content script.
197 message['keyBindings'] = this.keyMap_.toJSON(); 197 message['keyBindings'] = this.keyMap_.toJSON();
198 } 198 }
199 chrome.windows.getAll({populate: true}, function(windows) { 199 chrome.windows.getAll({populate: true}, function(windows) {
200 for (var i = 0; i < windows.length; i++) { 200 for (var i = 0; i < windows.length; i++) {
201 var tabs = windows[i].tabs; 201 var tabs = windows[i].tabs;
202 for (var j = 0; j < tabs.length; j++) { 202 for (var j = 0; j < tabs.length; j++) {
203 chrome.tabs.sendMessage(tabs[j].id, message); 203 chrome.tabs.sendMessage(tabs[j].id, message);
204 } 204 }
205 } 205 }
206 }); 206 });
207 }; 207 };
208 208
209 /** 209 /**
210 * Send all of the settings over the specified port. 210 * Send all of the settings over the specified port.
211 * @param {Port} port The port representing the connection to a content script. 211 * @param {Port} port The port representing the connection to a content script.
212 */ 212 */
213 cvox.ChromeVoxPrefs.prototype.sendPrefsToPort = function(port) { 213 cvox.ChromeVoxPrefs.prototype.sendPrefsToPort = function(port) {
214 port.postMessage({ 214 port.postMessage(
215 'keyBindings': this.keyMap_.toJSON(), 215 {'keyBindings': this.keyMap_.toJSON(), 'prefs': this.getPrefs()});
216 'prefs': this.getPrefs()});
217 }; 216 };
218 217
219 218
220 /** 219 /**
221 * Set the value of a pref and update all active tabs if it's changed. 220 * Set the value of a pref and update all active tabs if it's changed.
222 * @param {string} key The pref key. 221 * @param {string} key The pref key.
223 * @param {Object|string} value The new value of the pref. 222 * @param {Object|string} value The new value of the pref.
224 */ 223 */
225 cvox.ChromeVoxPrefs.prototype.setPref = function(key, value) { 224 cvox.ChromeVoxPrefs.prototype.setPref = function(key, value) {
226 if (localStorage[key] != value) { 225 if (localStorage[key] != value) {
227 localStorage[key] = value; 226 localStorage[key] = value;
228 this.sendPrefsToAllTabs(true, false); 227 this.sendPrefsToAllTabs(true, false);
229 } 228 }
230 }; 229 };
231 230
232 /** 231 /**
233 * Delegates to cvox.KeyMap. 232 * Delegates to cvox.KeyMap.
234 * @param {string} command The command to set. 233 * @param {string} command The command to set.
235 * @param {cvox.KeySequence} newKey The new key to assign it to. 234 * @param {cvox.KeySequence} newKey The new key to assign it to.
236 * @return {boolean} True if the key was bound to the command. 235 * @return {boolean} True if the key was bound to the command.
237 */ 236 */
238 cvox.ChromeVoxPrefs.prototype.setKey = function(command, newKey) { 237 cvox.ChromeVoxPrefs.prototype.setKey = function(command, newKey) {
239 if (this.keyMap_.rebind(command, newKey)) { 238 if (this.keyMap_.rebind(command, newKey)) {
240 this.keyMap_.toLocalStorage(); 239 this.keyMap_.toLocalStorage();
241 this.sendPrefsToAllTabs(false, true); 240 this.sendPrefsToAllTabs(false, true);
242 return true; 241 return true;
243 } 242 }
244 return false; 243 return false;
245 }; 244 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698