OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var OptionsPage = options.OptionsPage; | 6 /** @const */ var OptionsPage = options.OptionsPage; |
7 | 7 |
8 ////////////////////////////////////////////////////////////////////////////// | 8 ////////////////////////////////////////////////////////////////////////////// |
9 // ContentSettings class: | 9 // ContentSettings class: |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 'span.controlled-setting-indicator[content-setting=' + group + ']'); | 108 'span.controlled-setting-indicator[content-setting=' + group + ']'); |
109 if (indicators.length == 0) | 109 if (indicators.length == 0) |
110 continue; | 110 continue; |
111 // Create a synthetic pref change event decorated as | 111 // Create a synthetic pref change event decorated as |
112 // CoreOptionsHandler::CreateValueForPref() does. | 112 // CoreOptionsHandler::CreateValueForPref() does. |
113 var event = new Event(group); | 113 var event = new Event(group); |
114 event.value = { | 114 event.value = { |
115 value: dict[group].value, | 115 value: dict[group].value, |
116 controlledBy: controlledBy, | 116 controlledBy: controlledBy, |
117 }; | 117 }; |
118 for (var i = 0; i < indicators.length; i++) | 118 for (var i = 0; i < indicators.length; i++) { |
119 indicators[i].handlePrefChange(event); | 119 indicators[i].handlePrefChange(event); |
120 } | |
120 } | 121 } |
121 }; | 122 }; |
122 | 123 |
123 /** | 124 /** |
124 * Updates the labels and indicators for the Media settings. Those require | 125 * Updates the labels and indicators for the Media settings. Those require |
125 * special handling because they are backed by multiple prefs and can change | 126 * special handling because they are backed by multiple prefs and can change |
126 * their scope based on the managed state of the backing prefs. | 127 * their scope based on the managed state of the backing prefs. |
127 * @param {Object} mediaSettings A dictionary containing the following fields: | 128 * @param {Object} mediaSettings A dictionary containing the following fields: |
128 * {String} askText The label for the ask radio button. | 129 * {String} askText The label for the ask radio button. |
129 * {String} blockText The label for the block radio button. | 130 * {String} blockText The label for the block radio button. |
(...skipping 30 matching lines...) Expand all Loading... | |
160 | 161 |
161 $('media-indicator').handlePrefChange(event); | 162 $('media-indicator').handlePrefChange(event); |
162 }; | 163 }; |
163 | 164 |
164 /** | 165 /** |
165 * Initializes an exceptions list. | 166 * Initializes an exceptions list. |
166 * @param {string} type The content type that we are setting exceptions for. | 167 * @param {string} type The content type that we are setting exceptions for. |
167 * @param {Array} list An array of pairs, where the first element of each pair | 168 * @param {Array} list An array of pairs, where the first element of each pair |
168 * is the filter string, and the second is the setting (allow/block). | 169 * is the filter string, and the second is the setting (allow/block). |
169 */ | 170 */ |
170 ContentSettings.setExceptions = function(type, list) { | 171 ContentSettings.setExceptions = function(type, list) { |
Evan Stade
2014/05/02 01:18:33
s/list/exceptions please
Dan Beam
2014/05/02 18:28:05
Done.
| |
171 var exceptionsList = | 172 this.getExceptionsList(type, 'normal').setExceptions(list); |
172 document.querySelector('div[contentType=' + type + ']' + | |
173 ' list[mode=normal]'); | |
174 exceptionsList.setExceptions(list); | |
175 }; | 173 }; |
176 | 174 |
177 ContentSettings.setHandlers = function(list) { | 175 ContentSettings.setHandlers = function(list) { |
178 $('handlers-list').setHandlers(list); | 176 $('handlers-list').setHandlers(list); |
179 }; | 177 }; |
180 | 178 |
181 ContentSettings.setIgnoredHandlers = function(list) { | 179 ContentSettings.setIgnoredHandlers = function(list) { |
182 $('ignored-handlers-list').setHandlers(list); | 180 $('ignored-handlers-list').setHandlers(list); |
183 }; | 181 }; |
184 | 182 |
185 ContentSettings.setOTRExceptions = function(type, list) { | 183 ContentSettings.setOTRExceptions = function(type, list) { |
Evan Stade
2014/05/02 01:18:33
ditto
Dan Beam
2014/05/02 18:28:05
Done.
| |
186 var exceptionsList = | 184 var exceptionsList = this.getExceptionsList(type, 'otr'); |
187 document.querySelector('div[contentType=' + type + ']' + | |
188 ' list[mode=otr]'); | |
189 | |
190 exceptionsList.parentNode.hidden = false; | 185 exceptionsList.parentNode.hidden = false; |
191 exceptionsList.setExceptions(list); | 186 exceptionsList.setExceptions(list); |
192 }; | 187 }; |
193 | 188 |
194 /** | 189 /** |
190 * @param {string} type The type of exceptions (e.g. "location") to get. | |
191 * @param {string} mode The mode of the desired exceptions list (e.g. otr). | |
192 * @return {?ExceptionsList} The corresponding exceptions list or null. | |
193 */ | |
194 ContentSettings.getExceptionsList = function(type, mode) { | |
195 return document.querySelector( | |
196 'div[contentType=' + type + '] list[mode=' + mode + ']'); | |
197 }; | |
198 | |
199 /** | |
195 * The browser's response to a request to check the validity of a given URL | 200 * The browser's response to a request to check the validity of a given URL |
196 * pattern. | 201 * pattern. |
197 * @param {string} type The content type. | 202 * @param {string} type The content type. |
198 * @param {string} mode The browser mode. | 203 * @param {string} mode The browser mode. |
199 * @param {string} pattern The pattern. | 204 * @param {string} pattern The pattern. |
200 * @param {bool} valid Whether said pattern is valid in the context of | 205 * @param {bool} valid Whether said pattern is valid in the context of |
201 * a content exception setting. | 206 * a content exception setting. |
202 */ | 207 */ |
203 ContentSettings.patternValidityCheckComplete = | 208 ContentSettings.patternValidityCheckComplete = |
204 function(type, mode, pattern, valid) { | 209 function(type, mode, pattern, valid) { |
205 var exceptionsList = | 210 this.getExceptionsList(type, mode).patternValidityCheckComplete(pattern, |
206 document.querySelector('div[contentType=' + type + '] ' + | 211 valid); |
207 'list[mode=' + mode + ']'); | |
208 exceptionsList.patternValidityCheckComplete(pattern, valid); | |
209 }; | 212 }; |
210 | 213 |
211 /** | 214 /** |
212 * Shows/hides the link to the Pepper Flash camera and microphone default | 215 * Shows/hides the link to the Pepper Flash camera and microphone default |
213 * settings. | 216 * settings. |
214 * Please note that whether the link is actually showed or not is also | 217 * Please note that whether the link is actually showed or not is also |
215 * affected by the style class pepper-flash-settings. | 218 * affected by the style class pepper-flash-settings. |
216 */ | 219 */ |
217 ContentSettings.showMediaPepperFlashDefaultLink = function(show) { | 220 ContentSettings.showMediaPepperFlashDefaultLink = function(show) { |
218 $('media-pepper-flash-default').hidden = !show; | 221 $('media-pepper-flash-default').hidden = !show; |
219 } | 222 }; |
220 | 223 |
221 /** | 224 /** |
222 * Shows/hides the link to the Pepper Flash camera and microphone | 225 * Shows/hides the link to the Pepper Flash camera and microphone |
223 * site-specific settings. | 226 * site-specific settings. |
224 * Please note that whether the link is actually showed or not is also | 227 * Please note that whether the link is actually showed or not is also |
225 * affected by the style class pepper-flash-settings. | 228 * affected by the style class pepper-flash-settings. |
226 */ | 229 */ |
227 ContentSettings.showMediaPepperFlashExceptionsLink = function(show) { | 230 ContentSettings.showMediaPepperFlashExceptionsLink = function(show) { |
228 $('media-pepper-flash-exceptions').hidden = !show; | 231 $('media-pepper-flash-exceptions').hidden = !show; |
229 } | 232 }; |
230 | 233 |
231 /** | 234 /** |
232 * Shows/hides the whole Web MIDI settings. | 235 * Shows/hides the whole Web MIDI settings. |
233 * @param {bool} show Wether to show the whole Web MIDI settings. | 236 * @param {bool} show Wether to show the whole Web MIDI settings. |
234 */ | 237 */ |
235 ContentSettings.showExperimentalWebMIDISettings = function(show) { | 238 ContentSettings.showExperimentalWebMIDISettings = function(show) { |
236 $('experimental-web-midi-settings').hidden = !show; | 239 $('experimental-web-midi-settings').hidden = !show; |
237 } | 240 }; |
238 | 241 |
239 /** | 242 /** |
240 * Updates the microphone/camera devices menu with the given entries. | 243 * Updates the microphone/camera devices menu with the given entries. |
241 * @param {string} type The device type. | 244 * @param {string} type The device type. |
242 * @param {Array} devices List of available devices. | 245 * @param {Array} devices List of available devices. |
243 * @param {string} defaultdevice The unique id of the current default device. | 246 * @param {string} defaultdevice The unique id of the current default device. |
244 */ | 247 */ |
245 ContentSettings.updateDevicesMenu = function(type, devices, defaultdevice) { | 248 ContentSettings.updateDevicesMenu = function(type, devices, defaultdevice) { |
246 var deviceSelect = ''; | 249 var deviceSelect = ''; |
247 if (type == 'mic') { | 250 if (type == 'mic') { |
(...skipping 20 matching lines...) Expand all Loading... | |
268 if (defaultIndex >= 0) | 271 if (defaultIndex >= 0) |
269 deviceSelect.selectedIndex = defaultIndex; | 272 deviceSelect.selectedIndex = defaultIndex; |
270 }; | 273 }; |
271 | 274 |
272 /** | 275 /** |
273 * Enables/disables the protected content exceptions button. | 276 * Enables/disables the protected content exceptions button. |
274 * @param {bool} enable Whether to enable the button. | 277 * @param {bool} enable Whether to enable the button. |
275 */ | 278 */ |
276 ContentSettings.enableProtectedContentExceptions = function(enable) { | 279 ContentSettings.enableProtectedContentExceptions = function(enable) { |
277 var exceptionsButton = $('protected-content-exceptions'); | 280 var exceptionsButton = $('protected-content-exceptions'); |
278 if (exceptionsButton) { | 281 if (exceptionsButton) |
279 exceptionsButton.disabled = !enable; | 282 exceptionsButton.disabled = !enable; |
280 } | 283 }; |
281 } | |
282 | 284 |
283 /** | 285 /** |
284 * Set the default microphone device based on the popup selection. | 286 * Set the default microphone device based on the popup selection. |
285 * @private | 287 * @private |
286 */ | 288 */ |
287 ContentSettings.setDefaultMicrophone_ = function() { | 289 ContentSettings.setDefaultMicrophone_ = function() { |
288 var deviceSelect = $('media-select-mic'); | 290 var deviceSelect = $('media-select-mic'); |
289 chrome.send('setDefaultCaptureDevice', ['mic', deviceSelect.value]); | 291 chrome.send('setDefaultCaptureDevice', ['mic', deviceSelect.value]); |
290 }; | 292 }; |
291 | 293 |
292 /** | 294 /** |
293 * Set the default camera device based on the popup selection. | 295 * Set the default camera device based on the popup selection. |
294 * @private | 296 * @private |
295 */ | 297 */ |
296 ContentSettings.setDefaultCamera_ = function() { | 298 ContentSettings.setDefaultCamera_ = function() { |
297 var deviceSelect = $('media-select-camera'); | 299 var deviceSelect = $('media-select-camera'); |
298 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); | 300 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); |
299 }; | 301 }; |
300 | 302 |
301 // Export | 303 // Export |
302 return { | 304 return { |
303 ContentSettings: ContentSettings | 305 ContentSettings: ContentSettings |
304 }; | 306 }; |
305 | 307 |
306 }); | 308 }); |
OLD | NEW |