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 Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 ////////////////////////////////////////////////////////////////////////////// | 9 ////////////////////////////////////////////////////////////////////////////// |
10 // ContentSettings class: | 10 // ContentSettings class: |
11 | 11 |
12 /** | 12 /** |
13 * Encapsulated handling of content settings page. | 13 * Encapsulated handling of content settings page. |
14 * @constructor | 14 * @constructor |
15 * @extends {cr.ui.pageManager.Page} | |
15 */ | 16 */ |
16 function ContentSettings() { | 17 function ContentSettings() { |
17 this.activeNavTab = null; | 18 this.activeNavTab = null; |
18 Page.call(this, 'content', | 19 Page.call(this, 'content', |
19 loadTimeData.getString('contentSettingsPageTabTitle'), | 20 loadTimeData.getString('contentSettingsPageTabTitle'), |
20 'content-settings-page'); | 21 'content-settings-page'); |
21 } | 22 } |
22 | 23 |
23 cr.addSingletonGetter(ContentSettings); | 24 cr.addSingletonGetter(ContentSettings); |
24 | 25 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 for (var i = 0; i < indicators.length; i++) { | 120 for (var i = 0; i < indicators.length; i++) { |
120 indicators[i].handlePrefChange(event); | 121 indicators[i].handlePrefChange(event); |
121 } | 122 } |
122 } | 123 } |
123 }; | 124 }; |
124 | 125 |
125 /** | 126 /** |
126 * Updates the labels and indicators for the Media settings. Those require | 127 * Updates the labels and indicators for the Media settings. Those require |
127 * special handling because they are backed by multiple prefs and can change | 128 * special handling because they are backed by multiple prefs and can change |
128 * their scope based on the managed state of the backing prefs. | 129 * their scope based on the managed state of the backing prefs. |
129 * @param {Object} mediaSettings A dictionary containing the following fields: | 130 * @param {{askText: string, blockText: string, cameraDisabled: boolean, |
130 * {String} askText The label for the ask radio button. | 131 * micDisabled: boolean, showBubble: boolean, bubbleText: string}} |
131 * {String} blockText The label for the block radio button. | 132 * mediaSettings A dictionary containing the following fields: |
132 * {Boolean} cameraDisabled Whether to disable the camera dropdown. | 133 * askText The label for the ask radio button. |
133 * {Boolean} micDisabled Whether to disable the microphone dropdown. | 134 * blockText The label for the block radio button. |
134 * {Boolean} showBubble Wether to show the managed icon and bubble for the | 135 * cameraDisabled Whether to disable the camera dropdown. |
135 * media label. | 136 * micDisabled Whether to disable the microphone dropdown. |
136 * {String} bubbleText The text to use inside the bubble if it is shown. | 137 * showBubble Wether to show the managed icon and bubble for the media |
138 * label. | |
139 * bubbleText The text to use inside the bubble if it is shown. | |
137 */ | 140 */ |
138 ContentSettings.updateMediaUI = function(mediaSettings) { | 141 ContentSettings.updateMediaUI = function(mediaSettings) { |
139 $('media-stream-ask-label').innerHTML = | 142 $('media-stream-ask-label').innerHTML = |
140 loadTimeData.getString(mediaSettings.askText); | 143 loadTimeData.getString(mediaSettings.askText); |
141 $('media-stream-block-label').innerHTML = | 144 $('media-stream-block-label').innerHTML = |
142 loadTimeData.getString(mediaSettings.blockText); | 145 loadTimeData.getString(mediaSettings.blockText); |
143 | 146 |
144 if (mediaSettings.micDisabled) | 147 if (mediaSettings.micDisabled) |
145 $('media-select-mic').disabled = true; | 148 $('media-select-mic').disabled = true; |
146 if (mediaSettings.cameraDisabled) | 149 if (mediaSettings.cameraDisabled) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 } | 194 } |
192 }; | 195 }; |
193 | 196 |
194 /** | 197 /** |
195 * @param {string} type The type of exceptions (e.g. "location") to get. | 198 * @param {string} type The type of exceptions (e.g. "location") to get. |
196 * @param {string} mode The mode of the desired exceptions list (e.g. otr). | 199 * @param {string} mode The mode of the desired exceptions list (e.g. otr). |
197 * @return {?options.contentSettings.ExceptionsList} The corresponding | 200 * @return {?options.contentSettings.ExceptionsList} The corresponding |
198 * exceptions list or null. | 201 * exceptions list or null. |
199 */ | 202 */ |
200 ContentSettings.getExceptionsList = function(type, mode) { | 203 ContentSettings.getExceptionsList = function(type, mode) { |
201 return document.querySelector( | 204 var exceptionsList = document.querySelector( |
202 'div[contentType=' + type + '] list[mode=' + mode + ']'); | 205 'div[contentType=' + type + '] list[mode=' + mode + ']'); |
206 if (exceptionsList === null) | |
Dan Beam
2014/09/12 03:32:13
nit:
return !exceptionsList ? null :
assertIn
Vitaly Pavlenko
2014/09/12 19:21:16
Done.
| |
207 return null; | |
208 return assertInstanceof(exceptionsList, | |
209 options.contentSettings.ExceptionsList); | |
203 }; | 210 }; |
204 | 211 |
205 /** | 212 /** |
206 * The browser's response to a request to check the validity of a given URL | 213 * The browser's response to a request to check the validity of a given URL |
207 * pattern. | 214 * pattern. |
208 * @param {string} type The content type. | 215 * @param {string} type The content type. |
209 * @param {string} mode The browser mode. | 216 * @param {string} mode The browser mode. |
210 * @param {string} pattern The pattern. | 217 * @param {string} pattern The pattern. |
211 * @param {boolean} valid Whether said pattern is valid in the context of | 218 * @param {boolean} valid Whether said pattern is valid in the context of |
212 * a content exception setting. | 219 * a content exception setting. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 var deviceSelect = $('media-select-camera'); | 312 var deviceSelect = $('media-select-camera'); |
306 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); | 313 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); |
307 }; | 314 }; |
308 | 315 |
309 // Export | 316 // Export |
310 return { | 317 return { |
311 ContentSettings: ContentSettings | 318 ContentSettings: ContentSettings |
312 }; | 319 }; |
313 | 320 |
314 }); | 321 }); |
OLD | NEW |