Bug 1348257 - Hide the "always remember" checkbox for webrtc prompts in PBM. r=nhnt11
It's important to not remember any user choices made in private mode
(except the ones we specifically mention in the private browsing landing
page). The original idea was to change the checkbox behavior to store
the permission for session duration if in PBM, but this would actually be
inconsistent with the other permission prompts which hide it completely.
MozReview-Commit-ID: 8ioVmE4XefE
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -13,16 +13,18 @@ const Ci = Components.interfaces;
Cu.import("resource:///modules/syncedtabs/EventEmitter.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
+ "resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SitePermissions",
"resource:///modules/SitePermissions.jsm");
XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() {
return Services.strings.createBundle("chrome://branding/locale/brand.properties");
});
@@ -446,39 +448,19 @@ function prompt(aBrowser, aRequest) {
SitePermissions.set(uri, sharingScreen ? "screen" : "camera",
SitePermissions.BLOCK, scope, notification.browser);
}
}
];
let productName = gBrandBundle.GetStringFromName("brandShortName");
- // Disable the permanent 'Allow' action if the connection isn't secure, or for
- // screen/audio sharing (because we can't guess which window the user wants to
- // share without prompting).
- let reasonForNoPermanentAllow = "";
- if (sharingScreen) {
- reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.screen3";
- } else if (sharingAudio) {
- reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.audio";
- } else if (!aRequest.secure) {
- reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.insecure";
- }
-
let options = {
persistent: true,
hideClose: !Services.prefs.getBoolPref("privacy.permissionPrompts.showCloseButton"),
- checkbox: {
- label: stringBundle.getString("getUserMedia.remember"),
- checkedState: reasonForNoPermanentAllow ? {
- disableMainAction: true,
- warningLabel: stringBundle.getFormattedString(reasonForNoPermanentAllow,
- [productName])
- } : undefined,
- },
eventCallback(aTopic, aNewBrowser) {
if (aTopic == "swapping")
return true;
let doc = this.browser.ownerDocument;
// Clean-up video streams of screensharing previews.
if ((aTopic == "dismissed" || aTopic == "removed") &&
@@ -808,16 +790,41 @@ function prompt(aBrowser, aRequest) {
mm.sendAsyncMessage("webrtc:Allow", {callID: aRequest.callID,
windowID: aRequest.windowID,
devices: allowedDevices});
};
return false;
}
};
+ // Don't offer "always remember" action in PB mode.
+ if (!PrivateBrowsingUtils.isBrowserPrivate(aBrowser)) {
+
+ // Disable the permanent 'Allow' action if the connection isn't secure, or for
+ // screen/audio sharing (because we can't guess which window the user wants to
+ // share without prompting).
+ let reasonForNoPermanentAllow = "";
+ if (sharingScreen) {
+ reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.screen3";
+ } else if (sharingAudio) {
+ reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.audio";
+ } else if (!aRequest.secure) {
+ reasonForNoPermanentAllow = "getUserMedia.reasonForNoPermanentAllow.insecure";
+ }
+
+ options.checkbox = {
+ label: stringBundle.getString("getUserMedia.remember"),
+ checkedState: reasonForNoPermanentAllow ? {
+ disableMainAction: true,
+ warningLabel: stringBundle.getFormattedString(reasonForNoPermanentAllow,
+ [productName])
+ } : undefined,
+ };
+ }
+
let iconType = "Devices";
if (requestTypes.length == 1 && (requestTypes[0] == "Microphone" ||
requestTypes[0] == "AudioCapture"))
iconType = "Microphone";
if (requestTypes.includes("Screen"))
iconType = "Screen";
let anchorId = "webRTC-share" + iconType + "-notification-icon";