mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 892378 - Let SitePermissions.jsm handle indexedDB's special use of UNKNOWN_ACTION and ALLOW_ACTION. r=jaws
This commit is contained in:
parent
34181eb132
commit
4d3ab27bc9
@ -6868,7 +6868,7 @@ var gIdentityHandler = {
|
||||
continue;
|
||||
let menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("value", state);
|
||||
menuitem.setAttribute("label", SitePermissions.getStateLabel(state));
|
||||
menuitem.setAttribute("label", SitePermissions.getStateLabel(aPermission, state));
|
||||
menupopup.appendChild(menuitem);
|
||||
}
|
||||
menulist.appendChild(menupopup);
|
||||
|
@ -134,7 +134,7 @@ function createRow(aPartId) {
|
||||
for (let state of SitePermissions.getAvailableStates(aPartId)) {
|
||||
let radio = document.createElement("radio");
|
||||
radio.setAttribute("id", aPartId + "#" + state);
|
||||
radio.setAttribute("label", SitePermissions.getStateLabel(state));
|
||||
radio.setAttribute("label", SitePermissions.getStateLabel(aPartId, state));
|
||||
radio.setAttribute("command", commandId);
|
||||
radiogroup.appendChild(radio);
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ this.SitePermissions = {
|
||||
|
||||
/* Removes the saved state of a particular permission for a given URI.
|
||||
*/
|
||||
remove: function (aURI, aPermission) {
|
||||
remove: function (aURI, aPermissionID) {
|
||||
if (!this.isSupportedURI(aURI))
|
||||
return;
|
||||
|
||||
Services.perms.remove(aURI.host, aPermission);
|
||||
Services.perms.remove(aURI.host, aPermissionID);
|
||||
|
||||
if (aPermissionID in gPermissionObject &&
|
||||
gPermissionObject[aPermissionID].onChange)
|
||||
@ -110,7 +110,14 @@ this.SitePermissions = {
|
||||
/* Returns the localized label for the given permission state, to be used in
|
||||
* a UI for managing permissions.
|
||||
*/
|
||||
getStateLabel: function (aState) {
|
||||
getStateLabel: function (aPermissionID, aState) {
|
||||
if (aPermissionID in gPermissionObject &&
|
||||
gPermissionObject[aPermissionID].getStateLabel) {
|
||||
let label = gPermissionObject[aPermissionID].getStateLabel(aState);
|
||||
if (label)
|
||||
return label;
|
||||
}
|
||||
|
||||
switch (aState) {
|
||||
case this.UNKNOWN:
|
||||
return gStringBundle.GetStringFromName("alwaysAsk");
|
||||
@ -140,6 +147,11 @@ let gPermissionObject = {
|
||||
* Defaults to UNKNOWN, indicating that the user will be asked each time
|
||||
* a page asks for that permissions.
|
||||
*
|
||||
* - getStateLabel
|
||||
* Called to get the localized label for the given permission state, to be
|
||||
* used in a UI for managing permissions. May return null for states that
|
||||
* should use their default label.
|
||||
*
|
||||
* - onChange
|
||||
* Called when a permission state changes.
|
||||
*
|
||||
@ -189,8 +201,18 @@ let gPermissionObject = {
|
||||
},
|
||||
|
||||
"indexedDB": {
|
||||
getDefault: function () {
|
||||
return SitePermissions.ALLOW;
|
||||
states: [ SitePermissions.ALLOW, SitePermissions.UNKNOWN, SitePermissions.BLOCK ],
|
||||
getStateLabel: function (aState) {
|
||||
// indexedDB redefines nsIPermissionManager.UNKNOWN_ACTION (the default)
|
||||
// as "allow" and nsIPermissionManager.ALLOW_ACTION as "ask the user."
|
||||
switch (aState) {
|
||||
case SitePermissions.UNKNOWN:
|
||||
return gStringBundle.GetStringFromName("allow");
|
||||
case SitePermissions.ALLOW:
|
||||
return gStringBundle.GetStringFromName("alwaysAsk");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
onChange: function (aURI, aState) {
|
||||
if (aState == SitePermissions.ALLOW || aState == SitePermissions.BLOCK)
|
||||
|
Loading…
Reference in New Issue
Block a user