mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
reinstating earlier version; Txul regression in hand. long live bug 166442 r=jag,jst,et al. still applies
This commit is contained in:
parent
c46608a0c6
commit
fa22b55a15
@ -566,25 +566,45 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent,
|
||||
}
|
||||
|
||||
NS_ASSERTION(mWindowCreator, "attempted to open a new window with no WindowCreator");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (mWindowCreator) {
|
||||
nsCOMPtr<nsIWebBrowserChrome> newChrome;
|
||||
|
||||
// If the window creator is an nsIWindowCreator2, we can give it some hints.
|
||||
/* If the window creator is an nsIWindowCreator2, we can give it
|
||||
some hints. The only hint at this time is whether the opening window
|
||||
is in a situation that's likely to mean this is an unrequested
|
||||
popup window we're creating. However we're not completely honest:
|
||||
we clear that indicator if the opener is chrome, so that the
|
||||
downstream consumer can treat the indicator to mean simply
|
||||
that the new window is subject to popup control. */
|
||||
nsCOMPtr<nsIWindowCreator2> windowCreator2(do_QueryInterface(mWindowCreator));
|
||||
if (windowCreator2) {
|
||||
PRUint32 contextFlags = 0;
|
||||
PRBool popupConditions = PR_FALSE;
|
||||
|
||||
// is the parent under popup conditions?
|
||||
nsCOMPtr<nsPIDOMWindow> piWindow(do_QueryInterface(aParent));
|
||||
if (piWindow) {
|
||||
PRBool parentIsLoadingOrRunningTimeout;
|
||||
piWindow->IsLoadingOrRunningTimeout(&parentIsLoadingOrRunningTimeout);
|
||||
if (parentIsLoadingOrRunningTimeout)
|
||||
contextFlags |= nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
|
||||
if (piWindow)
|
||||
piWindow->IsLoadingOrRunningTimeout(&popupConditions);
|
||||
|
||||
// chrome is always allowed, so clear the flag if the opener is chrome
|
||||
if (popupConditions) {
|
||||
PRBool isChrome = PR_FALSE;
|
||||
nsCOMPtr<nsIScriptSecurityManager>
|
||||
sm(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
|
||||
if (sm)
|
||||
sm->SubjectPrincipalIsSystem(&isChrome);
|
||||
popupConditions = !isChrome;
|
||||
}
|
||||
windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags, contextFlags,
|
||||
getter_AddRefs(newChrome));
|
||||
|
||||
if (popupConditions)
|
||||
contextFlags |= nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
|
||||
|
||||
rv = windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags,
|
||||
contextFlags, getter_AddRefs(newChrome));
|
||||
}
|
||||
else
|
||||
mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags,
|
||||
rv = mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags,
|
||||
getter_AddRefs(newChrome));
|
||||
if (newChrome) {
|
||||
/* It might be a chrome nsXULWindow, in which case it won't have
|
||||
@ -595,13 +615,15 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent,
|
||||
GetWindowTreeItem(newWindow, getter_AddRefs(newDocShellItem));
|
||||
if (!newDocShellItem)
|
||||
newDocShellItem = do_GetInterface(newChrome);
|
||||
if (!newDocShellItem)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// better have a window to use by this point
|
||||
if (!newDocShellItem)
|
||||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
|
||||
rv = ReadyOpenedDocShellItem(newDocShellItem, aParent, _retval);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -32,7 +32,10 @@
|
||||
<![CDATA[
|
||||
/******* THE FOLLOWING IS FOR THE TASKMENU OVERLAY *******/
|
||||
|
||||
// both are necessary. popupmanager is just a special case
|
||||
// of permissionmanager but does extra work on add/remove
|
||||
var permissionmanager;
|
||||
var popupmanager;
|
||||
|
||||
// Remove the image entries from the task menu
|
||||
function HideImage() {
|
||||
@ -41,6 +44,18 @@
|
||||
element.setAttribute("style","display: none;" );
|
||||
element.setAttribute("disabled","true" );
|
||||
}
|
||||
// Remove the popup entries from the task menu
|
||||
function HidePopups(hide) {
|
||||
var element;
|
||||
element = document.getElementById("popup");
|
||||
if (hide) {
|
||||
element.setAttribute("hidden", "true");
|
||||
element.setAttribute("disabled", "true");
|
||||
} else {
|
||||
element.removeAttribute("hidden");
|
||||
element.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// for some unexplainable reason, CheckForImage() keeps getting called repeatedly
|
||||
// as we mouse over the task menu. IMO, that shouldn't be happening. To avoid
|
||||
@ -52,10 +67,14 @@
|
||||
function CheckForVisibility()
|
||||
{
|
||||
|
||||
// obtain access to permissionmanager module
|
||||
// obtain access to permissionmanager and popupmanager
|
||||
// (popup manager is a wrapper around permission that does extra work)
|
||||
permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
popupmanager =
|
||||
Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
if (!("_content" in window) || !window._content) {
|
||||
// this occurs if doing tasks->privacy->cookie->block from java console
|
||||
return;
|
||||
@ -88,16 +107,42 @@
|
||||
disableElement.setAttribute("disabled","true");
|
||||
enableElement.removeAttribute("disabled");
|
||||
|
||||
if (popupmanager.testPermission(getBrowser().currentURI) == Components.interfaces.nsIPopupWindowManager.eDisallow) {
|
||||
disableElement = document.getElementById("BlockPopups");
|
||||
enableElement = document.getElementById("AllowPopups");
|
||||
} else {
|
||||
disableElement = document.getElementById("AllowPopups");
|
||||
enableElement = document.getElementById("BlockPopups");
|
||||
}
|
||||
disableElement.setAttribute("disabled","true");
|
||||
if (popupmanager.testSuitability(getBrowser().currentURI))
|
||||
enableElement.removeAttribute("disabled");
|
||||
else
|
||||
enableElement.setAttribute("disabled","true");
|
||||
|
||||
var pref;
|
||||
pref = Components.classes['@mozilla.org/preferences-service;1'];
|
||||
pref = pref.getService();
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
// hide the popup manager menus if the prefs aren't exactly right.
|
||||
// it'd be nicer to leave it always visible and adjust prefs to match
|
||||
// any user selections
|
||||
try {
|
||||
var hide = pref.getBoolPref("dom.disable_open_during_load");
|
||||
if (!hide)
|
||||
hide = pref.getIntPref("privacy.popups.policy") != Components.interfaces.nsIPopupWindowManager.eAllowConditionally;
|
||||
HidePopups(hide);
|
||||
} catch(e) {
|
||||
HidePopups(true);
|
||||
}
|
||||
|
||||
// determine if image manager should be in the UI
|
||||
if (alreadyCheckedForImage) {
|
||||
return;
|
||||
}
|
||||
alreadyCheckedForImage = true;
|
||||
// remove image functions (unless overruled by the "imageblocker.enabled" pref)
|
||||
var pref;
|
||||
pref = Components.classes['@mozilla.org/preferences-service;1'];
|
||||
pref = pref.getService();
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
try {
|
||||
if (!pref.getBoolPref("imageblocker.enabled")) {
|
||||
HideImage();
|
||||
@ -136,6 +181,16 @@
|
||||
element = document.getElementById("BlockImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "popupAllow":
|
||||
popupmanager.add(getBrowser().currentURI, true);
|
||||
element = document.getElementById("AllowPopups");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "popupBlock":
|
||||
popupmanager.add(getBrowser().currentURI, false);
|
||||
element = document.getElementById("BlockPopups");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -182,5 +237,24 @@
|
||||
oncommand="viewImages();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&cookiePopupManager.label;"
|
||||
accesskey="&cookiePopupManager.accesskey;"
|
||||
id="popup"
|
||||
insertbefore="navBeginGlobalItems">
|
||||
<menupopup>
|
||||
<menuitem id="BlockPopups" label="&cookieBlockPopupsCmd.label;"
|
||||
accesskey="&cookieBlockPopupsCmd.accesskey;"
|
||||
msg="&cookieBlockPopupsMsg.label;"
|
||||
oncommand="CookieImageAction('popupBlock');"/>
|
||||
<menuitem id="AllowPopups" label="&cookieAllowPopupsCmd.label;"
|
||||
accesskey="&cookieAllowPopupsCmd.accesskey;"
|
||||
msg="&cookieAllowPopupsMsg.label;"
|
||||
oncommand="CookieImageAction('popupAllow');"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayPopupsCmd.label;"
|
||||
accesskey="&cookieDisplayPopupsCmd.accesskey;"
|
||||
oncommand="viewPopups();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</overlay>
|
||||
|
@ -20,12 +20,18 @@
|
||||
|
||||
var COOKIEPERMISSION = 0;
|
||||
var IMAGEPERMISSION = 1;
|
||||
var WINDOWPERMISSION = 2;
|
||||
|
||||
function viewImages() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"chrome,resizable=yes", "imageManager" );
|
||||
}
|
||||
|
||||
function viewPopups() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"chrome,resizable=yes", "popupManager" );
|
||||
}
|
||||
|
||||
function viewCookies() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"chrome,resizable=yes", "cookieManager");
|
||||
|
@ -25,8 +25,9 @@
|
||||
var kObserverService;
|
||||
|
||||
// interface variables
|
||||
var cookiemanager = null; // cookiemanager interfa
|
||||
var cookiemanager = null; // cookiemanager interface
|
||||
var permissionmanager = null; // permissionmanager interface
|
||||
var popupmanager = null; // popup manager
|
||||
var gDateService = null;
|
||||
|
||||
// cookies and permissions list
|
||||
@ -35,10 +36,16 @@ var permissions = [];
|
||||
var deletedCookies = [];
|
||||
var deletedPermissions = [];
|
||||
|
||||
// differentiate between cookies and images
|
||||
var isImages = (window.arguments[0] == "imageManager");
|
||||
// differentiate between cookies, images, and popups
|
||||
const cookieType = 0;
|
||||
const imageType = 1;
|
||||
const popupType = 2;
|
||||
|
||||
var dialogType = cookieType;
|
||||
if (window.arguments[0] == "imageManager")
|
||||
dialogType = imageType;
|
||||
else if (window.arguments[0] == "popupManager")
|
||||
dialogType = popupType;
|
||||
|
||||
var cookieBundle;
|
||||
|
||||
@ -49,11 +56,13 @@ function Startup() {
|
||||
// cookieManagerFromIcon
|
||||
// imageManager
|
||||
|
||||
// xpconnect to cookiemanager/permissionmanager interfaces
|
||||
// xpconnect to cookiemanager/permissionmanager/popupmanager interfaces
|
||||
cookiemanager = Components.classes["@mozilla.org/cookiemanager;1"].getService();
|
||||
cookiemanager = cookiemanager.QueryInterface(Components.interfaces.nsICookieManager);
|
||||
permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService();
|
||||
permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager);
|
||||
popupmanager = Components.classes["@mozilla.org/PopupWindowManager;1"].getService();
|
||||
popupmanager = popupmanager.QueryInterface(Components.interfaces.nsIPopupWindowManager);
|
||||
|
||||
// intialize gDateService
|
||||
if (!gDateService) {
|
||||
@ -73,10 +82,10 @@ function Startup() {
|
||||
try {
|
||||
var tabBox = document.getElementById("tabbox");
|
||||
var element;
|
||||
if (!isImages) {
|
||||
if (dialogType == cookieType) {
|
||||
element = document.getElementById("cookiesTab");
|
||||
tabBox.selectedTab = element;
|
||||
} else {
|
||||
} else if (dialogType == imageType) {
|
||||
element = document.getElementById("cookieviewer");
|
||||
element.setAttribute("title", cookieBundle.getString("imageTitle"));
|
||||
element = document.getElementById("permissionsTab");
|
||||
@ -86,6 +95,16 @@ function Startup() {
|
||||
element.value = cookieBundle.getString("textBannedImages");
|
||||
element = document.getElementById("cookiesTab");
|
||||
element.hidden = "true";
|
||||
} else {
|
||||
element = document.getElementById("cookieviewer");
|
||||
element.setAttribute("title", cookieBundle.getString("imageTitle"));
|
||||
element = document.getElementById("permissionsTab");
|
||||
element.label = cookieBundle.getString("tabBannedPopups");
|
||||
tabBox.selectedTab = element;
|
||||
element = document.getElementById("permissionsText");
|
||||
element.value = cookieBundle.getString("textBannedPopups");
|
||||
element = document.getElementById("cookiesTab");
|
||||
element.hidden = "true";
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
@ -93,7 +112,7 @@ function Startup() {
|
||||
// load in the cookies and permissions
|
||||
cookiesTree = document.getElementById("cookiesTree");
|
||||
permissionsTree = document.getElementById("permissionsTree");
|
||||
if (!isImages) {
|
||||
if (dialogType == cookieType) {
|
||||
loadCookies();
|
||||
}
|
||||
loadPermissions();
|
||||
@ -406,17 +425,20 @@ function loadPermissions() {
|
||||
var count = 0;
|
||||
var contentStr;
|
||||
var canStr, cannotStr;
|
||||
if (isImages) {
|
||||
if (dialogType == cookieType) {
|
||||
canStr="can";
|
||||
cannotStr="cannot";
|
||||
} else if (dialogType == imageType) {
|
||||
canStr="canImages";
|
||||
cannotStr="cannotImages";
|
||||
} else {
|
||||
canStr="can";
|
||||
cannotStr="cannot";
|
||||
canStr="canPopups";
|
||||
cannotStr="cannotPopups";
|
||||
}
|
||||
while (enumerator.hasMoreElements()) {
|
||||
var nextPermission = enumerator.getNext();
|
||||
nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
|
||||
if (nextPermission.type == (isImages ? imageType : cookieType)) {
|
||||
if (nextPermission.type == dialogType) {
|
||||
var host = nextPermission.host;
|
||||
permissions[count] =
|
||||
new Permission(count++, host,
|
||||
@ -462,7 +484,16 @@ function DeleteAllPermissions() {
|
||||
}
|
||||
|
||||
function FinalizePermissionDeletions() {
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
for (var p=0; p<deletedPermissions.length; p++) {
|
||||
if (deletedPermissions[p].type == popupType) {
|
||||
// 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;
|
||||
@ -499,10 +530,11 @@ function getSelectedTab()
|
||||
}
|
||||
|
||||
function doHelpButton() {
|
||||
if (isImages) {
|
||||
if (dialogType == imageType) {
|
||||
openHelp("image_mgr");
|
||||
} else {
|
||||
var uri = getSelectedTab();
|
||||
openHelp(uri);
|
||||
}
|
||||
// XXX missing popup help
|
||||
}
|
||||
|
@ -66,21 +66,30 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsWindowCreator.h"
|
||||
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDOMLocation.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIPopupWindowManager.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
nsWindowCreator::nsWindowCreator() {
|
||||
NS_INIT_ISUPPORTS();
|
||||
@ -89,21 +98,44 @@ nsWindowCreator::nsWindowCreator() {
|
||||
nsWindowCreator::~nsWindowCreator() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsWindowCreator, nsIWindowCreator)
|
||||
NS_IMPL_ISUPPORTS2(nsWindowCreator, nsIWindowCreator, nsIWindowCreator2)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
return CreateChromeWindow2(aParent, aChromeFlags, 0, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowCreator::CreateChromeWindow2(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
PRUint32 aContextFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = 0;
|
||||
|
||||
PRUint32 allow = nsIPopupWindowManager::eAllow;
|
||||
nsCOMPtr<nsIURI> parentURI;
|
||||
|
||||
GetParentURI(aParent, getter_AddRefs(parentURI));
|
||||
if (aContextFlags & PARENT_IS_LOADING_OR_RUNNING_TIMEOUT)
|
||||
allow = AllowWindowCreation(parentURI);
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
|
||||
if (aParent) {
|
||||
if (allow == nsIPopupWindowManager::eDisallow)
|
||||
return NS_OK; // ruse to not give scripts a catchable error
|
||||
if (allow == nsIPopupWindowManager::eAllow &&
|
||||
(aContextFlags & PARENT_IS_LOADING_OR_RUNNING_TIMEOUT))
|
||||
aContextFlags &= ~PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> xulParent(do_GetInterface(aParent));
|
||||
NS_ASSERTION(xulParent, "window created using non-XUL parent. that's unexpected, but may work.");
|
||||
|
||||
if (xulParent)
|
||||
xulParent->CreateNewWindow(aChromeFlags, getter_AddRefs(newWindow));
|
||||
// And if it fails, don't try again without a parent. It could fail
|
||||
@ -125,10 +157,49 @@ nsWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
}
|
||||
|
||||
// if anybody gave us anything to work with, use it
|
||||
if (newWindow) {
|
||||
newWindow->SetContextFlags(aContextFlags);
|
||||
nsCOMPtr<nsIInterfaceRequestor> thing(do_QueryInterface(newWindow));
|
||||
if (thing)
|
||||
thing->GetInterface(NS_GET_IID(nsIWebBrowserChrome), (void **) _retval);
|
||||
}
|
||||
|
||||
return *_retval ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsWindowCreator::AllowWindowCreation(nsIURI *aURI)
|
||||
{
|
||||
nsCOMPtr<nsIPopupWindowManager> pm(do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID));
|
||||
if (!pm)
|
||||
return nsIPopupWindowManager::eAllow;
|
||||
|
||||
PRUint32 permission;
|
||||
if (NS_SUCCEEDED(pm->TestPermission(aURI, &permission)))
|
||||
return permission;
|
||||
return nsIPopupWindowManager::eAllow;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindowCreator::GetParentURI(nsIWebBrowserChrome *aParent, nsIURI **aURI)
|
||||
{
|
||||
if (!aParent)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner(do_GetInterface(aParent));
|
||||
if (treeOwner) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> content;
|
||||
treeOwner->GetPrimaryContentShell(getter_AddRefs(content));
|
||||
nsCOMPtr<nsIDOMWindowInternal> domParent(do_GetInterface(content));
|
||||
if (domParent) {
|
||||
nsCOMPtr<nsIDOMLocation> location;
|
||||
domParent->GetLocation(getter_AddRefs(location));
|
||||
if (location) {
|
||||
nsAutoString url;
|
||||
location->GetHref(url);
|
||||
NS_NewURI(aURI, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,12 @@
|
||||
#ifndef __nsWindowCreator_h_
|
||||
#define __nsWindowCreator_h_
|
||||
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIWindowCreator2.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
class nsWindowCreator :
|
||||
public nsIWindowCreator
|
||||
public nsIWindowCreator2
|
||||
{
|
||||
public:
|
||||
nsWindowCreator();
|
||||
@ -49,6 +51,11 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIWINDOWCREATOR2
|
||||
|
||||
private:
|
||||
PRUint32 AllowWindowCreation(nsIURI *aURI);
|
||||
void GetParentURI(nsIWebBrowserChrome *aParent, nsIURI **aURI);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -32,7 +32,10 @@
|
||||
<![CDATA[
|
||||
/******* THE FOLLOWING IS FOR THE TASKMENU OVERLAY *******/
|
||||
|
||||
// both are necessary. popupmanager is just a special case
|
||||
// of permissionmanager but does extra work on add/remove
|
||||
var permissionmanager;
|
||||
var popupmanager;
|
||||
|
||||
// Remove the image entries from the task menu
|
||||
function HideImage() {
|
||||
@ -41,6 +44,18 @@
|
||||
element.setAttribute("style","display: none;" );
|
||||
element.setAttribute("disabled","true" );
|
||||
}
|
||||
// Remove the popup entries from the task menu
|
||||
function HidePopups(hide) {
|
||||
var element;
|
||||
element = document.getElementById("popup");
|
||||
if (hide) {
|
||||
element.setAttribute("hidden", "true");
|
||||
element.setAttribute("disabled", "true");
|
||||
} else {
|
||||
element.removeAttribute("hidden");
|
||||
element.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// for some unexplainable reason, CheckForImage() keeps getting called repeatedly
|
||||
// as we mouse over the task menu. IMO, that shouldn't be happening. To avoid
|
||||
@ -52,10 +67,14 @@
|
||||
function CheckForVisibility()
|
||||
{
|
||||
|
||||
// obtain access to permissionmanager module
|
||||
// obtain access to permissionmanager and popupmanager
|
||||
// (popup manager is a wrapper around permission that does extra work)
|
||||
permissionmanager =
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager);
|
||||
popupmanager =
|
||||
Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
if (!("_content" in window) || !window._content) {
|
||||
// this occurs if doing tasks->privacy->cookie->block from java console
|
||||
return;
|
||||
@ -88,16 +107,42 @@
|
||||
disableElement.setAttribute("disabled","true");
|
||||
enableElement.removeAttribute("disabled");
|
||||
|
||||
if (popupmanager.testPermission(getBrowser().currentURI) == Components.interfaces.nsIPopupWindowManager.eDisallow) {
|
||||
disableElement = document.getElementById("BlockPopups");
|
||||
enableElement = document.getElementById("AllowPopups");
|
||||
} else {
|
||||
disableElement = document.getElementById("AllowPopups");
|
||||
enableElement = document.getElementById("BlockPopups");
|
||||
}
|
||||
disableElement.setAttribute("disabled","true");
|
||||
if (popupmanager.testSuitability(getBrowser().currentURI))
|
||||
enableElement.removeAttribute("disabled");
|
||||
else
|
||||
enableElement.setAttribute("disabled","true");
|
||||
|
||||
var pref;
|
||||
pref = Components.classes['@mozilla.org/preferences-service;1'];
|
||||
pref = pref.getService();
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
// hide the popup manager menus if the prefs aren't exactly right.
|
||||
// it'd be nicer to leave it always visible and adjust prefs to match
|
||||
// any user selections
|
||||
try {
|
||||
var hide = pref.getBoolPref("dom.disable_open_during_load");
|
||||
if (!hide)
|
||||
hide = pref.getIntPref("privacy.popups.policy") != Components.interfaces.nsIPopupWindowManager.eAllowConditionally;
|
||||
HidePopups(hide);
|
||||
} catch(e) {
|
||||
HidePopups(true);
|
||||
}
|
||||
|
||||
// determine if image manager should be in the UI
|
||||
if (alreadyCheckedForImage) {
|
||||
return;
|
||||
}
|
||||
alreadyCheckedForImage = true;
|
||||
// remove image functions (unless overruled by the "imageblocker.enabled" pref)
|
||||
var pref;
|
||||
pref = Components.classes['@mozilla.org/preferences-service;1'];
|
||||
pref = pref.getService();
|
||||
pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
try {
|
||||
if (!pref.getBoolPref("imageblocker.enabled")) {
|
||||
HideImage();
|
||||
@ -136,6 +181,16 @@
|
||||
element = document.getElementById("BlockImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "popupAllow":
|
||||
popupmanager.add(getBrowser().currentURI, true);
|
||||
element = document.getElementById("AllowPopups");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "popupBlock":
|
||||
popupmanager.add(getBrowser().currentURI, false);
|
||||
element = document.getElementById("BlockPopups");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@ -182,5 +237,24 @@
|
||||
oncommand="viewImages();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&cookiePopupManager.label;"
|
||||
accesskey="&cookiePopupManager.accesskey;"
|
||||
id="popup"
|
||||
insertbefore="navBeginGlobalItems">
|
||||
<menupopup>
|
||||
<menuitem id="BlockPopups" label="&cookieBlockPopupsCmd.label;"
|
||||
accesskey="&cookieBlockPopupsCmd.accesskey;"
|
||||
msg="&cookieBlockPopupsMsg.label;"
|
||||
oncommand="CookieImageAction('popupBlock');"/>
|
||||
<menuitem id="AllowPopups" label="&cookieAllowPopupsCmd.label;"
|
||||
accesskey="&cookieAllowPopupsCmd.accesskey;"
|
||||
msg="&cookieAllowPopupsMsg.label;"
|
||||
oncommand="CookieImageAction('popupAllow');"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&cookieDisplayPopupsCmd.label;"
|
||||
accesskey="&cookieDisplayPopupsCmd.accesskey;"
|
||||
oncommand="viewPopups();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</overlay>
|
||||
|
@ -20,12 +20,18 @@
|
||||
|
||||
var COOKIEPERMISSION = 0;
|
||||
var IMAGEPERMISSION = 1;
|
||||
var WINDOWPERMISSION = 2;
|
||||
|
||||
function viewImages() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"chrome,resizable=yes", "imageManager" );
|
||||
}
|
||||
|
||||
function viewPopups() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"chrome,resizable=yes", "popupManager" );
|
||||
}
|
||||
|
||||
function viewCookies() {
|
||||
window.openDialog("chrome://communicator/content/wallet/CookieViewer.xul","_blank",
|
||||
"chrome,resizable=yes", "cookieManager");
|
||||
|
Loading…
x
Reference in New Issue
Block a user