r=me 
From mvl - fix phoenix bustage on popup blocking
This commit is contained in:
mkaply%us.ibm.com 2003-03-25 19:05:08 +00:00
Родитель 925955c81d
Коммит b647e99aa7
2 изменённых файлов: 21 добавлений и 16 удалений

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

@ -2808,7 +2808,6 @@ function focusSearchBar()
} }
} }
const IMAGEPERMISSION = 1;
function nsContextMenu( xulMenu ) { function nsContextMenu( xulMenu ) {
this.target = null; this.target = null;
this.menu = null; this.menu = null;
@ -3313,16 +3312,26 @@ nsContextMenu.prototype = {
saveURL( this.imageURL, null, "SaveImageTitle", false ); saveURL( this.imageURL, null, "SaveImageTitle", false );
}, },
toggleImageBlocking : function (aBlock) { toggleImageBlocking : function (aBlock) {
var nsIPermissionManager = Components.interfaces.nsIPermissionManager;
var permissionmanager =
Components.classes["@mozilla.org/permissionmanager;1"]
.getService(nsIPermissionManager);
var uri = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURI);
uri.spec = this.imageURL;
permissionmanager.add(uri,
nsIPermissionManager.IMAGE_TYPE,
aBlock ? nsIPermissionManager.DENY_ACTION : nsIPermissionManager.ALLOW_ACTION);
},
isImageBlocked : function() {
var nsIPermissionManager = Components.interfaces.nsIPermissionManager;
var permissionmanager = var permissionmanager =
Components.classes["@mozilla.org/permissionmanager;1"] Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager); .getService(Components.interfaces.nsIPermissionManager);
permissionmanager.add(this.imageURL, !aBlock, IMAGEPERMISSION); var uri = Components.classes["@mozilla.org/network/standard-url;1"]
}, .createInstance(Components.interfaces.nsIURI);
isImageBlocked : function() { uri.spec = this.imageURL;
var permissionmanager = return permissionmanager.testPermission(uri, nsIPermissionManager.IMAGE_TYPE);
Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
return permissionmanager.testForBlocking(this.imageURL, IMAGEPERMISSION);
}, },
// Generate email address and put it on clipboard. // Generate email address and put it on clipboard.
copyEmail : function () { copyEmail : function () {

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

@ -42,6 +42,8 @@ var gImagesPref, gImagesEnabled, gImagesRestricted;
var policyButton = null; var policyButton = null;
var manageTree = null; var manageTree = null;
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
function Startup() function Startup()
{ {
policyButton = document.getElementById("popupPolicy"); policyButton = document.getElementById("popupPolicy");
@ -299,7 +301,7 @@ function AddPermission() {
var nameToURI = name.value.replace(" ", ""); var nameToURI = name.value.replace(" ", "");
var uri = Components.classes['@mozilla.org/network/standard-url;1'].createInstance(Components.interfaces.nsIURI); var uri = Components.classes['@mozilla.org/network/standard-url;1'].createInstance(Components.interfaces.nsIURI);
uri.spec = nameToURI; uri.spec = nameToURI;
popupmanager.add(uri, true); permissionmanager.add(uri, nsIPermissionManager.POPUP_TYPE, nsIPermissionManager.ALLOW_ACTION);
loadPermissions(); loadPermissions();
} }
@ -322,13 +324,7 @@ function FinalizePermissionDeletions() {
.getService(Components.interfaces.nsIIOService); .getService(Components.interfaces.nsIIOService);
for (var p=0; p<deletedPermissions.length; p++) { for (var p=0; p<deletedPermissions.length; p++) {
if (deletedPermissions[p].type == 2) { permissionmanager.remove(deletedPermissions[p].host, deletedPermissions[p].type);
// we lost the URI's original scheme, but this will do because the scheme
// is stripped later anyway.
var uri = ioService.newURI("http://"+deletedPermissions[p].host, null, null);
popupmanager.remove(uri);
} else
permissionmanager.remove(deletedPermissions[p].host, deletedPermissions[p].type);
} }
deletedPermissions.length = 0; deletedPermissions.length = 0;
} }