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

Side by Side Diff: chrome/browser/resources/options/content_settings.js

Issue 1210173012: Split the Media settings UI into separate microphone and camera sections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI updates Created 5 years, 5 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 (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.exportPath('options'); 5 cr.exportPath('options');
6 6
7 /** 7 /**
8 * @typedef {{appId: string, 8 * @typedef {{appId: string,
9 * appName: (string|undefined), 9 * appName: (string|undefined),
10 * embeddingOrigin: (string|undefined), 10 * embeddingOrigin: (string|undefined),
11 * origin: string, 11 * origin: string,
12 * setting: string, 12 * setting: string,
13 * source: string, 13 * source: string,
14 * video: (string|undefined)}} 14 * video: (string|undefined)}}
15 */ 15 */
16 options.Exception; 16 options.Exception;
17 17
18 cr.define('options', function() { 18 cr.define('options', function() {
19 /** @const */ var Page = cr.ui.pageManager.Page; 19 /** @const */ var Page = cr.ui.pageManager.Page;
20 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 20 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
21 21
22 // Lookup table to generate the i18n strings. 22 // Lookup table to generate the i18n strings.
23 /** @const */ var permissionsLookup = { 23 /** @const */ var permissionsLookup = {
24 'cookies': 'cookies',
25 'images': 'images',
26 'javascript': 'javascript',
24 'location': 'location', 27 'location': 'location',
28 'media-stream-camera': 'mediaStreamCamera',
29 'media-stream-mic': 'mediaStreamMic',
30 'multiple-automatic-downloads': 'multipleAutomaticDownloads',
25 'notifications': 'notifications', 31 'notifications': 'notifications',
26 'media-stream': 'mediaStream',
27 'cookies': 'cookies',
28 'multiple-automatic-downloads': 'multipleAutomaticDownloads',
29 'images': 'images',
30 'plugins': 'plugins', 32 'plugins': 'plugins',
31 'popups': 'popups', 33 'popups': 'popups',
32 'javascript': 'javascript'
33 }; 34 };
34 35
35 ////////////////////////////////////////////////////////////////////////////// 36 //////////////////////////////////////////////////////////////////////////////
36 // ContentSettings class: 37 // ContentSettings class:
37 38
38 /** 39 /**
39 * Encapsulated handling of content settings page. 40 * Encapsulated handling of content settings page.
40 * @constructor 41 * @constructor
41 * @extends {cr.ui.pageManager.Page} 42 * @extends {cr.ui.pageManager.Page}
42 */ 43 */
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 value: dict[group].value, 144 value: dict[group].value,
144 controlledBy: controlledBy, 145 controlledBy: controlledBy,
145 }; 146 };
146 for (var i = 0; i < indicators.length; i++) { 147 for (var i = 0; i < indicators.length; i++) {
147 indicators[i].handlePrefChange(event); 148 indicators[i].handlePrefChange(event);
148 } 149 }
149 } 150 }
150 }; 151 };
151 152
152 /** 153 /**
153 * Updates the labels and indicators for the Media settings. Those require
154 * special handling because they are backed by multiple prefs and can change
155 * their scope based on the managed state of the backing prefs.
156 * @param {{askText: string, blockText: string, cameraDisabled: boolean,
157 * micDisabled: boolean, showBubble: boolean, bubbleText: string}}
158 * mediaSettings A dictionary containing the following fields:
159 * askText The label for the ask radio button.
160 * blockText The label for the block radio button.
161 * cameraDisabled Whether to disable the camera dropdown.
162 * micDisabled Whether to disable the microphone dropdown.
163 * showBubble Wether to show the managed icon and bubble for the media
164 * label.
165 * bubbleText The text to use inside the bubble if it is shown.
166 */
167 ContentSettings.updateMediaUI = function(mediaSettings) {
168 $('media-stream-ask-label').innerHTML =
169 loadTimeData.getString(mediaSettings.askText);
170 $('media-stream-block-label').innerHTML =
171 loadTimeData.getString(mediaSettings.blockText);
172
173 if (mediaSettings.micDisabled)
174 $('media-select-mic').disabled = true;
175 if (mediaSettings.cameraDisabled)
176 $('media-select-camera').disabled = true;
177
178 PageManager.hideBubble();
179 // Create a synthetic pref change event decorated as
180 // CoreOptionsHandler::CreateValueForPref() does.
181 // TODO(arv): It was not clear what event type this should use?
182 var event = new Event('undefined');
183 event.value = {};
184
185 if (mediaSettings.showBubble) {
186 event.value = { controlledBy: 'policy' };
187 $('media-indicator').setAttribute(
188 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText));
189 $('media-indicator').location = cr.ui.ArrowLocation.TOP_START;
190 }
191
192 $('media-indicator').handlePrefChange(event);
193 };
194
195 /**
196 * Initializes an exceptions list. 154 * Initializes an exceptions list.
197 * @param {string} type The content type that we are setting exceptions for. 155 * @param {string} type The content type that we are setting exceptions for.
198 * @param {Array<options.Exception>} exceptions An array of pairs, where the 156 * @param {Array<options.Exception>} exceptions An array of pairs, where the
199 * first element of each pair is the filter string, and the second is the 157 * first element of each pair is the filter string, and the second is the
200 * setting (allow/block). 158 * setting (allow/block).
201 */ 159 */
202 ContentSettings.setExceptions = function(type, exceptions) { 160 ContentSettings.setExceptions = function(type, exceptions) {
203 this.getExceptionsList(type, 'normal').setExceptions(exceptions); 161 this.getExceptionsList(type, 'normal').setExceptions(exceptions);
204 }; 162 };
205 163
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 var deviceSelect = $('media-select-camera'); 287 var deviceSelect = $('media-select-camera');
330 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); 288 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]);
331 }; 289 };
332 290
333 // Export 291 // Export
334 return { 292 return {
335 ContentSettings: ContentSettings 293 ContentSettings: ContentSettings
336 }; 294 };
337 295
338 }); 296 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698