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 27 matching lines...) Expand all Loading... |
157 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText)); | 158 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText)); |
158 $('media-indicator').location = cr.ui.ArrowLocation.TOP_START; | 159 $('media-indicator').location = cr.ui.ArrowLocation.TOP_START; |
159 } | 160 } |
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} exceptions An array of pairs, where the first element of |
168 * is the filter string, and the second is the setting (allow/block). | 169 * each pair is the filter string, and the second is the setting |
| 170 * (allow/block). |
169 */ | 171 */ |
170 ContentSettings.setExceptions = function(type, list) { | 172 ContentSettings.setExceptions = function(type, exceptions) { |
171 var exceptionsList = | 173 this.getExceptionsList(type, 'normal').setExceptions(exceptions); |
172 document.querySelector('div[contentType=' + type + ']' + | |
173 ' list[mode=normal]'); | |
174 exceptionsList.setExceptions(list); | |
175 }; | 174 }; |
176 | 175 |
177 ContentSettings.setHandlers = function(list) { | 176 ContentSettings.setHandlers = function(handlers) { |
178 $('handlers-list').setHandlers(list); | 177 $('handlers-list').setHandlers(handlers); |
179 }; | 178 }; |
180 | 179 |
181 ContentSettings.setIgnoredHandlers = function(list) { | 180 ContentSettings.setIgnoredHandlers = function(ignoredHandlers) { |
182 $('ignored-handlers-list').setHandlers(list); | 181 $('ignored-handlers-list').setHandlers(ignoredHandlers); |
183 }; | 182 }; |
184 | 183 |
185 ContentSettings.setOTRExceptions = function(type, list) { | 184 ContentSettings.setOTRExceptions = function(type, otrExceptions) { |
186 var exceptionsList = | 185 var exceptionsList = this.getExceptionsList(type, 'otr'); |
187 document.querySelector('div[contentType=' + type + ']' + | |
188 ' list[mode=otr]'); | |
189 | |
190 exceptionsList.parentNode.hidden = false; | 186 exceptionsList.parentNode.hidden = false; |
191 exceptionsList.setExceptions(list); | 187 exceptionsList.setExceptions(otrExceptions); |
192 }; | 188 }; |
193 | 189 |
194 /** | 190 /** |
| 191 * @param {string} type The type of exceptions (e.g. "location") to get. |
| 192 * @param {string} mode The mode of the desired exceptions list (e.g. otr). |
| 193 * @return {?ExceptionsList} The corresponding exceptions list or null. |
| 194 */ |
| 195 ContentSettings.getExceptionsList = function(type, mode) { |
| 196 return document.querySelector( |
| 197 'div[contentType=' + type + '] list[mode=' + mode + ']'); |
| 198 }; |
| 199 |
| 200 /** |
195 * The browser's response to a request to check the validity of a given URL | 201 * The browser's response to a request to check the validity of a given URL |
196 * pattern. | 202 * pattern. |
197 * @param {string} type The content type. | 203 * @param {string} type The content type. |
198 * @param {string} mode The browser mode. | 204 * @param {string} mode The browser mode. |
199 * @param {string} pattern The pattern. | 205 * @param {string} pattern The pattern. |
200 * @param {bool} valid Whether said pattern is valid in the context of | 206 * @param {bool} valid Whether said pattern is valid in the context of |
201 * a content exception setting. | 207 * a content exception setting. |
202 */ | 208 */ |
203 ContentSettings.patternValidityCheckComplete = | 209 ContentSettings.patternValidityCheckComplete = |
204 function(type, mode, pattern, valid) { | 210 function(type, mode, pattern, valid) { |
205 var exceptionsList = | 211 this.getExceptionsList(type, mode).patternValidityCheckComplete(pattern, |
206 document.querySelector('div[contentType=' + type + '] ' + | 212 valid); |
207 'list[mode=' + mode + ']'); | |
208 exceptionsList.patternValidityCheckComplete(pattern, valid); | |
209 }; | 213 }; |
210 | 214 |
211 /** | 215 /** |
212 * Shows/hides the link to the Pepper Flash camera and microphone default | 216 * Shows/hides the link to the Pepper Flash camera and microphone default |
213 * settings. | 217 * settings. |
214 * Please note that whether the link is actually showed or not is also | 218 * Please note that whether the link is actually showed or not is also |
215 * affected by the style class pepper-flash-settings. | 219 * affected by the style class pepper-flash-settings. |
216 */ | 220 */ |
217 ContentSettings.showMediaPepperFlashDefaultLink = function(show) { | 221 ContentSettings.showMediaPepperFlashDefaultLink = function(show) { |
218 $('media-pepper-flash-default').hidden = !show; | 222 $('media-pepper-flash-default').hidden = !show; |
219 } | 223 }; |
220 | 224 |
221 /** | 225 /** |
222 * Shows/hides the link to the Pepper Flash camera and microphone | 226 * Shows/hides the link to the Pepper Flash camera and microphone |
223 * site-specific settings. | 227 * site-specific settings. |
224 * Please note that whether the link is actually showed or not is also | 228 * Please note that whether the link is actually showed or not is also |
225 * affected by the style class pepper-flash-settings. | 229 * affected by the style class pepper-flash-settings. |
226 */ | 230 */ |
227 ContentSettings.showMediaPepperFlashExceptionsLink = function(show) { | 231 ContentSettings.showMediaPepperFlashExceptionsLink = function(show) { |
228 $('media-pepper-flash-exceptions').hidden = !show; | 232 $('media-pepper-flash-exceptions').hidden = !show; |
229 } | 233 }; |
230 | 234 |
231 /** | 235 /** |
232 * Shows/hides the whole Web MIDI settings. | 236 * Shows/hides the whole Web MIDI settings. |
233 * @param {bool} show Wether to show the whole Web MIDI settings. | 237 * @param {bool} show Wether to show the whole Web MIDI settings. |
234 */ | 238 */ |
235 ContentSettings.showExperimentalWebMIDISettings = function(show) { | 239 ContentSettings.showExperimentalWebMIDISettings = function(show) { |
236 $('experimental-web-midi-settings').hidden = !show; | 240 $('experimental-web-midi-settings').hidden = !show; |
237 } | 241 }; |
238 | 242 |
239 /** | 243 /** |
240 * Updates the microphone/camera devices menu with the given entries. | 244 * Updates the microphone/camera devices menu with the given entries. |
241 * @param {string} type The device type. | 245 * @param {string} type The device type. |
242 * @param {Array} devices List of available devices. | 246 * @param {Array} devices List of available devices. |
243 * @param {string} defaultdevice The unique id of the current default device. | 247 * @param {string} defaultdevice The unique id of the current default device. |
244 */ | 248 */ |
245 ContentSettings.updateDevicesMenu = function(type, devices, defaultdevice) { | 249 ContentSettings.updateDevicesMenu = function(type, devices, defaultdevice) { |
246 var deviceSelect = ''; | 250 var deviceSelect = ''; |
247 if (type == 'mic') { | 251 if (type == 'mic') { |
(...skipping 20 matching lines...) Expand all Loading... |
268 if (defaultIndex >= 0) | 272 if (defaultIndex >= 0) |
269 deviceSelect.selectedIndex = defaultIndex; | 273 deviceSelect.selectedIndex = defaultIndex; |
270 }; | 274 }; |
271 | 275 |
272 /** | 276 /** |
273 * Enables/disables the protected content exceptions button. | 277 * Enables/disables the protected content exceptions button. |
274 * @param {bool} enable Whether to enable the button. | 278 * @param {bool} enable Whether to enable the button. |
275 */ | 279 */ |
276 ContentSettings.enableProtectedContentExceptions = function(enable) { | 280 ContentSettings.enableProtectedContentExceptions = function(enable) { |
277 var exceptionsButton = $('protected-content-exceptions'); | 281 var exceptionsButton = $('protected-content-exceptions'); |
278 if (exceptionsButton) { | 282 if (exceptionsButton) |
279 exceptionsButton.disabled = !enable; | 283 exceptionsButton.disabled = !enable; |
280 } | 284 }; |
281 } | |
282 | 285 |
283 /** | 286 /** |
284 * Set the default microphone device based on the popup selection. | 287 * Set the default microphone device based on the popup selection. |
285 * @private | 288 * @private |
286 */ | 289 */ |
287 ContentSettings.setDefaultMicrophone_ = function() { | 290 ContentSettings.setDefaultMicrophone_ = function() { |
288 var deviceSelect = $('media-select-mic'); | 291 var deviceSelect = $('media-select-mic'); |
289 chrome.send('setDefaultCaptureDevice', ['mic', deviceSelect.value]); | 292 chrome.send('setDefaultCaptureDevice', ['mic', deviceSelect.value]); |
290 }; | 293 }; |
291 | 294 |
292 /** | 295 /** |
293 * Set the default camera device based on the popup selection. | 296 * Set the default camera device based on the popup selection. |
294 * @private | 297 * @private |
295 */ | 298 */ |
296 ContentSettings.setDefaultCamera_ = function() { | 299 ContentSettings.setDefaultCamera_ = function() { |
297 var deviceSelect = $('media-select-camera'); | 300 var deviceSelect = $('media-select-camera'); |
298 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); | 301 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); |
299 }; | 302 }; |
300 | 303 |
301 // Export | 304 // Export |
302 return { | 305 return { |
303 ContentSettings: ContentSettings | 306 ContentSettings: ContentSettings |
304 }; | 307 }; |
305 | 308 |
306 }); | 309 }); |
OLD | NEW |