mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
bug 97409, add unblocking images to context menu, r=law, sr=alecf
This commit is contained in:
parent
d3a5abd687
commit
031aa7ff3b
@ -41,22 +41,10 @@
|
||||
// Determine if "Block Image" is to appear in the menu.
|
||||
// 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 = gContextMenu.getService('@mozilla.org/preferences;1', 'nsIPref');
|
||||
var result = false;
|
||||
try {
|
||||
result = pref.GetBoolPref( "imageblocker.enabled" );
|
||||
} catch(e) {
|
||||
}
|
||||
if (!result) {
|
||||
/* pref is not set so return false */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* determine if image is already being blocked */
|
||||
var permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService().QueryInterface(Components.interfaces.nsIPermissionManager);
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
|
||||
|
||||
var enumerator = permissionmanager.enumerator;
|
||||
@ -81,21 +69,53 @@
|
||||
return true;
|
||||
},
|
||||
|
||||
// Determine if "imageBlocker.enabled" pref is set
|
||||
isPrefSet: function () {
|
||||
var pref = gContextMenu.getService('@mozilla.org/preferences;1', 'nsIPref');
|
||||
var result = false;
|
||||
try {
|
||||
result = pref.GetBoolPref( "imageblocker.enabled" );
|
||||
} catch(e) {
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// Block image from loading in the future.
|
||||
blockImage : function () {
|
||||
var imgmanager =
|
||||
Components.classes["@mozilla.org/imgmanager;1"]
|
||||
.getService().QueryInterface(Components.interfaces.nsIImgManager);
|
||||
imgmanager.block(gContextMenu.imageURL);
|
||||
var permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
if (!permissionmanager) {
|
||||
return;
|
||||
}
|
||||
permissionmanager.add(window._content.location, false, IMAGEPERMISSION);
|
||||
},
|
||||
|
||||
// Unblock image from loading in the future.
|
||||
unblockImage : function () {
|
||||
var permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService().QueryInterface(Components.interfaces.nsIPermissionManager);
|
||||
if (!permissionmanager) {
|
||||
return;
|
||||
}
|
||||
permissionmanager.add(window._content.location, true, IMAGEPERMISSION);
|
||||
},
|
||||
|
||||
initImageBlocking : function () {
|
||||
try {
|
||||
// Block image depends on whether an image was clicked on, and,
|
||||
// whether the user pref is enabled.
|
||||
|
||||
gContextMenu.showItem
|
||||
("context-blockimage",
|
||||
gContextMenu.onImage && cookieContextMenu.isBlockingImages());
|
||||
gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
|
||||
cookieContextMenu.isBlockingImages());
|
||||
|
||||
gContextMenu.showItem
|
||||
("context-unblockimage",
|
||||
gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
|
||||
!cookieContextMenu.isBlockingImages());
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
@ -124,5 +144,11 @@
|
||||
oncommand="cookieContextMenu.blockImage();"
|
||||
style="display:none;"
|
||||
insertafter="context-viewimage"/>
|
||||
<menuitem id="context-unblockimage"
|
||||
label="&unblockImageCmd.label;"
|
||||
accesskey=""
|
||||
oncommand="cookieContextMenu.unblockImage();"
|
||||
style="display:none;"
|
||||
insertafter="context-viewimage"/>
|
||||
</popup>
|
||||
</overlay>
|
||||
|
@ -18,6 +18,9 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
var COOKIEPERMISSION = 0;
|
||||
var IMAGEPERMISSION = 1;
|
||||
|
||||
function viewImages() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"modal=yes,chrome,resizable=yes", 2 );
|
||||
|
@ -81,8 +81,6 @@
|
||||
if (!permissionmanager) {
|
||||
return;
|
||||
}
|
||||
var COOKIEPERMISSION = 0;
|
||||
var IMAGEPERMISSION = 1;
|
||||
var element;
|
||||
switch (action) {
|
||||
case "cookieAllow":
|
||||
|
@ -1,2 +1,4 @@
|
||||
<!ENTITY blockImageCmd.label "Block Images from this Server">
|
||||
<!ENTITY blockImageCmd.accesskey "k">
|
||||
<!ENTITY unblockImageCmd.label "Unblock Images from this Server">
|
||||
<!ENTITY unblockImageCmd.accesskey "u">
|
||||
|
@ -81,8 +81,6 @@
|
||||
if (!permissionmanager) {
|
||||
return;
|
||||
}
|
||||
var COOKIEPERMISSION = 0;
|
||||
var IMAGEPERMISSION = 1;
|
||||
var element;
|
||||
switch (action) {
|
||||
case "cookieAllow":
|
||||
|
@ -41,22 +41,10 @@
|
||||
// Determine if "Block Image" is to appear in the menu.
|
||||
// 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 = gContextMenu.getService('@mozilla.org/preferences;1', 'nsIPref');
|
||||
var result = false;
|
||||
try {
|
||||
result = pref.GetBoolPref( "imageblocker.enabled" );
|
||||
} catch(e) {
|
||||
}
|
||||
if (!result) {
|
||||
/* pref is not set so return false */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* determine if image is already being blocked */
|
||||
var permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService().QueryInterface(Components.interfaces.nsIPermissionManager);
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
|
||||
|
||||
var enumerator = permissionmanager.enumerator;
|
||||
@ -81,21 +69,53 @@
|
||||
return true;
|
||||
},
|
||||
|
||||
// Determine if "imageBlocker.enabled" pref is set
|
||||
isPrefSet: function () {
|
||||
var pref = gContextMenu.getService('@mozilla.org/preferences;1', 'nsIPref');
|
||||
var result = false;
|
||||
try {
|
||||
result = pref.GetBoolPref( "imageblocker.enabled" );
|
||||
} catch(e) {
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// Block image from loading in the future.
|
||||
blockImage : function () {
|
||||
var imgmanager =
|
||||
Components.classes["@mozilla.org/imgmanager;1"]
|
||||
.getService().QueryInterface(Components.interfaces.nsIImgManager);
|
||||
imgmanager.block(gContextMenu.imageURL);
|
||||
var permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
if (!permissionmanager) {
|
||||
return;
|
||||
}
|
||||
permissionmanager.add(window._content.location, false, IMAGEPERMISSION);
|
||||
},
|
||||
|
||||
// Unblock image from loading in the future.
|
||||
unblockImage : function () {
|
||||
var permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService().QueryInterface(Components.interfaces.nsIPermissionManager);
|
||||
if (!permissionmanager) {
|
||||
return;
|
||||
}
|
||||
permissionmanager.add(window._content.location, true, IMAGEPERMISSION);
|
||||
},
|
||||
|
||||
initImageBlocking : function () {
|
||||
try {
|
||||
// Block image depends on whether an image was clicked on, and,
|
||||
// whether the user pref is enabled.
|
||||
|
||||
gContextMenu.showItem
|
||||
("context-blockimage",
|
||||
gContextMenu.onImage && cookieContextMenu.isBlockingImages());
|
||||
gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
|
||||
cookieContextMenu.isBlockingImages());
|
||||
|
||||
gContextMenu.showItem
|
||||
("context-unblockimage",
|
||||
gContextMenu.onImage && cookieContextMenu.isPrefSet() &&
|
||||
!cookieContextMenu.isBlockingImages());
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
@ -124,5 +144,11 @@
|
||||
oncommand="cookieContextMenu.blockImage();"
|
||||
style="display:none;"
|
||||
insertafter="context-viewimage"/>
|
||||
<menuitem id="context-unblockimage"
|
||||
label="&unblockImageCmd.label;"
|
||||
accesskey=""
|
||||
oncommand="cookieContextMenu.unblockImage();"
|
||||
style="display:none;"
|
||||
insertafter="context-viewimage"/>
|
||||
</popup>
|
||||
</overlay>
|
||||
|
@ -18,6 +18,9 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
var COOKIEPERMISSION = 0;
|
||||
var IMAGEPERMISSION = 1;
|
||||
|
||||
function viewImages() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"modal=yes,chrome,resizable=yes", 2 );
|
||||
|
@ -1,2 +1,4 @@
|
||||
<!ENTITY blockImageCmd.label "Block Images from this Server">
|
||||
<!ENTITY blockImageCmd.accesskey "k">
|
||||
<!ENTITY unblockImageCmd.label "Unblock Images from this Server">
|
||||
<!ENTITY unblockImageCmd.accesskey "u">
|
||||
|
Loading…
Reference in New Issue
Block a user