Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * 'media-picker' handles showing the dropdown allowing users to select the | |
| 8 * default camera/microphone. | |
| 9 */ | |
| 10 Polymer({ | |
| 11 is: 'media-picker', | |
| 12 | |
| 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], | |
| 14 | |
| 15 properties: { | |
| 16 /** | |
| 17 * The type of media picker, either 'camera' or 'mic'. | |
| 18 */ | |
| 19 type: String, | |
| 20 | |
| 21 /** | |
| 22 * The devices available to pick from. | |
| 23 * @type {Array<MediaPickerEntry>} | |
| 24 */ | |
| 25 devices: Array, | |
| 26 }, | |
| 27 | |
| 28 ready: function() { | |
| 29 this.addWebUIListener('updateDevicesMenu', | |
| 30 this.updateDevicesMenu_.bind(this)); | |
| 31 this.browserProxy.getDefaultCaptureDevices(this.type); | |
| 32 }, | |
| 33 | |
| 34 /** | |
| 35 * Updates the microphone/camera devices menu with the given entries. | |
| 36 * @param {string} type The device type. | |
| 37 * @param {!Array<MediaPickerEntry>} devices List of available devices. | |
| 38 * @param {string} defaultDevice The unique id of the current default device. | |
| 39 */ | |
| 40 updateDevicesMenu_: function(type, devices, defaultDevice) { | |
| 41 if (type != this.type) | |
| 42 return; | |
| 43 | |
| 44 this.$.picker.hidden = devices.length == 0; | |
| 45 if (devices.length > 0) { | |
| 46 this.devices = devices; | |
| 47 this.$.mediaPicker.selected = defaultDevice; | |
| 48 } | |
| 49 }, | |
| 50 | |
| 51 /** | |
| 52 * A handler for when an item is selected in the media picker. | |
| 53 */ | |
| 54 onMediaPickerActivate_: function(event) { | |
| 55 this.browserProxy.setDefaultCaptureDevice(this.type, event.detail.selected); | |
| 56 }, | |
| 57 | |
|
michaelpg
2016/06/08 16:02:32
nit: remove empty line
Finnur
2016/06/08 21:15:45
Done.
| |
| 58 }); | |
| OLD | NEW |