Bug 1299783 - change the name of the temporary permission from 'camera' to something not exposed in the UI, r=gcp.

This commit is contained in:
Florian Quèze 2016-09-21 17:19:07 +02:00
parent dd33962ca2
commit 6f480b3e80
2 changed files with 12 additions and 24 deletions

View File

@ -292,7 +292,6 @@ function prompt(aBrowser, aRequest) {
requestTypes: requestTypes} = aRequest;
let uri = Services.io.newURI(aRequest.documentURI, null, null);
let host = getHost(uri);
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
let chromeDoc = aBrowser.ownerDocument;
let chromeWin = chromeDoc.defaultView;
let stringBundle = chromeWin.gNavigatorBundle;
@ -388,14 +387,12 @@ function prompt(aBrowser, aRequest) {
if (micPerm == perms.PROMPT_ACTION)
micPerm = perms.UNKNOWN_ACTION;
let camPermanentPerm = perms.testExactPermanentPermission(principal, "camera");
let camPerm = perms.testExactPermission(uri, "camera");
// Session approval given but never used to allocate a camera, remove
// and ask again
if (camPerm && !camPermanentPerm) {
perms.remove(uri, "camera");
camPerm = perms.UNKNOWN_ACTION;
let mediaManagerPerm =
perms.testExactPermission(uri, "MediaManagerVideo");
if (mediaManagerPerm) {
perms.remove(uri, "MediaManagerVideo");
}
if (camPerm == perms.PROMPT_ACTION)
@ -534,10 +531,12 @@ function prompt(aBrowser, aRequest) {
allowedDevices.push(videoDeviceIndex);
// Session permission will be removed after use
// (it's really one-shot, not for the entire session)
perms.add(uri, "camera", perms.ALLOW_ACTION,
aRemember ? perms.EXPIRE_NEVER : perms.EXPIRE_SESSION);
} else if (aRemember) {
perms.add(uri, "camera", perms.DENY_ACTION);
perms.add(uri, "MediaManagerVideo", perms.ALLOW_ACTION,
perms.EXPIRE_SESSION);
}
if (aRemember) {
perms.add(uri, "camera",
allowCamera ? perms.ALLOW_ACTION : perms.DENY_ACTION);
}
}
if (audioDevices.length) {

View File

@ -707,9 +707,8 @@ static bool
HasCameraPermission(const nsCString& aOrigin)
{
// Name used with nsIPermissionManager
static const char* cameraPermission = "camera";
static const char* cameraPermission = "MediaManagerVideo";
bool allowed = false;
bool permanent = false;
nsresult rv;
nsCOMPtr<nsIPermissionManager> mgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
@ -728,19 +727,9 @@ HasCameraPermission(const nsCString& aOrigin)
&video);
if (NS_SUCCEEDED(rv)) {
allowed = (video == nsIPermissionManager::ALLOW_ACTION);
// Was allowed, now see if this is a persistent permission
// or a session one.
if (allowed) {
rv = mgr->TestExactPermanentPermission(principal,
cameraPermission,
&video);
if (NS_SUCCEEDED(rv)) {
permanent = (video == nsIPermissionManager::ALLOW_ACTION);
}
}
}
// Session permissions are removed after one use.
if (allowed && !permanent) {
if (allowed) {
mgr->RemoveFromPrincipal(principal, cameraPermission);
}
}