Bug 736278 - (2/2) Add always/never permissions for click-to-play plugins. r=mfinkle

This commit is contained in:
Margaret Leibovic 2012-03-27 14:36:25 -07:00
Родитель caa421dfd0
Коммит 6479d74f07
2 изменённых файлов: 50 добавлений и 8 удалений

Просмотреть файл

@ -3923,23 +3923,54 @@ var ClipboardHelper = {
var PluginHelper = {
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;
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 = [
{
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);
}
},
{
label: Strings.browser.GetStringFromName("clickToPlayPlugins.no"),
callback: function() {
// Do nothing
callback: function(aChecked) {
// 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) {
@ -4001,7 +4032,7 @@ var PluginHelper = {
var PermissionsHelper = {
_permissonTypes: ["password", "geolocation", "popup", "indexedDB",
"offline-app", "desktop-notification"],
"offline-app", "desktop-notification", "plugins"],
_permissionStrings: {
"password": {
label: "password.rememberPassword",
@ -4032,6 +4063,11 @@ var PermissionsHelper = {
label: "desktopNotification.useNotifications",
allowed: "desktopNotification.allow",
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
# 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.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
# LOCALIZATION NOTE (siteSettings.labelToValue): This string will be used to