Bug 1616661 - Show raw device name to users in the gum prompt. r=achronop,snorp,johannh a=jcristau
☠☠ backed out by be31d6a4cc2a ☠ ☠
authorJan-Ivar Bruaroey <jib@mozilla.com>
Mon, 24 Feb 2020 17:09:13 +0000
changeset 524624 7d86454fd261ff5028988de190372aff143d873e
parent 524623 24241169e9d68b39500c3012d7794c0d386482ae
child 524625 a34778097505ce3c5988e82f373bf707b548b6ea
push id918
push userryanvm@gmail.com
push dateThu, 27 Feb 2020 19:00:46 +0000
treeherdermozilla-esr68@7d86454fd261 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersachronop, snorp, johannh, jcristau
bugs1616661
milestone68.6.0
Bug 1616661 - Show raw device name to users in the gum prompt. r=achronop,snorp,johannh a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D63552
browser/actors/WebRTCChild.jsm
dom/media/MediaManager.cpp
dom/media/MediaManager.h
dom/media/nsIDOMNavigatorUserMedia.idl
mobile/android/components/geckoview/GeckoViewPermission.js
--- a/browser/actors/WebRTCChild.jsm
+++ b/browser/actors/WebRTCChild.jsm
@@ -217,30 +217,30 @@ function prompt(
     device = device.QueryInterface(Ci.nsIMediaDevice);
     switch (device.type) {
       case "audioinput":
         // Check that if we got a microphone, we have not requested an audio
         // capture, and if we have requested an audio capture, we are not
         // getting a microphone instead.
         if (audio && (device.mediaSource == "microphone") != sharingAudio) {
           audioDevices.push({
-            name: device.name,
+            name: device.rawName, // unfiltered device name to show to the user
             deviceIndex: devices.length,
             id: device.rawId,
             mediaSource: device.mediaSource,
           });
           devices.push(device);
         }
         break;
       case "videoinput":
         // Verify that if we got a camera, we haven't requested a screen share,
         // or that if we requested a screen share we aren't getting a camera.
         if (video && (device.mediaSource == "camera") != sharingScreen) {
           let deviceObject = {
-            name: device.name,
+            name: device.rawName, // unfiltered device name to show to the user
             deviceIndex: devices.length,
             id: device.rawId,
             mediaSource: device.mediaSource,
           };
           if (device.scary) {
             deviceObject.scary = true;
           }
           videoDevices.push(deviceObject);
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -708,17 +708,18 @@ MediaDevice::MediaDevice(const RefPtr<Me
                 ? dom::MediaDeviceKind::Videoinput
                 : dom::MediaDeviceKind::Audioinput),
       mScary(mSource->GetScary()),
       mType(NS_ConvertUTF8toUTF16(
           dom::MediaDeviceKindValues::strings[uint32_t(mKind)].value)),
       mName(aName),
       mID(aID),
       mGroupID(aGroupID),
-      mRawID(aRawID) {
+      mRawID(aRawID),
+      mRawName(aName) {
   MOZ_ASSERT(mSource);
 }
 
 MediaDevice::MediaDevice(const RefPtr<AudioDeviceInfo>& aAudioDeviceInfo,
                          const nsString& aID, const nsString& aGroupID,
                          const nsString& aRawID)
     : mSource(nullptr),
       mSinkInfo(aAudioDeviceInfo),
@@ -726,17 +727,18 @@ MediaDevice::MediaDevice(const RefPtr<Au
                 ? dom::MediaDeviceKind::Audioinput
                 : dom::MediaDeviceKind::Audiooutput),
       mScary(false),
       mType(NS_ConvertUTF8toUTF16(
           dom::MediaDeviceKindValues::strings[uint32_t(mKind)].value)),
       mName(mSinkInfo->Name()),
       mID(aID),
       mGroupID(aGroupID),
-      mRawID(aRawID) {
+      mRawID(aRawID),
+      mRawName(mSinkInfo->Name()) {
   // For now this ctor is used only for Audiooutput.
   // It could be used for Audioinput and Videoinput
   // when we do not instantiate a MediaEngineSource
   // during EnumerateDevices.
   MOZ_ASSERT(mKind == dom::MediaDeviceKind::Audiooutput);
   MOZ_ASSERT(mSinkInfo);
 }
 
@@ -750,17 +752,18 @@ MediaDevice::MediaDevice(const RefPtr<Me
     : mSource(aOther->mSource),
       mSinkInfo(aOther->mSinkInfo),
       mKind(aOther->mKind),
       mScary(aOther->mScary),
       mType(aOther->mType),
       mName(aName),
       mID(aID),
       mGroupID(aGroupID),
-      mRawID(aRawID) {
+      mRawID(aRawID),
+      mRawName(aOther->mRawName) {
   MOZ_ASSERT(aOther);
 }
 
 /**
  * Helper functions that implement the constraints algorithm from
  * http://dev.w3.org/2011/webrtc/editor/getusermedia.html#methods-5
  */
 
@@ -823,16 +826,23 @@ uint32_t MediaDevice::GetBestFitnessDist
 NS_IMETHODIMP
 MediaDevice::GetName(nsAString& aName) {
   MOZ_ASSERT(NS_IsMainThread());
   aName.Assign(mName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
+MediaDevice::GetRawName(nsAString& aName) {
+  MOZ_ASSERT(NS_IsMainThread());
+  aName.Assign(mRawName);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 MediaDevice::GetType(nsAString& aType) {
   MOZ_ASSERT(NS_IsMainThread());
   aType.Assign(mType);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MediaDevice::GetId(nsAString& aID) {
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -126,16 +126,17 @@ class MediaDevice : public nsIMediaDevic
   const RefPtr<AudioDeviceInfo> mSinkInfo;
   const dom::MediaDeviceKind mKind;
   const bool mScary;
   const nsString mType;
   const nsString mName;
   const nsString mID;
   const nsString mGroupID;
   const nsString mRawID;
+  const nsString mRawName;
 };
 
 typedef nsRefPtrHashtable<nsUint64HashKey, GetUserMediaWindowListener>
     WindowTable;
 typedef MozPromise<RefPtr<AudioDeviceInfo>, nsresult, true> SinkInfoPromise;
 
 class MediaManager final : public nsIMediaManagerService,
                            public nsIObserver,
--- a/dom/media/nsIDOMNavigatorUserMedia.idl
+++ b/dom/media/nsIDOMNavigatorUserMedia.idl
@@ -4,15 +4,16 @@
 
 #include "nsISupports.idl"
 #include "nsIVariant.idl"
 
 [scriptable, builtinclass, uuid(ba3b2e08-1c07-4cd3-8822-f4d7e35ff2ae)]
 interface nsIMediaDevice : nsISupports
 {
   readonly attribute AString type;
-  readonly attribute AString name;
+  readonly attribute AString name; // may have personal info filtered out
   readonly attribute AString id;
   readonly attribute AString mediaSource;
   readonly attribute AString rawId;
   readonly attribute AString groupId;
   readonly attribute boolean scary;
+  readonly attribute AString rawName; // unfiltered device name, from 1616661
 };
--- a/mobile/android/components/geckoview/GeckoViewPermission.js
+++ b/mobile/android/components/geckoview/GeckoViewPermission.js
@@ -123,17 +123,17 @@ GeckoViewPermission.prototype = {
         }
 
         let sources = devices.map(device => {
           device = device.QueryInterface(Ci.nsIMediaDevice);
           return {
             type: device.type,
             id: device.id,
             rawId: device.rawId,
-            name: device.name,
+            name: device.rawName, // unfiltered device name to show to the user
             mediaSource: device.mediaSource,
           };
         });
 
         if (
           constraints.video &&
           !sources.some(source => source.type === "videoinput")
         ) {