diff --git a/browser/modules/webrtcUI.jsm b/browser/modules/webrtcUI.jsm index 707a8d7cb97f..c05bf6f54026 100644 --- a/browser/modules/webrtcUI.jsm +++ b/browser/modules/webrtcUI.jsm @@ -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) { diff --git a/dom/media/systemservices/CamerasParent.cpp b/dom/media/systemservices/CamerasParent.cpp index c43633664745..5eda8022f9d6 100644 --- a/dom/media/systemservices/CamerasParent.cpp +++ b/dom/media/systemservices/CamerasParent.cpp @@ -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 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); } }