mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 17:20:54 +00:00
Bug 736278 - Add always/never permissions for click-to-play plugins. r=mfinkle
This commit is contained in:
parent
b498eb6445
commit
b6d2d20c84
@ -3925,23 +3925,53 @@ var ClipboardHelper = {
|
|||||||
|
|
||||||
var PluginHelper = {
|
var PluginHelper = {
|
||||||
showDoorHanger: function(aTab) {
|
showDoorHanger: function(aTab) {
|
||||||
|
if (!aTab.browser)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Even though we may not end up showing a doorhanger, this flag
|
||||||
|
// lets us know that we've tried to show a doorhanger.
|
||||||
aTab.clickToPlayPluginDoorhangerShown = true;
|
aTab.clickToPlayPluginDoorhangerShown = true;
|
||||||
let message = Strings.browser.GetStringFromName("clickToPlayPlugins.message");
|
|
||||||
|
let uri = aTab.browser.currentURI;
|
||||||
|
|
||||||
|
// If the user has previously set a plugins permission for this website,
|
||||||
|
// either play or don't play the plugins instead of showing a doorhanger.
|
||||||
|
let permValue = Services.perms.testPermission(uri, "plugins");
|
||||||
|
if (permValue != Services.perms.UNKNOWN_ACTION) {
|
||||||
|
if (permValue == Services.perms.ALLOW_ACTION)
|
||||||
|
PluginHelper.playAllPlugins(aTab.browser.contentWindow);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = Strings.browser.formatStringFromName("clickToPlayPlugins.message1",
|
||||||
|
[uri.host], 1);
|
||||||
let buttons = [
|
let buttons = [
|
||||||
{
|
{
|
||||||
label: Strings.browser.GetStringFromName("clickToPlayPlugins.yes"),
|
label: Strings.browser.GetStringFromName("clickToPlayPlugins.yes"),
|
||||||
callback: function() {
|
callback: function(aChecked) {
|
||||||
|
// If the user checked "Don't ask again", make a permanent exception
|
||||||
|
if (aChecked)
|
||||||
|
Services.perms.add(uri, "plugins", Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||||
|
|
||||||
PluginHelper.playAllPlugins(aTab.browser.contentWindow);
|
PluginHelper.playAllPlugins(aTab.browser.contentWindow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: Strings.browser.GetStringFromName("clickToPlayPlugins.no"),
|
label: Strings.browser.GetStringFromName("clickToPlayPlugins.no"),
|
||||||
callback: function() {
|
callback: function(aChecked) {
|
||||||
// Do nothing
|
// If the user checked "Don't ask again", make a permanent exception
|
||||||
}
|
if (aChecked)
|
||||||
|
Services.perms.add(uri, "plugins", Ci.nsIPermissionManager.DENY_ACTION);
|
||||||
|
|
||||||
|
// Other than that, do nothing
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
NativeWindow.doorhanger.show(message, "ask-to-play-plugins", buttons, aTab.id);
|
|
||||||
|
// Add a checkbox with a "Don't ask again" message
|
||||||
|
let options = { checkbox: Strings.browser.GetStringFromName("clickToPlayPlugins.dontAskAgain") };
|
||||||
|
|
||||||
|
NativeWindow.doorhanger.show(message, "ask-to-play-plugins", buttons, aTab.id, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
playAllPlugins: function(aContentWindow) {
|
playAllPlugins: function(aContentWindow) {
|
||||||
@ -4003,7 +4033,7 @@ var PluginHelper = {
|
|||||||
var PermissionsHelper = {
|
var PermissionsHelper = {
|
||||||
|
|
||||||
_permissonTypes: ["password", "geolocation", "popup", "indexedDB",
|
_permissonTypes: ["password", "geolocation", "popup", "indexedDB",
|
||||||
"offline-app", "desktop-notification"],
|
"offline-app", "desktop-notification", "plugins"],
|
||||||
_permissionStrings: {
|
_permissionStrings: {
|
||||||
"password": {
|
"password": {
|
||||||
label: "password.rememberPassword",
|
label: "password.rememberPassword",
|
||||||
@ -4034,6 +4064,11 @@ var PermissionsHelper = {
|
|||||||
label: "desktopNotification.useNotifications",
|
label: "desktopNotification.useNotifications",
|
||||||
allowed: "desktopNotification.allow",
|
allowed: "desktopNotification.allow",
|
||||||
denied: "desktopNotification.dontAllow"
|
denied: "desktopNotification.dontAllow"
|
||||||
|
},
|
||||||
|
"plugins": {
|
||||||
|
label: "clickToPlayPlugins.playPlugins",
|
||||||
|
allowed: "clickToPlayPlugins.yes",
|
||||||
|
denied: "clickToPlayPlugins.no"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -226,9 +226,15 @@ timer.start=%S: timer started
|
|||||||
timer.end=%1$S: %2$Sms
|
timer.end=%1$S: %2$Sms
|
||||||
|
|
||||||
# Click to play plugins
|
# Click to play plugins
|
||||||
clickToPlayPlugins.message=This page contains plugin content. Would you like to play it?
|
clickToPlayPlugins.message1=%S contains plugin content. Would you like to play it?
|
||||||
clickToPlayPlugins.yes=Yes
|
clickToPlayPlugins.yes=Yes
|
||||||
clickToPlayPlugins.no=No
|
clickToPlayPlugins.no=No
|
||||||
|
# LOCALIZATION NOTE (clickToPlayPlugins.dontAskAgain): This label appears next to a
|
||||||
|
# checkbox to indicate whether or not the user wants to make a permanent decision.
|
||||||
|
clickToPlayPlugins.dontAskAgain=Don't ask again for this site
|
||||||
|
# LOCALIZATION NOTE (clickToPlayPlugins.playPlugins): Label that
|
||||||
|
# will be used in site settings dialog.
|
||||||
|
clickToPlayPlugins.playPlugins=Play Plugins
|
||||||
|
|
||||||
# Site settings dialog
|
# Site settings dialog
|
||||||
# LOCALIZATION NOTE (siteSettings.labelToValue): This string will be used to
|
# LOCALIZATION NOTE (siteSettings.labelToValue): This string will be used to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user