зеркало из https://github.com/mozilla/gecko-dev.git
bloody hell. backing out the rest of popup manager because of a suspected Txul regression. bug 167929
This commit is contained in:
Родитель
997fa879e8
Коммит
cb279f2219
|
@ -566,46 +566,26 @@ 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. 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. */
|
||||
// If the window creator is an nsIWindowCreator2, we can give it some hints.
|
||||
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)
|
||||
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;
|
||||
if (piWindow) {
|
||||
PRBool parentIsLoadingOrRunningTimeout;
|
||||
piWindow->IsLoadingOrRunningTimeout(&parentIsLoadingOrRunningTimeout);
|
||||
if (parentIsLoadingOrRunningTimeout)
|
||||
contextFlags |= nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
|
||||
}
|
||||
|
||||
if (popupConditions)
|
||||
contextFlags |= nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
|
||||
|
||||
rv = windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags,
|
||||
contextFlags, getter_AddRefs(newChrome));
|
||||
windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags, contextFlags,
|
||||
getter_AddRefs(newChrome));
|
||||
}
|
||||
else
|
||||
rv = mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags,
|
||||
getter_AddRefs(newChrome));
|
||||
mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags,
|
||||
getter_AddRefs(newChrome));
|
||||
if (newChrome) {
|
||||
/* It might be a chrome nsXULWindow, in which case it won't have
|
||||
an nsIDOMWindow (primary content shell). But in that case, it'll
|
||||
|
@ -615,15 +595,13 @@ 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 rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = ReadyOpenedDocShellItem(newDocShellItem, aParent, _retval);
|
||||
if (NS_FAILED(rv))
|
||||
|
|
|
@ -32,10 +32,7 @@
|
|||
<![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() {
|
||||
|
@ -44,18 +41,6 @@
|
|||
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
|
||||
|
@ -67,14 +52,10 @@
|
|||
function CheckForVisibility()
|
||||
{
|
||||
|
||||
// obtain access to permissionmanager and popupmanager
|
||||
// (popup manager is a wrapper around permission that does extra work)
|
||||
// obtain access to permissionmanager module
|
||||
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;
|
||||
|
@ -107,35 +88,16 @@
|
|||
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);
|
||||
// try {
|
||||
// HidePopups(!pref.getBoolPref("dom.disable_open_during_load"));
|
||||
// } 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();
|
||||
|
@ -174,16 +136,6 @@
|
|||
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:
|
||||
}
|
||||
}
|
||||
|
@ -230,24 +182,5 @@
|
|||
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,18 +20,12 @@
|
|||
|
||||
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,9 +25,8 @@
|
|||
var kObserverService;
|
||||
|
||||
// interface variables
|
||||
var cookiemanager = null; // cookiemanager interface
|
||||
var cookiemanager = null; // cookiemanager interfa
|
||||
var permissionmanager = null; // permissionmanager interface
|
||||
var popupmanager = null; // popup manager
|
||||
var gDateService = null;
|
||||
|
||||
// cookies and permissions list
|
||||
|
@ -36,16 +35,10 @@ var permissions = [];
|
|||
var deletedCookies = [];
|
||||
var deletedPermissions = [];
|
||||
|
||||
// differentiate between cookies, images, and popups
|
||||
// differentiate between cookies and images
|
||||
var isImages = (window.arguments[0] == "imageManager");
|
||||
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;
|
||||
|
||||
|
@ -56,13 +49,11 @@ function Startup() {
|
|||
// cookieManagerFromIcon
|
||||
// imageManager
|
||||
|
||||
// xpconnect to cookiemanager/permissionmanager/popupmanager interfaces
|
||||
// xpconnect to cookiemanager/permissionmanager 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) {
|
||||
|
@ -82,10 +73,10 @@ function Startup() {
|
|||
try {
|
||||
var tabBox = document.getElementById("tabbox");
|
||||
var element;
|
||||
if (dialogType == cookieType) {
|
||||
if (!isImages) {
|
||||
element = document.getElementById("cookiesTab");
|
||||
tabBox.selectedTab = element;
|
||||
} else if (dialogType == imageType) {
|
||||
} else {
|
||||
element = document.getElementById("cookieviewer");
|
||||
element.setAttribute("title", cookieBundle.getString("imageTitle"));
|
||||
element = document.getElementById("permissionsTab");
|
||||
|
@ -95,16 +86,6 @@ 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) {
|
||||
}
|
||||
|
@ -112,7 +93,7 @@ function Startup() {
|
|||
// load in the cookies and permissions
|
||||
cookiesTree = document.getElementById("cookiesTree");
|
||||
permissionsTree = document.getElementById("permissionsTree");
|
||||
if (dialogType == cookieType) {
|
||||
if (!isImages) {
|
||||
loadCookies();
|
||||
}
|
||||
loadPermissions();
|
||||
|
@ -425,20 +406,17 @@ function loadPermissions() {
|
|||
var count = 0;
|
||||
var contentStr;
|
||||
var canStr, cannotStr;
|
||||
if (dialogType == cookieType) {
|
||||
canStr="can";
|
||||
cannotStr="cannot";
|
||||
} else if (dialogType == imageType) {
|
||||
if (isImages) {
|
||||
canStr="canImages";
|
||||
cannotStr="cannotImages";
|
||||
} else {
|
||||
canStr="canPopups";
|
||||
cannotStr="cannotPopups";
|
||||
canStr="can";
|
||||
cannotStr="cannot";
|
||||
}
|
||||
while (enumerator.hasMoreElements()) {
|
||||
var nextPermission = enumerator.getNext();
|
||||
nextPermission = nextPermission.QueryInterface(Components.interfaces.nsIPermission);
|
||||
if (nextPermission.type == dialogType) {
|
||||
if (nextPermission.type == (isImages ? imageType : cookieType)) {
|
||||
var host = nextPermission.host;
|
||||
permissions[count] =
|
||||
new Permission(count++, host,
|
||||
|
@ -484,17 +462,8 @@ 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);
|
||||
permissionmanager.remove(deletedPermissions[p].host, deletedPermissions[p].type);
|
||||
}
|
||||
deletedPermissions.length = 0;
|
||||
}
|
||||
|
@ -530,11 +499,10 @@ function getSelectedTab()
|
|||
}
|
||||
|
||||
function doHelpButton() {
|
||||
if (dialogType == imageType) {
|
||||
if (isImages) {
|
||||
openHelp("image_mgr");
|
||||
} else {
|
||||
var uri = getSelectedTab();
|
||||
openHelp(uri);
|
||||
}
|
||||
// XXX missing popup help
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "nsIEmbeddingSiteWindow2.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIWindowCreator2.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIXULBrowserWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -654,11 +653,6 @@ NS_IMETHODIMP nsContentTreeOwner::ApplyChromeFlags()
|
|||
the 'chromehidden' attribute of the <window> tag. */
|
||||
nsAutoString newvalue;
|
||||
|
||||
PRUint32 contextFlags;
|
||||
mXULWindow->GetContextFlags(&contextFlags);
|
||||
if (! (contextFlags & nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT))
|
||||
newvalue.Append(NS_LITERAL_STRING("popupcontrol "));
|
||||
|
||||
if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR))
|
||||
newvalue.Append(NS_LITERAL_STRING("menubar "));
|
||||
|
||||
|
|
|
@ -64,38 +64,23 @@
|
|||
Mozilla version, which calls through to nsAppShellService.
|
||||
*/
|
||||
|
||||
#ifdef USE_POPUP_MANAGER
|
||||
#undef USE_POPUP_MANAGER
|
||||
#endif
|
||||
|
||||
#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 "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#ifdef USE_POPUP_MANAGER
|
||||
#include "nsIPopupWindowManager.h"
|
||||
#endif
|
||||
|
||||
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();
|
||||
|
@ -104,48 +89,21 @@ nsWindowCreator::nsWindowCreator() {
|
|||
nsWindowCreator::~nsWindowCreator() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsWindowCreator, nsIWindowCreator, nsIWindowCreator2)
|
||||
NS_IMPL_ISUPPORTS1(nsWindowCreator, nsIWindowCreator)
|
||||
|
||||
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;
|
||||
|
||||
#ifdef USE_POPUP_MANAGER
|
||||
PRUint32 allow = nsIPopupWindowManager::eAllow;
|
||||
nsCOMPtr<nsIURI> parentURI;
|
||||
|
||||
GetParentURI(aParent, getter_AddRefs(parentURI));
|
||||
if (aContextFlags & PARENT_IS_LOADING_OR_RUNNING_TIMEOUT)
|
||||
allow = AllowWindowCreation(parentURI);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
|
||||
if (aParent) {
|
||||
#ifdef USE_POPUP_MANAGER
|
||||
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;
|
||||
#endif
|
||||
|
||||
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
|
||||
|
@ -167,53 +125,10 @@ nsWindowCreator::CreateChromeWindow2(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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
#ifdef USE_POPUP_MANAGER
|
||||
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;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
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,12 +38,10 @@
|
|||
#ifndef __nsWindowCreator_h_
|
||||
#define __nsWindowCreator_h_
|
||||
|
||||
#include "nsIWindowCreator2.h"
|
||||
|
||||
class nsIURI;
|
||||
#include "nsIWindowCreator.h"
|
||||
|
||||
class nsWindowCreator :
|
||||
public nsIWindowCreator2
|
||||
public nsIWindowCreator
|
||||
{
|
||||
public:
|
||||
nsWindowCreator();
|
||||
|
@ -51,11 +49,6 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIWINDOWCREATOR2
|
||||
|
||||
private:
|
||||
PRUint32 AllowWindowCreation(nsIURI *aURI);
|
||||
void GetParentURI(nsIWebBrowserChrome *aParent, nsIURI **aURI);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,28 +63,11 @@ var appCore = null;
|
|||
|
||||
//cached elements
|
||||
var gBrowser = null;
|
||||
var gOpenerOrgURI = null; // opener's URI at time of opening
|
||||
|
||||
// focused frame URL
|
||||
var gFocusedURL = null;
|
||||
var gFocusedDocument = null;
|
||||
|
||||
const gPopupPermListener = {
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
if (topic != "popup perm change")
|
||||
return;
|
||||
|
||||
if (!gOpenerOrgURI)
|
||||
return;
|
||||
|
||||
var pm = Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
var checkbox = document.getElementById("popup-checkbox");
|
||||
checkbox.checked = pm.testPermission(gOpenerOrgURI) != Components.interfaces.nsIPopupWindowManager.eDisallow;
|
||||
}
|
||||
};
|
||||
|
||||
// Pref listener constants
|
||||
const gButtonPrefListener =
|
||||
{
|
||||
|
@ -172,26 +155,6 @@ function removePrefListener(observer)
|
|||
}
|
||||
}
|
||||
|
||||
function addPopupPermListener(observer)
|
||||
{
|
||||
try {
|
||||
var pm = Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
pm.addObserver(observer);
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
function removePopupPermListener(observer)
|
||||
{
|
||||
try {
|
||||
var pm = Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
pm.removeObserver(observer);
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We can avoid adding multiple load event listeners and save some time by adding
|
||||
* one listener that calls all real handlers.
|
||||
|
@ -415,7 +378,6 @@ function Startup()
|
|||
addPrefListener(gButtonPrefListener);
|
||||
addPrefListener(gTabStripPrefListener);
|
||||
addPrefListener(gHomepagePrefListener);
|
||||
//addPopupPermListener(gPopupPermListener);
|
||||
|
||||
window.browserContentListener =
|
||||
new nsBrowserContentListener(window, getBrowser());
|
||||
|
@ -540,9 +502,6 @@ function Startup()
|
|||
|
||||
// now load bookmarks after a delay
|
||||
setTimeout(LoadBookmarksCallback, 0);
|
||||
|
||||
// initialize this checkbox after the rest of the onload sequence has completed
|
||||
//setTimeout(initPopupCheckbox, 0);
|
||||
}
|
||||
|
||||
function LoadBookmarksCallback()
|
||||
|
@ -617,7 +576,6 @@ function Shutdown()
|
|||
removePrefListener(gButtonPrefListener);
|
||||
removePrefListener(gTabStripPrefListener);
|
||||
removePrefListener(gHomepagePrefListener);
|
||||
//removePopupPermListener(gPopupPermListener);
|
||||
|
||||
window.browserContentListener.close();
|
||||
// Close the app core.
|
||||
|
@ -1995,47 +1953,3 @@ function checkTheme()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function popupCheckboxClick(aCheckbox)
|
||||
{
|
||||
if (!gOpenerOrgURI)
|
||||
return;
|
||||
|
||||
try {
|
||||
var pm = Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
pm.add(gOpenerOrgURI, aCheckbox.checked);
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
function initPopupCheckbox()
|
||||
{
|
||||
if (!window.content || !window.content.opener)
|
||||
return;
|
||||
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var spec = Components.lookupMethod(window.content.opener, "location").call(location);
|
||||
gOpenerOrgURI = ioService.newURI(spec, null, null);
|
||||
|
||||
var valid = false;
|
||||
var hostname = window.content.opener.location.hostname;
|
||||
|
||||
if (hostname) {
|
||||
try {
|
||||
var pm = Components.classes["@mozilla.org/PopupWindowManager;1"]
|
||||
.getService(Components.interfaces.nsIPopupWindowManager);
|
||||
valid = pm.testSuitability(gOpenerOrgURI);
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
var checkbox = document.getElementById("popup-checkbox");
|
||||
if (valid)
|
||||
checkbox.setAttribute("tooltiptext", hostname);
|
||||
else {
|
||||
checkbox.setAttribute("tooltiptext", gNavigatorBundle.getString("noPopupControl"));
|
||||
checkbox.setAttribute("disabled", true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,7 @@
|
|||
<![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() {
|
||||
|
@ -44,18 +41,6 @@
|
|||
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
|
||||
|
@ -67,14 +52,10 @@
|
|||
function CheckForVisibility()
|
||||
{
|
||||
|
||||
// obtain access to permissionmanager and popupmanager
|
||||
// (popup manager is a wrapper around permission that does extra work)
|
||||
// obtain access to permissionmanager module
|
||||
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;
|
||||
|
@ -107,35 +88,16 @@
|
|||
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);
|
||||
// try {
|
||||
// HidePopups(!pref.getBoolPref("dom.disable_open_during_load"));
|
||||
// } 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();
|
||||
|
@ -174,16 +136,6 @@
|
|||
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:
|
||||
}
|
||||
}
|
||||
|
@ -230,24 +182,5 @@
|
|||
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,18 +20,12 @@
|
|||
|
||||
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");
|
||||
|
|
Загрузка…
Ссылка в новой задаче