Skip to content

Commit

Permalink
[embedlite-components] Add support for MediaManagerVideo permission. …
Browse files Browse the repository at this point in the history
…JB#53942

In addition to "camera" and "microphone" permissions, the MediaManager
uses one more id "MediaManagerVideo", and does not grant permission to
use camera unless the principal has "MediaManagerVideo" allowed. Add
this permission for one shot each time the camera is requested.
  • Loading branch information
d-grigorev committed Jun 8, 2021
1 parent 2477d1f commit 7e52fd6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jscomps/EmbedLiteWebrtcUI.js
Expand Up @@ -118,6 +118,12 @@ WebrtcPermissionRequest.prototype = {
// If the permission has already been granted
let result = Services.perms.testExactPermission(this.uri, type);
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
if (type == "camera") {
// Add one-shot permission to use camera
Services.perms.add(this.uri, "MediaManagerVideo",
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION);
}
// Use first available device. Assume Gecko has them sorted by importance.
// Perhaps a better algorithm can be implemented here.
return 0;
Expand Down Expand Up @@ -148,6 +154,12 @@ WebrtcPermissionRequest.prototype = {
&& availableDevices
&& availableDevices.length > selectedIndex) {
this.allowedDevices.appendElement(availableDevices[selectedIndex]);
// Add one-shot permission to use camera
if (type == "camera") {
Services.perms.add(this.uri, "MediaManagerVideo",
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION);
}
}
}
}
Expand Down

0 comments on commit 7e52fd6

Please sign in to comment.