mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
fix bug 34499 don't display Block-Image if image is already blocked
This commit is contained in:
parent
98fe3d4df9
commit
a61f227e57
@ -316,15 +316,39 @@ nsContextMenu.prototype = {
|
||||
this.copyToClipboard( this.imageURL );
|
||||
},
|
||||
// Determine if "Block Image" is to appear in the menu.
|
||||
// Return false unless "imageBlocker.enabled" pref is set.
|
||||
// Return true if "imageBlocker.enabled" pref is set and image is not already blocked.
|
||||
isBlockingImages: function () {
|
||||
/* determine if "imageBlocker.enabled" pref is set */
|
||||
var pref = this.getService( 'component://netscape/preferences', 'nsIPref' );
|
||||
var result = false;
|
||||
try {
|
||||
result = pref.GetBoolPref( "imageblocker.enabled" );
|
||||
} catch(e) {
|
||||
}
|
||||
return result;
|
||||
if (!result) {
|
||||
/* pref is not set so return false */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* determine if image is already being blocked */
|
||||
var cookieViewer = this.createInstance
|
||||
("component://netscape/cookieviewer/cookieviewer-world", "nsICookieViewer");
|
||||
var list = cookieViewer.GetPermissionValue(1);
|
||||
var permissionList = list.split(list[0]);
|
||||
for(var i = 1; i < permissionList.length; i+=2) {
|
||||
permStr = permissionList[i+1];
|
||||
var type = permStr.substring(0,1);
|
||||
if (type == "-") {
|
||||
/* some host is being blocked, need to find out if it's our image's host */
|
||||
var host = permStr.substring(1,permStr.length);
|
||||
if (this.imageURL.search(host) != -1) {
|
||||
/* it's our image's host that's being blocked */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* image is not already being blocked, so "Block Image" can appear on the menu */
|
||||
return true;
|
||||
},
|
||||
// Block image from loading in the future.
|
||||
blockImage : function () {
|
||||
|
Loading…
Reference in New Issue
Block a user