#ifdefs for phoenix. NPOB.
This commit is contained in:
Родитель
2e965a9efa
Коммит
9cf9441ddd
|
@ -143,6 +143,10 @@
|
|||
#include "nsIBindingManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
// Used by phoenix to do popup whitelisting
|
||||
#include "nsIPopupWindowManager.h"
|
||||
#endif
|
||||
|
||||
static nsIEntropyCollector* gEntropyCollector = nsnull;
|
||||
static PRInt32 gRefCnt = 0;
|
||||
|
@ -2817,6 +2821,50 @@ GlobalWindowImpl::DisableExternalCapture()
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
static
|
||||
PRBool IsPopupWhitelisted(nsIDOMDocument* aDoc)
|
||||
{
|
||||
// Phoenix whitelists popups. Subvert Mozilla's blacklist implementation and
|
||||
// use it as a whitelist instead. If/when Mozilla receives a patch to do
|
||||
// popup whitelisting, the #ifdefs can be removed, and the right list/api can
|
||||
// be used.
|
||||
PRBool whiteListed = PR_FALSE;
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDoc));
|
||||
nsCOMPtr<nsIPopupWindowManager> pm(do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID));
|
||||
if (pm) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (doc)
|
||||
doc->GetDocumentURL(getter_AddRefs(uri));
|
||||
|
||||
// Allow really means it wasn't in our list. So in Phoenix, we
|
||||
// assume DENY means it's in the whitelist. It's all backwards! Backwards, I say!
|
||||
PRUint32 permission;
|
||||
if (NS_SUCCEEDED(pm->TestPermission(uri, &permission)))
|
||||
whiteListed = (permission == nsIPopupWindowManager::DENY_POPUP);
|
||||
}
|
||||
|
||||
return whiteListed;
|
||||
}
|
||||
|
||||
static
|
||||
void FirePopupBlockedEvent(nsIDOMDocument* aDoc)
|
||||
{
|
||||
if (aDoc) {
|
||||
// Fire a "DOMPopupBlocked" event so that the UI can hear about blocked popups.
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(aDoc));
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
|
||||
if (event) {
|
||||
event->InitEvent(NS_LITERAL_STRING("DOMPopupBlocked"), PR_TRUE, PR_TRUE);
|
||||
PRBool noDefault;
|
||||
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(aDoc));
|
||||
targ->DispatchEvent(event, &noDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Examine the current document state to see if we're in a way that is
|
||||
* typically abused by web designers. This routine returns PR_TRUE if
|
||||
|
@ -2850,7 +2898,14 @@ GlobalWindowImpl::CheckForAbusePoint ()
|
|||
printf ("*** Scripts executed during (un)load or as a result of "
|
||||
"setTimeout() are potential javascript abuse points.\n");
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
// see the definition of the function for details.
|
||||
if (!IsPopupWhitelisted(mDocument))
|
||||
FirePopupBlockedEvent(mDocument);
|
||||
#else
|
||||
return PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
PRInt32 clickDelay = 0;
|
||||
|
@ -2869,7 +2924,14 @@ GlobalWindowImpl::CheckForAbusePoint ()
|
|||
"action are potential javascript abuse points (%i.)\n",
|
||||
clickDelay, delta);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
// see the definition of the function for details.
|
||||
if (!IsPopupWhitelisted(mDocument))
|
||||
FirePopupBlockedEvent(mDocument);
|
||||
#else
|
||||
return PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,6 +170,10 @@ nsWindowCreator::CreateChromeWindow2(nsIWebBrowserChrome *aParent,
|
|||
PRUint32
|
||||
nsWindowCreator::AllowWindowCreation(nsIURI *aURI)
|
||||
{
|
||||
#ifdef MOZ_PHOENIX
|
||||
// Phoenix doesn't check here. It checks over in nsGlobalWindow.cpp.
|
||||
return nsIPopupWindowManager::ALLOW_POPUP;
|
||||
#else
|
||||
nsCOMPtr<nsIPopupWindowManager> pm(do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID));
|
||||
if (!pm)
|
||||
return nsIPopupWindowManager::ALLOW_POPUP;
|
||||
|
@ -178,6 +182,7 @@ nsWindowCreator::AllowWindowCreation(nsIURI *aURI)
|
|||
if (NS_SUCCEEDED(pm->TestPermission(aURI, &permission)))
|
||||
return permission;
|
||||
return nsIPopupWindowManager::ALLOW_POPUP;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче