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

Unified Diff: chrome/browser/resources/settings/site_settings/media_picker.js

Issue 2039833004: Site Settings Desktop: Implement media picker for camera/mic categories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/site_settings/media_picker.js
diff --git a/chrome/browser/resources/settings/site_settings/media_picker.js b/chrome/browser/resources/settings/site_settings/media_picker.js
new file mode 100644
index 0000000000000000000000000000000000000000..847213c0b384ae3f015b6a42a60aeb55b0dd7223
--- /dev/null
+++ b/chrome/browser/resources/settings/site_settings/media_picker.js
@@ -0,0 +1,57 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * 'media-picker' handles showing the dropdown allowing users to select the
+ * default camera/microphone.
+ */
+Polymer({
+ is: 'media-picker',
+
+ behaviors: [SiteSettingsBehavior, WebUIListenerBehavior],
+
+ properties: {
+ /**
+ * The type of media picker, either 'camera' or 'mic'.
+ */
+ type: String,
+
+ /**
+ * The devices available to pick from.
+ * @type {Array<MediaPickerEntry>}
+ */
+ devices: Array,
+ },
+
+ ready: function() {
+ this.addWebUIListener('updateDevicesMenu',
+ this.updateDevicesMenu_.bind(this));
+ this.browserProxy.getDefaultCaptureDevices(this.type);
+ },
+
+ /**
+ * Updates the microphone/camera devices menu with the given entries.
+ * @param {string} type The device type.
+ * @param {!Array<MediaPickerEntry>} devices List of available devices.
+ * @param {string} defaultDevice The unique id of the current default device.
+ */
+ updateDevicesMenu_: function(type, devices, defaultDevice) {
+ if (type != this.type)
+ return;
+
+ this.$.picker.hidden = devices.length == 0;
+ if (devices.length > 0) {
+ this.devices = devices;
+ this.$.mediaPicker.selected = defaultDevice;
+ }
+ },
+
+ /**
+ * A handler for when an item is selected in the media picker.
+ */
+ onMediaPickerActivate_: function(event) {
+ this.browserProxy.setDefaultCaptureDevice(this.type, event.detail.selected);
+ },
+});

Powered by Google App Engine
This is Rietveld 408576698