bug #65777 (r=valeski, sr=mscott) - Window targeting fixes...
git-svn-id: svn://10.0.0.236/trunk@94842 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
3a374455ca
commit
9c40a95650
@ -64,18 +64,18 @@ NS_INTERFACE_MAP_END
|
||||
// nsDSURIContentListener::nsIURIContentListener
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
|
||||
{
|
||||
if(mParentContentListener)
|
||||
return mParentContentListener->OnStartURIOpen(aURI, aWindowTarget,
|
||||
aAbortOpen);
|
||||
return mParentContentListener->OnStartURIOpen(aURI, aAbortOpen);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDSURIContentListener::GetProtocolHandler(nsIURI* aURI,
|
||||
nsIProtocolHandler** aProtocolHandler)
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::GetProtocolHandler(nsIURI* aURI,
|
||||
nsIProtocolHandler** aProtocolHandler)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProtocolHandler);
|
||||
NS_ENSURE_ARG(aURI);
|
||||
@ -88,11 +88,14 @@ NS_IMETHODIMP nsDSURIContentListener::GetProtocolHandler(nsIURI* aURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType,
|
||||
nsURILoadCommand aCommand, const char* aWindowTarget,
|
||||
nsIRequest* request, nsIStreamListener** aContentHandler,
|
||||
PRBool* aAbortProcess)
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::DoContent(const char* aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
nsIRequest* request,
|
||||
nsIStreamListener** aContentHandler,
|
||||
PRBool* aAbortProcess)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aContentHandler);
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||
if(aAbortProcess)
|
||||
@ -113,8 +116,7 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType,
|
||||
mDocShell->StopLoad();
|
||||
}
|
||||
|
||||
nsresult rv = mDocShell->CreateContentViewer(aContentType,
|
||||
request, aContentHandler);
|
||||
rv = mDocShell->CreateContentViewer(aContentType, request, aContentHandler);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE; // it's okay if we don't know how to handle the content
|
||||
|
||||
if(loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
||||
@ -123,8 +125,11 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDSURIContentListener::IsPreferred(const char* aContentType,
|
||||
nsURILoadCommand aCommand, const char* aWindowTarget, char ** aDesiredContentType, PRBool* aCanHandle)
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::IsPreferred(const char* aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
char ** aDesiredContentType,
|
||||
PRBool* aCanHandle)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCanHandle);
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
@ -133,8 +138,10 @@ NS_IMETHODIMP nsDSURIContentListener::IsPreferred(const char* aContentType,
|
||||
// It needs to ask it's parent if it is the preferred content handler or not...
|
||||
|
||||
if(mParentContentListener)
|
||||
return mParentContentListener->IsPreferred(aContentType, aCommand,
|
||||
aWindowTarget, aDesiredContentType, aCanHandle);
|
||||
return mParentContentListener->IsPreferred(aContentType,
|
||||
aCommand,
|
||||
aDesiredContentType,
|
||||
aCanHandle);
|
||||
else
|
||||
{
|
||||
// we used to return false here if we didn't have a parent properly registered at the top of
|
||||
@ -144,32 +151,35 @@ NS_IMETHODIMP nsDSURIContentListener::IsPreferred(const char* aContentType,
|
||||
// because we said we weren't the preferred handler type. I'm going to change the default now...if we can handle the
|
||||
// content, and someone didn't EXPLICITLY set a nsIURIContentListener at the top of our docshell chain, then we'll
|
||||
// now always attempt to process the content ourselves...
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType, aCanHandle);
|
||||
return CanHandleContent(aContentType, aCommand, aDesiredContentType, aCanHandle);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
||||
nsURILoadCommand aCommand, const char* aWindowTarget, char ** aDesiredContentType, PRBool* aCanHandleContent)
|
||||
NS_IMETHODIMP
|
||||
nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
char ** aDesiredContentType,
|
||||
PRBool* aCanHandleContent)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aCanHandleContent);
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
|
||||
if (aContentType)
|
||||
{
|
||||
nsXPIDLCString value;
|
||||
nsresult rv = mCatMgr->GetCategoryEntry("Gecko-Content-Viewers", aContentType,
|
||||
rv = mCatMgr->GetCategoryEntry("Gecko-Content-Viewers",
|
||||
aContentType,
|
||||
getter_Copies(value));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (value && *value)
|
||||
*aCanHandleContent = PR_TRUE;
|
||||
else
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
}
|
||||
else
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -78,6 +78,10 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsICachingChannel.h"
|
||||
|
||||
// The following are for bug #13871: Prevent frameset spoofing
|
||||
#include "nsICodebasePrincipal.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
// For reporting errors with the console service.
|
||||
// These can go away if error reporting is propagated up past nsDocShell.
|
||||
#include "nsIConsoleService.h"
|
||||
@ -114,7 +118,6 @@ static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
static NS_DEFINE_CID(kDocumentCharsetInfoCID, NS_DOCUMENTCHARSETINFO_CID);
|
||||
static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
static NS_DEFINE_CID(kSecurityManagerCID, NS_SCRIPTSECURITYMANAGER_CID);
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
@ -403,11 +406,13 @@ nsDocShell::ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType)
|
||||
// nsDocShell::nsIDocShell
|
||||
//*****************************************************************************
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURI(nsIURI * aURI, nsIDocShellLoadInfo * aLoadInfo,
|
||||
PRUint32 aLoadFlags)
|
||||
nsDocShell::LoadURI(nsIURI * aURI,
|
||||
nsIDocShellLoadInfo * aLoadInfo,
|
||||
PRUint32 aLoadFlags)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
nsCOMPtr<nsIInputStream> postStream;
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
PRBool inheritOwner = PR_FALSE;
|
||||
PRBool stopActiveDoc = PR_FALSE;
|
||||
@ -458,6 +463,7 @@ nsDocShell::LoadURI(nsIURI * aURI, nsIDocShellLoadInfo * aLoadInfo,
|
||||
aLoadInfo->GetStopActiveDocument(&stopActiveDoc);
|
||||
aLoadInfo->GetSHEntry(getter_AddRefs(shEntry));
|
||||
aLoadInfo->GetTarget(getter_Copies(target));
|
||||
aLoadInfo->GetPostDataStream(getter_AddRefs(postStream));
|
||||
}
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
@ -506,10 +512,21 @@ nsDocShell::LoadURI(nsIURI * aURI, nsIDocShellLoadInfo * aLoadInfo,
|
||||
|
||||
rv = LoadHistoryEntry(shEntry, loadType);
|
||||
}
|
||||
// Perform the load...
|
||||
else {
|
||||
rv = InternalLoad(aURI, referrer, owner, inheritOwner, stopActiveDoc,
|
||||
(const char *) target, nsnull, nsnull, loadType,
|
||||
nsnull);
|
||||
nsAutoString windowTarget;
|
||||
windowTarget.AssignWithConversion(target);
|
||||
|
||||
rv = InternalLoad(aURI,
|
||||
referrer,
|
||||
owner,
|
||||
inheritOwner,
|
||||
stopActiveDoc,
|
||||
windowTarget.GetUnicode(),
|
||||
postStream,
|
||||
nsnull, // No headers stream
|
||||
loadType,
|
||||
nsnull); // No SHEntry
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -593,7 +610,7 @@ nsDocShell::LoadStream(nsIInputStream * aStream, nsIURI * aURI,
|
||||
NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(DoChannelLoad
|
||||
(channel, nsIURILoader::viewNormal, nsnull, uriLoader),
|
||||
(channel, nsIURILoader::viewNormal, uriLoader),
|
||||
NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -636,6 +653,285 @@ nsDocShell::StopLoad()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
// Check if origin document uri is the equivalent to target's principal.
|
||||
// This takes into account subdomain checking if document.domain is set for
|
||||
// Nav 4.x compatability.
|
||||
//
|
||||
// The following was derived from nsCodeBasePrincipal::Equals but in addition
|
||||
// to the host PL_strcmp, it accepts a subdomain (nsHTMLDocument::SetDomain)
|
||||
// if the document.domain was set.
|
||||
//
|
||||
static
|
||||
PRBool SameOrSubdomainOfTarget(nsIURI* aOriginURI, nsIURI* aTargetURI, PRBool aDocumentDomainSet)
|
||||
{
|
||||
nsXPIDLCString targetScheme;
|
||||
nsresult rv = aTargetURI->GetScheme(getter_Copies(targetScheme));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetScheme, PR_TRUE);
|
||||
|
||||
nsXPIDLCString originScheme;
|
||||
rv = aOriginURI->GetScheme(getter_Copies(originScheme));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originScheme, PR_TRUE);
|
||||
|
||||
if (PL_strcmp(targetScheme, originScheme))
|
||||
return PR_FALSE; // Different schemes - check fails
|
||||
|
||||
if (! PL_strcmp(targetScheme, "file"))
|
||||
return PR_TRUE; // All file: urls are considered to have the same origin.
|
||||
|
||||
if (! PL_strcmp(targetScheme, "imap") ||
|
||||
! PL_strcmp(targetScheme, "mailbox") ||
|
||||
! PL_strcmp(targetScheme, "news"))
|
||||
{
|
||||
|
||||
// Each message is a distinct trust domain; use the whole spec for comparison
|
||||
nsXPIDLCString targetSpec;
|
||||
rv =aTargetURI->GetSpec(getter_Copies(targetSpec));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetSpec, PR_TRUE);
|
||||
|
||||
nsXPIDLCString originSpec;
|
||||
rv = aOriginURI->GetSpec(getter_Copies(originSpec));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originSpec, PR_TRUE);
|
||||
|
||||
return (! PL_strcmp(targetSpec, originSpec)); // True if full spec is same, false otherwise
|
||||
}
|
||||
|
||||
// Compare ports.
|
||||
int targetPort, originPort;
|
||||
rv = aTargetURI->GetPort(&targetPort);
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), PR_TRUE);
|
||||
|
||||
rv = aOriginURI->GetPort(&originPort);
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), PR_TRUE);
|
||||
|
||||
if (targetPort != originPort)
|
||||
return PR_FALSE; // Different port - check fails
|
||||
|
||||
// Need to check the hosts
|
||||
nsXPIDLCString targetHost;
|
||||
rv = aTargetURI->GetHost(getter_Copies(targetHost));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetHost, PR_TRUE);
|
||||
|
||||
nsXPIDLCString originHost;
|
||||
rv = aOriginURI->GetHost(getter_Copies(originHost));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originHost, PR_TRUE);
|
||||
|
||||
if (!PL_strcmp(targetHost, originHost))
|
||||
return PR_TRUE; // Hosts are the same - check passed
|
||||
|
||||
// If document.domain was set, do the relaxed check
|
||||
// Right align hostnames and compare - ensure preceeding char is . or /
|
||||
if (aDocumentDomainSet)
|
||||
{
|
||||
int targetHostLen = PL_strlen(targetHost);
|
||||
int originHostLen = PL_strlen(originHost);
|
||||
int prefixChar = originHostLen-targetHostLen-1;
|
||||
|
||||
return ((originHostLen > targetHostLen) &&
|
||||
(! PL_strcmp((originHost+prefixChar+1), targetHost)) &&
|
||||
(originHost[prefixChar] == '.' || originHost[prefixChar] == '/'));
|
||||
}
|
||||
|
||||
return PR_FALSE; // document.domain not set and hosts not same - check failed
|
||||
}
|
||||
|
||||
//
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
//
|
||||
// This routine answers: 'Is origin's document from same domain as target's document?'
|
||||
// Be optimistic that domain is same - error cases all answer 'yes'.
|
||||
//
|
||||
// We have to compare the URI of the actual document loaded in the origin,
|
||||
// ignoring any document.domain that was set, with the principal URI of the
|
||||
// target (including any document.domain that was set). This puts control
|
||||
// of loading in the hands of the target, which is more secure. (per Nav 4.x)
|
||||
//
|
||||
static
|
||||
PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem, nsIDocShellTreeItem* aTargetTreeItem)
|
||||
{
|
||||
// Get origin document uri (ignoring document.domain)
|
||||
nsCOMPtr<nsIWebNavigation> originWebNav(do_QueryInterface(aOriginTreeItem));
|
||||
NS_ENSURE_TRUE(originWebNav, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIURI> originDocumentURI;
|
||||
nsresult rv = originWebNav->GetCurrentURI(getter_AddRefs(originDocumentURI));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originDocumentURI, PR_TRUE);
|
||||
|
||||
// Get target principal uri (including document.domain)
|
||||
nsCOMPtr<nsIDOMDocument> targetDOMDocument(do_GetInterface(aTargetTreeItem));
|
||||
NS_ENSURE_TRUE(targetDOMDocument, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> targetDocument(do_QueryInterface(targetDOMDocument));
|
||||
NS_ENSURE_TRUE(targetDocument, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> targetPrincipal;
|
||||
rv = targetDocument->GetPrincipal(getter_AddRefs(targetPrincipal));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetPrincipal, rv);
|
||||
|
||||
nsCOMPtr<nsICodebasePrincipal> targetCodebasePrincipal(do_QueryInterface(targetPrincipal));
|
||||
NS_ENSURE_TRUE(targetCodebasePrincipal, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIURI> targetPrincipalURI;
|
||||
rv = targetCodebasePrincipal->GetURI(getter_AddRefs(targetPrincipalURI));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetPrincipalURI, PR_TRUE);
|
||||
|
||||
// Find out if document.domain was set for HTML documents
|
||||
PRBool documentDomainSet = PR_FALSE;
|
||||
nsCOMPtr<nsIHTMLDocument> targetHTMLDocument(do_QueryInterface(targetDocument));
|
||||
|
||||
// If we don't have an HTML document, fall through with documentDomainSet false
|
||||
if (targetHTMLDocument) {
|
||||
targetHTMLDocument->WasDomainSet(&documentDomainSet);
|
||||
}
|
||||
|
||||
// Is origin same principal or a subdomain of target's document.domain
|
||||
// Compare actual URI of origin document, not origin principal's URI. (Per Nav 4.x)
|
||||
return SameOrSubdomainOfTarget(originDocumentURI, targetPrincipalURI, documentDomainSet);
|
||||
}
|
||||
|
||||
nsresult nsDocShell::FindTarget(const PRUnichar *aWindowTarget,
|
||||
PRBool *aIsNewWindow,
|
||||
nsIDocShell **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString name(aWindowTarget);
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem;
|
||||
PRBool mustMakeNewWindow = PR_FALSE;
|
||||
|
||||
*aResult = nsnull;
|
||||
*aIsNewWindow = PR_FALSE;
|
||||
|
||||
if(!name.Length() || name.EqualsIgnoreCase("_self"))
|
||||
{
|
||||
*aResult = this;
|
||||
}
|
||||
else if (name.EqualsIgnoreCase("_blank") || name.EqualsIgnoreCase("_new"))
|
||||
{
|
||||
mustMakeNewWindow = PR_TRUE;
|
||||
name.AssignWithConversion("");
|
||||
}
|
||||
else if(name.EqualsIgnoreCase("_parent"))
|
||||
{
|
||||
GetSameTypeParent(getter_AddRefs(treeItem));
|
||||
if(!treeItem)
|
||||
*aResult = this;
|
||||
}
|
||||
else if(name.EqualsIgnoreCase("_top"))
|
||||
{
|
||||
GetSameTypeRootTreeItem(getter_AddRefs(treeItem));
|
||||
if(!treeItem)
|
||||
*aResult = this;
|
||||
}
|
||||
else if(name.EqualsIgnoreCase("_content"))
|
||||
{
|
||||
if (mTreeOwner)
|
||||
mTreeOwner->FindItemWithName(name.get(), nsnull,
|
||||
getter_AddRefs(treeItem));
|
||||
else
|
||||
{
|
||||
NS_ERROR("Someone isn't setting up the tree owner. "
|
||||
"You might like to try that. "
|
||||
"Things will.....you know, work.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to locate the target window...
|
||||
FindItemWithName(name.get(), nsnull, getter_AddRefs(treeItem));
|
||||
|
||||
// The named window cannot be found so it must be created to receive
|
||||
// the channel data.
|
||||
|
||||
if (!treeItem) {
|
||||
mustMakeNewWindow = PR_TRUE;
|
||||
}
|
||||
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
// See BugSplat 336170, 338737 and XP_FindNamedContextInList in
|
||||
// the classic codebase
|
||||
// Per Nav's behaviour:
|
||||
// - pref controlled: "browser.frame.validate_origin"
|
||||
// (mValidateOrigin)
|
||||
// - allow load if host of target or target's parent is same
|
||||
// as host of origin
|
||||
// - allow load if target is a top level window
|
||||
|
||||
// Check to see if pref is true
|
||||
if (mValidateOrigin && treeItem)
|
||||
{
|
||||
|
||||
// Is origin frame from the same domain as target frame?
|
||||
if (! ValidateOrigin(this, treeItem))
|
||||
{
|
||||
|
||||
// No. Is origin frame from the same domain as target's parent?
|
||||
nsCOMPtr<nsIDocShellTreeItem> targetParentTreeItem;
|
||||
|
||||
rv = treeItem->GetSameTypeParent(getter_AddRefs(targetParentTreeItem));
|
||||
if (NS_SUCCEEDED(rv) && targetParentTreeItem)
|
||||
{
|
||||
if (! ValidateOrigin(this, targetParentTreeItem))
|
||||
{
|
||||
|
||||
// Neither is from the origin domain, send load to a new window (_blank)
|
||||
mustMakeNewWindow = PR_TRUE;
|
||||
name.AssignWithConversion("");
|
||||
} // else (target's parent from origin domain) allow this load
|
||||
} // else (no parent) allow this load since shell is a toplevel window
|
||||
} // else (target from origin domain) allow this load
|
||||
} // else (pref is false) allow this load
|
||||
}
|
||||
|
||||
if (mustMakeNewWindow)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
nsCOMPtr<nsIDOMWindowInternal> parentWindow;
|
||||
|
||||
// This DocShell is the parent window
|
||||
parentWindow = do_GetInterface(NS_STATIC_CAST(nsIDocShell*, this));
|
||||
if (!parentWindow) {
|
||||
NS_ASSERTION(0, "Cant get nsIDOMWindowInternal from nsDocShell!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = parentWindow->Open(NS_LITERAL_STRING(""), // URL to load
|
||||
name, // Window name
|
||||
nsLiteralString(nsnull), // Window features
|
||||
getter_AddRefs(newWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the DocShell from the new window...
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
sgo = do_QueryInterface(newWindow, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// This will AddRef() aResult...
|
||||
rv = sgo->GetDocShell(aResult);
|
||||
|
||||
// If all went well, indicate that a new window has been created.
|
||||
if (*aResult) {
|
||||
*aIsNewWindow = PR_TRUE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (treeItem)
|
||||
{
|
||||
NS_ASSERTION(!*aResult, "aResult should be null if treeItem is set!");
|
||||
treeItem->QueryInterface(NS_GET_IID(nsIDocShell), (void **)aResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_IF_ADDREF(*aResult);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetPresContext(nsIPresContext ** aPresContext)
|
||||
{
|
||||
@ -1702,8 +1998,16 @@ nsDocShell::Reload(PRUint32 aReloadFlags)
|
||||
else if (LSHE) // In case a reload happened before the current load is done
|
||||
rv = LoadHistoryEntry(LSHE, type);
|
||||
else
|
||||
rv = InternalLoad(mCurrentURI, mReferrerURI, nsnull, PR_TRUE, PR_FALSE,
|
||||
nsnull, nsnull, nsnull, type);
|
||||
rv = InternalLoad(mCurrentURI,
|
||||
mReferrerURI,
|
||||
nsnull, // No owner
|
||||
PR_TRUE, // Inherit owner from document
|
||||
PR_FALSE, // Do not stop active document
|
||||
nsnull, // No window target
|
||||
nsnull, // No post data
|
||||
nsnull, // No headers data
|
||||
type, // Load type
|
||||
nsnull); // No SHEntry
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1839,6 +2143,9 @@ nsDocShell::Create()
|
||||
mPrefs->GetBoolPref("browser.target_new_blocked", &mDisallowPopupWindows);
|
||||
mPrefs->GetBoolPref("browser.frames.enabled", &mAllowSubframes);
|
||||
|
||||
// Check pref to see if we should prevent frameset spoofing
|
||||
mPrefs->GetBoolPref("browser.frame.validate_origin", &mValidateOrigin);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3294,38 +3601,132 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
|
||||
// nsDocShell: Site Loading
|
||||
//*****************************************************************************
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::InternalLoad(nsIURI * aURI, nsIURI * aReferrer,
|
||||
nsISupports * aOwner, PRBool aInheritOwner,
|
||||
PRBool aStopActiveDoc, const char *aWindowTarget,
|
||||
nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
nsIURI * aReferrer,
|
||||
nsISupports * aOwner,
|
||||
PRBool aInheritOwner,
|
||||
PRBool aStopActiveDoc,
|
||||
const PRUnichar *aWindowTarget,
|
||||
nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData, PRUint32 aLoadType,
|
||||
nsIInputStream * aHeadersData,
|
||||
PRUint32 aLoadType,
|
||||
nsISHEntry * aSHEntry)
|
||||
{
|
||||
if (mDisallowPopupWindows && aWindowTarget && aWindowTarget[0] != '\0') {
|
||||
PRBool isChrome = PR_FALSE;
|
||||
PRBool isResource = PR_FALSE;
|
||||
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) &&
|
||||
NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)) &&
|
||||
!isChrome && !isResource) {
|
||||
static const char top[] = "_top";
|
||||
if (!nsCRT::strcmp(aWindowTarget, "_blank") ||
|
||||
!nsCRT::strcmp(aWindowTarget, "_new")) {
|
||||
aWindowTarget = top;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocShellTreeItem> targetDocShell;
|
||||
FindItemWithName(NS_ConvertASCIItoUCS2(aWindowTarget).
|
||||
GetUnicode(),
|
||||
NS_STATIC_CAST(nsIInterfaceRequestor *, this),
|
||||
getter_AddRefs(targetDocShell));
|
||||
if (!targetDocShell)
|
||||
aWindowTarget = top;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
//
|
||||
// Resolve the window target before going any further...
|
||||
// If the load has been targeted to another DocShell, then transfer the
|
||||
// load to it...
|
||||
//
|
||||
if (aWindowTarget && *aWindowTarget) {
|
||||
PRBool bIsNewWindow;
|
||||
nsCOMPtr<nsIDocShell> targetDocShell;
|
||||
nsAutoString name(aWindowTarget);
|
||||
|
||||
//
|
||||
// This is a hack for Shrimp :-(
|
||||
//
|
||||
// if the load cmd is a user click....and we are supposed to try using
|
||||
// external default protocol handlers....then try to see if we have one for
|
||||
// this protocol
|
||||
//
|
||||
// See bug #52182
|
||||
//
|
||||
if (mUseExternalProtocolHandler && aLoadType == LOAD_LINK) {
|
||||
PRBool bIsJavascript = PR_FALSE;
|
||||
|
||||
aURI->SchemeIs("javascript", &bIsJavascript);
|
||||
// don't do it for javascript urls!
|
||||
if (!bIsJavascript &&
|
||||
(name.EqualsIgnoreCase("_content") ||
|
||||
name.EqualsIgnoreCase("_blank")))
|
||||
{
|
||||
nsCOMPtr<nsIExternalProtocolService> extProtService;
|
||||
nsXPIDLCString urlScheme;
|
||||
|
||||
extProtService = do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID);
|
||||
if (extProtService) {
|
||||
PRBool haveHandler = PR_FALSE;
|
||||
aURI->GetScheme(getter_Copies(urlScheme));
|
||||
|
||||
extProtService->ExternalProtocolHandlerExists(urlScheme,
|
||||
&haveHandler);
|
||||
if (haveHandler)
|
||||
return extProtService->LoadUrl(aURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This is a hack to prevent top-level windows from ever being
|
||||
// created. It really doesn't belong here, but until there is a
|
||||
// way for embeddors to get involved in window targeting, this is
|
||||
// as good a place as any...
|
||||
//
|
||||
if (mDisallowPopupWindows) {
|
||||
PRBool bIsChromeOrResource = PR_FALSE;
|
||||
|
||||
aURI->SchemeIs("chrome", &bIsChromeOrResource);
|
||||
if (!bIsChromeOrResource) {
|
||||
aURI->SchemeIs("resource", &bIsChromeOrResource);
|
||||
}
|
||||
if (!bIsChromeOrResource) {
|
||||
if (name.EqualsIgnoreCase("_blank") ||
|
||||
name.EqualsIgnoreCase("_new")) {
|
||||
name.AssignWithConversion("_top");
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocShellTreeItem> targetTreeItem;
|
||||
FindItemWithName(name.GetUnicode(),
|
||||
NS_STATIC_CAST(nsIInterfaceRequestor *, this),
|
||||
getter_AddRefs(targetTreeItem));
|
||||
if (targetTreeItem)
|
||||
targetDocShell = do_QueryInterface(targetTreeItem);
|
||||
else
|
||||
name.AssignWithConversion("_top");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Locate the target DocShell.
|
||||
// This may involve creating a new toplevel window - if necessary.
|
||||
//
|
||||
if (!targetDocShell) {
|
||||
rv = FindTarget(name.GetUnicode(), &bIsNewWindow,
|
||||
getter_AddRefs(targetDocShell));
|
||||
}
|
||||
|
||||
NS_ASSERTION(targetDocShell, "No Target docshell could be found!");
|
||||
//
|
||||
// Transfer the load to the target DocShell... Pass nsnull as the
|
||||
// window target name from to prevent recursive retargeting!
|
||||
//
|
||||
if (targetDocShell) {
|
||||
rv = targetDocShell->InternalLoad(aURI,
|
||||
aReferrer,
|
||||
aOwner,
|
||||
aInheritOwner,
|
||||
aStopActiveDoc,
|
||||
nsnull, // No window target
|
||||
aPostData,
|
||||
aHeadersData,
|
||||
aLoadType,
|
||||
aSHEntry);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
mURIResultedInDocument = PR_FALSE; // reset the clock...
|
||||
|
||||
//
|
||||
// First:
|
||||
// Check to see if the new URI is an anchor in the existing document.
|
||||
//
|
||||
if ((aLoadType == LOAD_NORMAL ||
|
||||
aLoadType == LOAD_NORMAL_REPLACE ||
|
||||
aLoadType == LOAD_HISTORY ||
|
||||
@ -3363,6 +3764,41 @@ nsDocShell::InternalLoad(nsIURI * aURI, nsIURI * aReferrer,
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> owner(aOwner);
|
||||
//
|
||||
// Check to see if an owner should be inherited...
|
||||
//
|
||||
if (!owner) {
|
||||
// If an owner was passed in, use it
|
||||
// Otherwise, if the caller has allowed inheriting from the current document,
|
||||
// or if we're being called from chrome (which has the system principal),
|
||||
// then use the current document principal
|
||||
if (!aInheritOwner) {
|
||||
// See if there's system or chrome JS code running
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
|
||||
secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIPrincipal> sysPrin;
|
||||
nsCOMPtr<nsIPrincipal> subjectPrin;
|
||||
|
||||
// Just to compare, not to use!
|
||||
rv = secMan->GetSystemPrincipal(getter_AddRefs(sysPrin));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = secMan->GetSubjectPrincipal(getter_AddRefs(subjectPrin));
|
||||
}
|
||||
// XXX: Why can the subject principal be nsnull??
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
(!subjectPrin || sysPrin.get() == subjectPrin.get())) {
|
||||
aInheritOwner = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aInheritOwner) {
|
||||
GetCurrentDocumentOwner(getter_AddRefs(owner));
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(StopLoad(), NS_ERROR_FAILURE);
|
||||
// Cancel any timers that were set for this loader.
|
||||
CancelRefreshURITimers();
|
||||
@ -3376,12 +3812,10 @@ nsDocShell::InternalLoad(nsIURI * aURI, nsIURI * aReferrer,
|
||||
|
||||
nsDocShellInfoLoadType loadCmd =
|
||||
ConvertLoadTypeToDocShellLoadInfo(mLoadType);
|
||||
NS_ENSURE_SUCCESS(DoURILoad
|
||||
(aURI, aReferrer, aOwner, aInheritOwner, loadCmd,
|
||||
aWindowTarget, aPostData, aHeadersData),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
rv = DoURILoad(aURI, aReferrer, owner, loadCmd, aPostData, aHeadersData);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -3447,85 +3881,42 @@ nsDocShell::GetCurrentDocumentOwner(nsISupports ** aOwner)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::DoURILoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
||||
nsISupports * aOwner, PRBool aInheritOwner,
|
||||
nsURILoadCommand aLoadCmd, const char *aWindowTarget,
|
||||
nsIInputStream * aPostData, nsIInputStream * aHeadersData)
|
||||
nsresult nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
nsIURI * aReferrerURI,
|
||||
nsISupports * aOwner,
|
||||
nsURILoadCommand aLoadCmd,
|
||||
nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData)
|
||||
{
|
||||
static const char jsSchemeName[] = "javascript";
|
||||
// if the load cmd is a user click....and we are supposed to try using
|
||||
// external default protocol handlers....then try to see if we have one for
|
||||
// this protocol
|
||||
if (mUseExternalProtocolHandler && aLoadCmd == nsIURILoader::viewUserClick) {
|
||||
nsXPIDLCString urlScheme;
|
||||
aURI->GetScheme(getter_Copies(urlScheme));
|
||||
// don't do it for javascript urls!
|
||||
if (urlScheme && nsCRT::strcasecmp(jsSchemeName, urlScheme)
|
||||
&& (!nsCRT::strcasecmp(aWindowTarget, "_content") ||
|
||||
!nsCRT::strcasecmp(aWindowTarget, "_blank"))) {
|
||||
nsCOMPtr<nsIExternalProtocolService>
|
||||
extProtService(do_GetService
|
||||
(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
|
||||
PRBool haveHandler = PR_FALSE;
|
||||
extProtService->ExternalProtocolHandlerExists(urlScheme,
|
||||
&haveHandler);
|
||||
if (haveHandler)
|
||||
return extProtService->LoadUrl(aURI);
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIURILoader>
|
||||
uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID));
|
||||
NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURILoader> uriLoader;
|
||||
|
||||
uriLoader = do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// we need to get the load group from our load cookie so we can pass it into open uri...
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
NS_ENSURE_SUCCESS(uriLoader->
|
||||
GetLoadGroupForContext(NS_STATIC_CAST
|
||||
(nsIDocShell *, this),
|
||||
getter_AddRefs(loadGroup)),
|
||||
NS_ERROR_FAILURE);
|
||||
rv = uriLoader->GetLoadGroupForContext(NS_STATIC_CAST
|
||||
(nsIDocShell *, this),
|
||||
getter_AddRefs(loadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// open a channel for the url
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIInterfaceRequestor> ifreq;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel),
|
||||
aURI,
|
||||
nsnull,
|
||||
loadGroup,
|
||||
NS_STATIC_CAST(nsIInterfaceRequestor *, this));
|
||||
|
||||
// This is a workaround to get javascript: URL's with a target
|
||||
// attribute execute in the correct window, this only works if the
|
||||
// target window exists when the link is clicked.
|
||||
if (aWindowTarget && *aWindowTarget) {
|
||||
PRBool isJSURL = PR_FALSE;
|
||||
// do it only for javascript urls!
|
||||
if (NS_SUCCEEDED(aURI->SchemeIs("javascript", &isJSURL)) && isJSURL) {
|
||||
nsAutoString targetName;
|
||||
targetName.AssignWithConversion(aWindowTarget);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> targetDocShell;
|
||||
|
||||
FindItemWithName(targetName.GetUnicode(),
|
||||
NS_STATIC_CAST(nsIInterfaceRequestor *, this),
|
||||
getter_AddRefs(targetDocShell));
|
||||
|
||||
ifreq = do_QueryInterface(targetDocShell);
|
||||
}
|
||||
}
|
||||
// End of workaround.
|
||||
|
||||
if (!ifreq)
|
||||
ifreq = NS_STATIC_CAST(nsIInterfaceRequestor *, this);
|
||||
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURI, nsnull, loadGroup, ifreq);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_ERROR_DOM_RETVAL_UNDEFINED == rv) // if causing the channel changed the
|
||||
return NS_OK; // dom and there is nothing else to do
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
channel->SetOriginalURI(aURI);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
//
|
||||
// If this is a HTTP channel, then set up the HTTP specific information
|
||||
// (ie. POST data, referer, ...)
|
||||
//
|
||||
if (httpChannel) {
|
||||
nsCOMPtr<nsICachingChannel>
|
||||
cacheChannel(do_QueryInterface(httpChannel));
|
||||
@ -3583,54 +3974,27 @@ nsDocShell::DoURILoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
||||
httpChannel->SetReferrer(aReferrerURI,
|
||||
nsIHttpChannel::REFERRER_LINK_CLICK);
|
||||
}
|
||||
else {
|
||||
// iff we are dealing with a JS or a data url, we may need an inherited owner.
|
||||
// This is either aOwner or the owner of the current document.
|
||||
nsCOMPtr<nsISupports> owner = aOwner;
|
||||
PRBool isJSOrData = PR_FALSE;
|
||||
nsCOMPtr<nsIStreamIOChannel> ioChannel(do_QueryInterface(channel));
|
||||
if (ioChannel) // Might be a javascript: URL load, need to set owner
|
||||
{
|
||||
aURI->SchemeIs("javascript", &isJSOrData);
|
||||
}
|
||||
else { // Also set owner for data: URLs
|
||||
nsCOMPtr<nsIDataChannel> dataChannel(do_QueryInterface(channel));
|
||||
isJSOrData = (dataChannel != nsnull);
|
||||
}
|
||||
|
||||
if (isJSOrData) {
|
||||
if (!owner) // If an owner was passed in, use it
|
||||
{
|
||||
// Otherwise, if the caller has allowed inheriting from the current document,
|
||||
// or if we're being called from chrome (which has the system principal),
|
||||
// then use the current document principal
|
||||
if (!aInheritOwner) {
|
||||
// See if there's system or chrome JS code running
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
|
||||
kSecurityManagerCID, &rv);
|
||||
nsCOMPtr<nsIPrincipal> sysPrin;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = secMan->GetSystemPrincipal(getter_AddRefs(sysPrin)); // Just to compare, not to use!
|
||||
nsCOMPtr<nsIPrincipal> subjectPrin;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = secMan->
|
||||
GetSubjectPrincipal(getter_AddRefs(subjectPrin));
|
||||
if (NS_SUCCEEDED(rv)
|
||||
&& (!subjectPrin || sysPrin.get() == subjectPrin.get()))
|
||||
aInheritOwner = PR_TRUE;
|
||||
}
|
||||
if (aInheritOwner)
|
||||
GetCurrentDocumentOwner(getter_AddRefs(owner));
|
||||
}
|
||||
channel->SetOwner(owner);
|
||||
}
|
||||
//
|
||||
// Set the owner of the channel - only for javascript and data channels.
|
||||
//
|
||||
// XXX: Is seems wrong that the owner is ignored - even if one is
|
||||
// supplied) unless the URI is javascript or data.
|
||||
//
|
||||
// (Currently chrome URIs set the owner when they are created!
|
||||
// So setting a NULL owner would be bad!)
|
||||
//
|
||||
PRBool isJSOrData = PR_FALSE;
|
||||
aURI->SchemeIs("javascript", &isJSOrData);
|
||||
if (!isJSOrData) {
|
||||
aURI->SchemeIs("data", &isJSOrData);
|
||||
}
|
||||
if (isJSOrData) {
|
||||
channel->SetOwner(aOwner);
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(DoChannelLoad
|
||||
(channel, aLoadCmd, aWindowTarget, uriLoader),
|
||||
NS_ERROR_FAILURE);
|
||||
rv = DoChannelLoad(channel, aLoadCmd, uriLoader);
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static NS_METHOD
|
||||
@ -3786,10 +4150,11 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::DoChannelLoad(nsIChannel * aChannel, nsURILoadCommand aLoadCmd,
|
||||
const char *aWindowTarget, nsIURILoader * aURILoader)
|
||||
nsresult nsDocShell::DoChannelLoad(nsIChannel * aChannel,
|
||||
nsURILoadCommand aLoadCmd,
|
||||
nsIURILoader * aURILoader)
|
||||
{
|
||||
nsresult rv;
|
||||
// Mark the channel as being a document URI...
|
||||
nsLoadFlags loadFlags = 0;
|
||||
(void) aChannel->GetLoadFlags(&loadFlags);
|
||||
@ -3836,12 +4201,10 @@ nsDocShell::DoChannelLoad(nsIChannel * aChannel, nsURILoadCommand aLoadCmd,
|
||||
|
||||
(void) aChannel->SetLoadFlags(loadFlags);
|
||||
|
||||
NS_ENSURE_SUCCESS(aURILoader->OpenURI(aChannel, aLoadCmd,
|
||||
aWindowTarget,
|
||||
NS_STATIC_CAST(nsIDocShell *, this)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
rv = aURILoader->OpenURI(aChannel,
|
||||
aLoadCmd,
|
||||
NS_STATIC_CAST(nsIDocShell *, this));
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -4445,6 +4808,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIInputStream> postData;
|
||||
nsCOMPtr<nsIURI> referrerURI;
|
||||
@ -4488,10 +4852,17 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType)
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(InternalLoad
|
||||
(uri, referrerURI, nsnull, PR_TRUE, PR_FALSE, nsnull,
|
||||
postData, nsnull, aLoadType, aEntry), NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
rv = InternalLoad(uri,
|
||||
referrerURI,
|
||||
nsnull, // No owner
|
||||
PR_TRUE, // Inherit owner from document
|
||||
PR_FALSE, // Do not stop active document
|
||||
nsnull, // No window target
|
||||
postData, // Post data stream
|
||||
nsnull, // No headers stream
|
||||
aLoadType, // Load type
|
||||
aEntry); // SHEntry
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -204,22 +204,19 @@ protected:
|
||||
nsIStreamListener ** aContentHandler, nsIContentViewer ** aViewer);
|
||||
NS_IMETHOD SetupNewViewer(nsIContentViewer * aNewViewer);
|
||||
|
||||
NS_IMETHOD InternalLoad(nsIURI * aURI, nsIURI * aReferrerURI,
|
||||
nsISupports * owner, PRBool inheritOwnerFromDocument,
|
||||
PRBool stopActiveDoc, const char * aWindowTarget = nsnull,
|
||||
nsIInputStream * aPostData = nsnull,
|
||||
nsIInputStream * aHeadersData = nsnull,
|
||||
PRUint32 aLoadType = LOAD_NORMAL, nsISHEntry * aSHEntry = nsnull);
|
||||
NS_IMETHOD CreateFixupURI(const PRUnichar * aStringURI, nsIURI ** aURI);
|
||||
NS_IMETHOD GetCurrentDocumentOwner(nsISupports ** aOwner);
|
||||
NS_IMETHOD DoURILoad(nsIURI * aURI, nsIURI * aReferrer,
|
||||
nsISupports * aOwner, PRBool inheritOwnerFromDocument,
|
||||
nsURILoadCommand aLoadCmd, const char * aWindowTarget,
|
||||
nsIInputStream * aPostData, nsIInputStream * aHeadersData);
|
||||
virtual nsresult DoURILoad(nsIURI * aURI,
|
||||
nsIURI * aReferrer,
|
||||
nsISupports * aOwner,
|
||||
nsURILoadCommand aLoadCmd,
|
||||
nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData);
|
||||
NS_IMETHOD AddHeadersToChannel(nsIInputStream * aHeadersData,
|
||||
nsIChannel * aChannel);
|
||||
NS_IMETHOD DoChannelLoad(nsIChannel * aChannel, nsURILoadCommand aLoadCmd,
|
||||
const char * aWindowTarget, nsIURILoader * aURILoader);
|
||||
virtual nsresult DoChannelLoad(nsIChannel * aChannel,
|
||||
nsURILoadCommand aLoadCmd,
|
||||
nsIURILoader * aURILoader);
|
||||
NS_IMETHOD ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor);
|
||||
NS_IMETHOD OnLoadingSite(nsIChannel * aChannel);
|
||||
|
||||
@ -254,6 +251,11 @@ protected:
|
||||
NS_IMETHOD EnsureScriptEnvironment();
|
||||
NS_IMETHOD EnsureFind();
|
||||
|
||||
|
||||
virtual nsresult FindTarget(const PRUnichar *aTargetName,
|
||||
PRBool *aIsNewWindow,
|
||||
nsIDocShell **aResult);
|
||||
|
||||
PRBool IsFrame();
|
||||
|
||||
//
|
||||
@ -323,6 +325,9 @@ protected:
|
||||
// Disallow popping up new windows with target=
|
||||
PRBool mDisallowPopupWindows;
|
||||
|
||||
// Validate window targets to prevent frameset spoofing
|
||||
PRBool mValidateOrigin;
|
||||
|
||||
PRBool mIsBeingDestroyed;
|
||||
|
||||
// WEAK REFERENCES BELOW HERE.
|
||||
|
||||
@ -159,6 +159,29 @@ NS_IMETHODIMP nsDocShellLoadInfo::SetTarget(const char* aTarget)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = mPostDataStream;
|
||||
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream *aStream)
|
||||
{
|
||||
mPostDataStream = aStream;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// nsDocShellLoadInfo: Helpers
|
||||
//*****************************************************************************
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
// Interfaces Needed
|
||||
#include "nsIDocShellLoadInfo.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsISHEntry.h"
|
||||
|
||||
class nsDocShellLoadInfo : public nsIDocShellLoadInfo
|
||||
@ -52,6 +53,7 @@ protected:
|
||||
nsDocShellInfoLoadType mLoadType;
|
||||
nsCOMPtr<nsISHEntry> mSHEntry;
|
||||
nsCString mTarget;
|
||||
nsCOMPtr<nsIInputStream> mPostDataStream;
|
||||
};
|
||||
|
||||
#endif /* nsDocShellLoadInfo_h__ */
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
@ -32,7 +31,7 @@
|
||||
%}
|
||||
|
||||
/**
|
||||
* The nsIDocShell
|
||||
* The nsIDocShell interface.
|
||||
*/
|
||||
|
||||
[ptr] native nsIPresContext(nsIPresContext);
|
||||
@ -43,162 +42,204 @@ interface nsIDocShellLoadInfo;
|
||||
interface nsIDocumentCharsetInfo;
|
||||
interface nsIWebNavigation;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsISHEntry;
|
||||
|
||||
[scriptable, uuid(69E5DE00-7B8B-11d3-AF61-00A024FFC08C)]
|
||||
interface nsIDocShell : nsISupports
|
||||
{
|
||||
/*
|
||||
Loads a given URI. This will give priority to loading the requested URI
|
||||
in the object implementing this interface. If it can't be loaded here
|
||||
however, the URL dispatcher will go through its normal process of content
|
||||
loading.
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
* however, the URL dispatcher will go through its normal process of content
|
||||
* loading.
|
||||
*
|
||||
* @param uri - The URI to load.
|
||||
* @param loadInfo - This is the extended load info for this load. This
|
||||
* most often will be null, but if you need to do
|
||||
* additional setup for this load you can get a loadInfo
|
||||
* object by calling createLoadInfo. Once you have this
|
||||
* object you can set the needed properties on it and
|
||||
* then pass it to loadURI.
|
||||
* @param aLoadFlags - Flags to modify load behaviour. Flags are defined
|
||||
* in nsIWebNavigation.
|
||||
*/
|
||||
[noscript]void loadURI(in nsIURI uri,
|
||||
in nsIDocShellLoadInfo loadInfo,
|
||||
in unsigned long aLoadFlags);
|
||||
|
||||
@param uri - The URI to load.
|
||||
@param loadInfo - This is the extended load info for this load. This
|
||||
most often will be null, but if you need to do additional setup for
|
||||
this load you can get a loadInfo object by calling createLoadInfo.
|
||||
Once you have this object you can set the needed properties on it and
|
||||
then pass it to loadURI.
|
||||
@param aLoadFlags - Flags to modify load behaviour. Flags are defined
|
||||
in nsIWebNavigation.
|
||||
*/
|
||||
[noscript]void loadURI(in nsIURI uri, in nsIDocShellLoadInfo loadInfo, in unsigned long aLoadFlags);
|
||||
/**
|
||||
* Loads a given stream. This will give priority to loading the requested
|
||||
* stream in the object implementing this interface. If it can't be loaded
|
||||
* here however, the URL dispatched will go through its normal process of
|
||||
* content loading.
|
||||
*
|
||||
* @param aStream - The input stream that provides access to the data
|
||||
* to be loaded.
|
||||
* @param aURI - The URI representing the stream, or null.
|
||||
* @param aContentType - The type (MIME) of data being loaded.
|
||||
* @param aContentLen - The length (in bytes) of the stream. If you don't
|
||||
* know the length of the stream this can be -1.
|
||||
* @param aLoadInfo - This is the extended load info for this load. This
|
||||
* most often will be null, but if you need to do
|
||||
* additional setup for this load you can get a
|
||||
* loadInfo object by calling createLoadInfo. Once
|
||||
* you have this object you can set the needed
|
||||
* properties on it and then pass it to loadStream.
|
||||
*/
|
||||
[noscript]void loadStream(in nsIInputStream aStream,
|
||||
in nsIURI aURI,
|
||||
in string aContentType,
|
||||
in long aContentLen,
|
||||
in nsIDocShellLoadInfo aLoadInfo);
|
||||
|
||||
/*
|
||||
Loads a given stream. This will give priority to loading the requested stream
|
||||
in the object implementing this interface. If it can't be loaded here however,
|
||||
the URL dispatched will go through its normal process of content loading.
|
||||
/**
|
||||
* Loads the given URI. This method is identical to loadURI(...) except
|
||||
* that its parameter list is broken out instead of being packaged inside
|
||||
* of an nsIDocShellLoadInfo object...
|
||||
*
|
||||
* @param aURI - The URI to load.
|
||||
* @param aReferrer - Refering URI
|
||||
* @param aOwner - Owner (security principal)
|
||||
* @param aInheritOwner - Flag indicating whether the owner of the current
|
||||
* document should be inherited if aOwner is null.
|
||||
* @param aStopActiveDoc - Flag indicating whether loading the current
|
||||
* document should be stopped.
|
||||
* @param aWindowTarget - Window target for the load.
|
||||
* @param aPostDataStream - Post data stream (if POSTing)
|
||||
* @param aHeadersStream - Stream containing "extra" request headers...
|
||||
* @param aLoadFlags - Flags to modify load behaviour. Flags are defined
|
||||
* in nsIWebNavigation.
|
||||
* @param aSHEntry - Active Session History entry (if loading from SH)
|
||||
*/
|
||||
[noscript]void InternalLoad(in nsIURI aURI,
|
||||
in nsIURI aReferrer,
|
||||
in nsISupports aOwner,
|
||||
in boolean aInheritOwner,
|
||||
in boolean aStopActiveDoc,
|
||||
in wstring aWindowTarget,
|
||||
in nsIInputStream aPostDataStream,
|
||||
in nsIInputStream aHeadersStream,
|
||||
in unsigned long aLoadFlags,
|
||||
in nsISHEntry aSHEntry);
|
||||
|
||||
@param aStream - The input stream that provides access to the data to be loaded.
|
||||
@param aURI - The URI representing the stream, or null.
|
||||
@param aContentType - The type (MIME) of data being loaded.
|
||||
@param aContentLen - The length (in bytes) of the stream. If you don't know
|
||||
the length of the stream this can be -1.
|
||||
@param aLoadInfo - This is the extended load info for this load. This most
|
||||
most often will be null, but if you need to do additional setup for this
|
||||
load you can get a loadInfo object by calling createLoadInfo. Once you have
|
||||
this object you can set the needed properties on it and then pass it to
|
||||
loadURI.
|
||||
*/
|
||||
[noscript]void loadStream(in nsIInputStream aStream, in nsIURI aURI,
|
||||
in string aContentType, in long aContentLen,
|
||||
in nsIDocShellLoadInfo aLoadInfo);
|
||||
/**
|
||||
* Creates a DocShellLoadInfo object that you can manipulate and then pass
|
||||
* to loadURI.
|
||||
*/
|
||||
void createLoadInfo(out nsIDocShellLoadInfo loadInfo);
|
||||
|
||||
/*
|
||||
Creates a DocShellLoadInfo object that you can manipulate and then pass to
|
||||
loadURI.
|
||||
*/
|
||||
void createLoadInfo(out nsIDocShellLoadInfo loadInfo);
|
||||
/**
|
||||
* Stops a current load. This simply stops the network portion of the load.
|
||||
* If you wish to do a complete stop, then you should us the
|
||||
* nsIWebNavigation::Stop() method.
|
||||
*/
|
||||
void stopLoad();
|
||||
|
||||
/*
|
||||
Stops a current load. This simply stops the network portion of the load.
|
||||
If you wish to do a complete stop, then you should us the
|
||||
nsIWebNavigation::Stop() method.
|
||||
*/
|
||||
void stopLoad();
|
||||
/**
|
||||
* Presentation context for the currently loaded document. This may be null.
|
||||
*/
|
||||
[noscript] readonly attribute nsIPresContext presContext;
|
||||
|
||||
/*
|
||||
Presentation context for the currently loaded document. This may be null.
|
||||
*/
|
||||
[noscript] readonly attribute nsIPresContext presContext;
|
||||
/**
|
||||
* Presentation context for the currently loaded document. This may be null.
|
||||
*/
|
||||
[noscript] readonly attribute nsIPresShell presShell;
|
||||
|
||||
/*
|
||||
Presentation context for the currently loaded document. This may be null.
|
||||
*/
|
||||
[noscript] readonly attribute nsIPresShell presShell;
|
||||
/**
|
||||
* Content Viewer that is currently loaded for this DocShell. This may
|
||||
* change as the underlying content changes.
|
||||
*/
|
||||
readonly attribute nsIContentViewer contentViewer;
|
||||
|
||||
/*
|
||||
Content Viewer that is currently loaded for this DocShell. This may change
|
||||
as the underlying content changes.
|
||||
*/
|
||||
readonly attribute nsIContentViewer contentViewer;
|
||||
/**
|
||||
* This attribute allows chrome to tie in to handle DOM events that may
|
||||
* be of interest to chrome.
|
||||
*/
|
||||
attribute nsIChromeEventHandler chromeEventHandler;
|
||||
|
||||
/*
|
||||
This attribute allows chrome to tie in to handle DOM events that may be of
|
||||
interest to chrome.
|
||||
*/
|
||||
attribute nsIChromeEventHandler chromeEventHandler;
|
||||
/**
|
||||
* URI content listener parent. This is not refcounted and is assumed to be
|
||||
* nulled out by the parent when the parent is going away.
|
||||
*/
|
||||
attribute nsIURIContentListener parentURIContentListener;
|
||||
|
||||
/*
|
||||
URI content listener parent. This is not refcounted and is assumed to be
|
||||
nulled out by the parent when the parent is going away.
|
||||
*/
|
||||
attribute nsIURIContentListener parentURIContentListener;
|
||||
/**
|
||||
* The document charset info. This is used by a load to determine priorities
|
||||
* for charset detection etc.
|
||||
*/
|
||||
attribute nsIDocumentCharsetInfo documentCharsetInfo;
|
||||
|
||||
/*
|
||||
The document charset info. This is used by a load to determine priorities for
|
||||
charset detection etc.
|
||||
*/
|
||||
attribute nsIDocumentCharsetInfo documentCharsetInfo;
|
||||
/**
|
||||
* Whether to allow plugin execution
|
||||
*/
|
||||
attribute boolean allowPlugins;
|
||||
|
||||
/*
|
||||
Whether to allow plugin execution
|
||||
*/
|
||||
attribute boolean allowPlugins;
|
||||
/**
|
||||
* Whether to allow Javascript execution
|
||||
*/
|
||||
attribute boolean allowJavascript;
|
||||
|
||||
/*
|
||||
Whether to allow Javascript execution
|
||||
*/
|
||||
attribute boolean allowJavascript;
|
||||
/**
|
||||
* Attribute stating if refresh based redirects can be allowed
|
||||
*/
|
||||
attribute boolean allowMetaRedirects;
|
||||
|
||||
/*
|
||||
Attribute stating if refresh based redirects can be allowed
|
||||
*/
|
||||
attribute boolean allowMetaRedirects;
|
||||
|
||||
/*
|
||||
Attribute stating if it should allow subframes (framesets/iframes) or not.
|
||||
*/
|
||||
attribute boolean allowSubframes;
|
||||
/**
|
||||
* Attribute stating if it should allow subframes (framesets/iframes) or not
|
||||
*/
|
||||
attribute boolean allowSubframes;
|
||||
|
||||
/*
|
||||
Get an enumerator over this docShell and its children.
|
||||
|
||||
@param aItemType - Only include docShells of this type, or if typeAll, include
|
||||
all child shells. Uses types from nsIDocShellTreeItem.
|
||||
@param aDirection - Whether to enumerate forwards or backwards.
|
||||
*/
|
||||
|
||||
const long ENUMERATE_FORWARDS = 0;
|
||||
const long ENUMERATE_BACKWARDS = 1;
|
||||
/**
|
||||
* Get an enumerator over this docShell and its children.
|
||||
*
|
||||
* @param aItemType - Only include docShells of this type, or if typeAll,
|
||||
* include all child shells.
|
||||
* Uses types from nsIDocShellTreeItem.
|
||||
* @param aDirection - Whether to enumerate forwards or backwards.
|
||||
*/
|
||||
|
||||
nsISimpleEnumerator getDocShellEnumerator(in long aItemType, in long aDirection);
|
||||
|
||||
/*
|
||||
The type of application that created this window
|
||||
*/
|
||||
const unsigned long APP_TYPE_UNKNOWN = 0;
|
||||
const unsigned long APP_TYPE_MAIL = 1;
|
||||
const long ENUMERATE_FORWARDS = 0;
|
||||
const long ENUMERATE_BACKWARDS = 1;
|
||||
|
||||
attribute unsigned long appType;
|
||||
nsISimpleEnumerator getDocShellEnumerator(in long aItemType,
|
||||
in long aDirection);
|
||||
|
||||
/**
|
||||
* Set/Get the document scale factor. When setting this attribute, a
|
||||
* NS_ERROR_NOT_IMPLEMENTED error may be returned by implementations
|
||||
* not supporting zoom. Implementations not supporting zoom should return
|
||||
* 1.0 all the time for the Get operation. 1.0 by the way is the default
|
||||
* of zoom. This means 100% of normal scaling or in other words normal size
|
||||
* no zoom.
|
||||
*/
|
||||
attribute float zoom;
|
||||
/**
|
||||
* The type of application that created this window
|
||||
*/
|
||||
const unsigned long APP_TYPE_UNKNOWN = 0;
|
||||
const unsigned long APP_TYPE_MAIL = 1;
|
||||
|
||||
/*
|
||||
XXX Comment here!
|
||||
*/
|
||||
attribute long marginWidth;
|
||||
attribute unsigned long appType;
|
||||
|
||||
/*
|
||||
XXX Comment here!
|
||||
*/
|
||||
attribute long marginHeight;
|
||||
/**
|
||||
* Set/Get the document scale factor. When setting this attribute, a
|
||||
* NS_ERROR_NOT_IMPLEMENTED error may be returned by implementations
|
||||
* not supporting zoom. Implementations not supporting zoom should return
|
||||
* 1.0 all the time for the Get operation. 1.0 by the way is the default
|
||||
* of zoom. This means 100% of normal scaling or in other words normal size
|
||||
* no zoom.
|
||||
*/
|
||||
attribute float zoom;
|
||||
|
||||
/* Current busy state for DocShell */
|
||||
const unsigned long BUSY_FLAGS_NONE = 0;
|
||||
const unsigned long BUSY_FLAGS_BUSY = 1;
|
||||
const unsigned long BUSY_FLAGS_BEFORE_PAGE_LOAD = 2;
|
||||
const unsigned long BUSY_FLAGS_PAGE_LOADING = 4;
|
||||
/*
|
||||
* XXX Comment here!
|
||||
*/
|
||||
attribute long marginWidth;
|
||||
|
||||
readonly attribute unsigned long busyFlags;
|
||||
/*
|
||||
* XXX Comment here!
|
||||
*/
|
||||
attribute long marginHeight;
|
||||
|
||||
/**
|
||||
* Current busy state for DocShell
|
||||
*/
|
||||
const unsigned long BUSY_FLAGS_NONE = 0;
|
||||
const unsigned long BUSY_FLAGS_BUSY = 1;
|
||||
const unsigned long BUSY_FLAGS_BEFORE_PAGE_LOAD = 2;
|
||||
const unsigned long BUSY_FLAGS_PAGE_LOADING = 4;
|
||||
|
||||
readonly attribute unsigned long busyFlags;
|
||||
};
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIInputStream;
|
||||
interface nsISHEntry;
|
||||
|
||||
typedef long nsDocShellInfoLoadType;
|
||||
@ -74,4 +75,6 @@ interface nsIDocShellLoadInfo : nsISupports
|
||||
attribute nsISHEntry SHEntry;
|
||||
|
||||
attribute string target; // like _content, _blank etc
|
||||
|
||||
attribute nsIInputStream postDataStream;
|
||||
};
|
||||
|
||||
@ -774,11 +774,12 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsIInputStream* aHeadersDataStream)
|
||||
{
|
||||
nsCAutoString target; target.AssignWithConversion(aTargetSpec);
|
||||
nsresult rv;
|
||||
nsAutoString target(aTargetSpec);
|
||||
|
||||
switch(aVerb) {
|
||||
case eLinkVerb_New:
|
||||
target = "_blank";
|
||||
target.AssignWithConversion("_blank");
|
||||
// Fall into replace case
|
||||
case eLinkVerb_Undefined:
|
||||
// Fall through, this seems like the most reasonable action
|
||||
@ -799,7 +800,6 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
||||
nsCOMPtr<nsIURIContentListener> listener = do_QueryInterface(mContentListener);
|
||||
nsCAutoString spec; spec.AssignWithConversion(aURLSpec);
|
||||
PRBool abort = PR_FALSE;
|
||||
nsresult rv;
|
||||
uri = do_CreateInstance(kSimpleURICID, &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "can't create simple uri");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
@ -808,14 +808,22 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "spec is invalid");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
listener->OnStartURIOpen(uri, target, &abort);
|
||||
listener->OnStartURIOpen(uri, &abort);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
InternalLoad(uri, mCurrentURI, nsnull, PR_TRUE, PR_FALSE, target, aPostDataStream,
|
||||
aHeadersDataStream, LOAD_LINK, nsnull);
|
||||
rv = InternalLoad(uri, // New URI
|
||||
mCurrentURI, // Referer URI
|
||||
nsnull, // No onwer
|
||||
PR_TRUE, // Inherit owner from document
|
||||
PR_FALSE, // Do not stop active document
|
||||
target.GetUnicode(),// Window target
|
||||
aPostDataStream, // Post data stream
|
||||
aHeadersDataStream, // Headers stream
|
||||
LOAD_LINK, // Load type
|
||||
nsnull); // No SHEntry
|
||||
}
|
||||
break;
|
||||
case eLinkVerb_Embed:
|
||||
@ -1120,8 +1128,16 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
||||
{
|
||||
postDataRandomAccess->Seek(PR_SEEK_SET, 0);
|
||||
}
|
||||
InternalLoad(url, referrer, nsnull, PR_TRUE, PR_FALSE, nsnull, inputStream,
|
||||
nsnull, LOAD_RELOAD_BYPASS_PROXY_AND_CACHE, nsnull);
|
||||
InternalLoad(url, // URI
|
||||
referrer, // Refering URI
|
||||
nsnull, // Owner
|
||||
PR_TRUE, // Inherit owner
|
||||
PR_FALSE, // Do not stop active Doc
|
||||
nsnull, // No window target
|
||||
inputStream, // Post data stream
|
||||
nsnull, // No headers stream
|
||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE,// Load type
|
||||
nsnull); // No SHEntry
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -4704,8 +4704,8 @@ nsEditorShell::DeleteSuggestedWordList()
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
/* void onStartURIOpen (in nsIURI aURI, in string aWindowTarget, out boolean aAbortOpen); */
|
||||
NS_IMETHODIMP nsEditorShell::OnStartURIOpen(nsIURI *aURI, const char *aWindowTarget, PRBool *aAbortOpen)
|
||||
/* void onStartURIOpen (in nsIURI aURI, out boolean aAbortOpen); */
|
||||
NS_IMETHODIMP nsEditorShell::OnStartURIOpen(nsIURI *aURI, PRBool *aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -4718,8 +4718,8 @@ NS_IMETHODIMP nsEditorShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
|
||||
NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
|
||||
NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aContentHandler);
|
||||
NS_ENSURE_ARG_POINTER(aAbortProcess);
|
||||
@ -4728,8 +4728,8 @@ NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadComman
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval)
|
||||
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
@ -4738,8 +4738,8 @@ NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadComm
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval)
|
||||
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
@ -4704,8 +4704,8 @@ nsEditorShell::DeleteSuggestedWordList()
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
/* void onStartURIOpen (in nsIURI aURI, in string aWindowTarget, out boolean aAbortOpen); */
|
||||
NS_IMETHODIMP nsEditorShell::OnStartURIOpen(nsIURI *aURI, const char *aWindowTarget, PRBool *aAbortOpen)
|
||||
/* void onStartURIOpen (in nsIURI aURI, out boolean aAbortOpen); */
|
||||
NS_IMETHODIMP nsEditorShell::OnStartURIOpen(nsIURI *aURI, PRBool *aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -4718,8 +4718,8 @@ NS_IMETHODIMP nsEditorShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
|
||||
NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
|
||||
NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aContentHandler);
|
||||
NS_ENSURE_ARG_POINTER(aAbortProcess);
|
||||
@ -4728,8 +4728,8 @@ NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadComman
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval)
|
||||
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
@ -4738,8 +4738,8 @@ NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadComm
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval)
|
||||
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP nsEditorShell::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
@ -293,8 +293,8 @@ CWebBrowserContainer::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIURIContentListener
|
||||
|
||||
/* void onStartURIOpen (in nsIURI aURI, in string aWindowTarget, out boolean aAbortOpen); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::OnStartURIOpen(nsIURI *pURI, const char *aWindowTarget, PRBool *aAbortOpen)
|
||||
/* void onStartURIOpen (in nsIURI aURI, out boolean aAbortOpen); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::OnStartURIOpen(nsIURI *pURI, PRBool *aAbortOpen)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
NG_TRACE(_T("CWebBrowserContainer::OnStartURIOpen(...)\n"));
|
||||
@ -317,6 +317,7 @@ NS_IMETHODIMP CWebBrowserContainer::OnStartURIOpen(nsIURI *pURI, const char *aWi
|
||||
vPostDataRef.pvarVal = &vPostData;
|
||||
// TODO get the post data passed in via the original call to Navigate()
|
||||
|
||||
|
||||
// Fire a BeforeNavigate event
|
||||
BSTR bstrURI = SysAllocString(A2OLE((const char *)aURI));
|
||||
BSTR bstrTargetFrameName = NULL;
|
||||
@ -376,22 +377,22 @@ NS_IMETHODIMP CWebBrowserContainer::GetProtocolHandler(nsIURI *aURI, nsIProtocol
|
||||
}
|
||||
|
||||
|
||||
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval)
|
||||
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval)
|
||||
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
|
||||
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -47,7 +47,6 @@ EmbedContentListener::Init(EmbedPrivate *aOwner)
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
const char *aWindowTarget,
|
||||
PRBool *aAbortOpen)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -78,7 +77,6 @@ EmbedContentListener::GetProtocolHandler(nsIURI *aURI,
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::DoContent(const char *aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget,
|
||||
nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
@ -89,7 +87,6 @@ EmbedContentListener::DoContent(const char *aContentType,
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::IsPreferred(const char *aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget,
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
@ -119,7 +116,6 @@ EmbedContentListener::IsPreferred(const char *aContentType,
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
|
||||
@ -452,7 +452,7 @@ NS_IMETHODIMP PhMozEmbedChrome::ExitModalEventLoop(nsresult aStatus)
|
||||
|
||||
// nsIURIContentListener
|
||||
|
||||
NS_IMETHODIMP PhMozEmbedChrome::OnStartURIOpen(nsIURI *aURI, const char *aWindowTarget, PRBool *aAbortOpen)
|
||||
NS_IMETHODIMP PhMozEmbedChrome::OnStartURIOpen(nsIURI *aURI, PRBool *aAbortOpen)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::OnStartURIOpen\n"));
|
||||
NS_ENSURE_ARG_POINTER(aAbortOpen);
|
||||
@ -483,7 +483,7 @@ NS_IMETHODIMP PhMozEmbedChrome::GetProtocolHandler(nsIURI *aURI, nsIProtocolHand
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PhMozEmbedChrome::DoContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, nsIChannel *aOpenedChannel,
|
||||
nsIChannel *aOpenedChannel,
|
||||
nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::DoContent\n"));
|
||||
@ -491,7 +491,7 @@ NS_IMETHODIMP PhMozEmbedChrome::DoContent(const char *aContentType, nsURILoadCom
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PhMozEmbedChrome::IsPreferred(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, char **aDesiredContentType,
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::IsPreferred\n"));
|
||||
@ -520,7 +520,7 @@ NS_IMETHODIMP PhMozEmbedChrome::IsPreferred(const char *aContentType, nsURILoadC
|
||||
}
|
||||
|
||||
NS_IMETHODIMP PhMozEmbedChrome::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget, char **aDesiredContentType,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::CanHandleContent\n"));
|
||||
|
||||
@ -913,8 +913,7 @@ CertContentListener::init()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CertContentListener::OnStartURIOpen(nsIURI *aURI, const char *aWindowTarget,
|
||||
PRBool *aAbortOpen)
|
||||
CertContentListener::OnStartURIOpen(nsIURI *aURI, PRBool *aAbortOpen)
|
||||
{
|
||||
//if we don't want to handle the URI, return PR_TRUE in
|
||||
//*aAbortOpen
|
||||
@ -933,18 +932,16 @@ CertContentListener::GetProtocolHandler(nsIURI *aURI,
|
||||
NS_IMETHODIMP
|
||||
CertContentListener::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget,
|
||||
return CanHandleContent(aContentType, aCommand,
|
||||
aDesiredContentType, aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CertContentListener::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
{
|
||||
@ -962,7 +959,6 @@ CertContentListener::CanHandleContent(const char * aContentType,
|
||||
NS_IMETHODIMP
|
||||
CertContentListener::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest * request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
|
||||
@ -187,8 +187,7 @@ NS_IMETHODIMP ImageConsumer::GetInterface(const nsIID & aIID, void * *aInstanceP
|
||||
// nsIURIContentListener support
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
ImageConsumer::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -231,19 +230,17 @@ ImageConsumer::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget,
|
||||
return CanHandleContent(aContentType, aCommand,
|
||||
aDesiredContentType, aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
@ -261,7 +258,6 @@ ImageConsumer::CanHandleContent(const char * aContentType,
|
||||
NS_IMETHODIMP
|
||||
ImageConsumer::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest * aOpenedChannel,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
@ -810,8 +806,7 @@ ImageNetContextImpl::GetURL (ilIURL * aURL,
|
||||
}
|
||||
|
||||
|
||||
rv = pURILoader->OpenURI(channel, loadCmd, nsnull /* window target */,
|
||||
window);
|
||||
rv = pURILoader->OpenURI(channel, loadCmd, window);
|
||||
}
|
||||
// rv = channel->AsyncOpen(ic, nsnull);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
@ -295,8 +295,7 @@ NS_IMETHODIMP nsAbSyncPostEngine::GetInterface(const nsIID & aIID, void * *aInst
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -311,19 +310,17 @@ nsAbSyncPostEngine::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProto
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
||||
return CanHandleContent(aContentType, aCommand, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
@ -339,7 +336,6 @@ nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
|
||||
NS_IMETHODIMP
|
||||
nsAbSyncPostEngine::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
|
||||
@ -370,8 +370,7 @@ NS_IMETHODIMP nsMsgWindow::StopUrls()
|
||||
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP nsMsgWindow::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
NS_IMETHODIMP nsMsgWindow::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -384,7 +383,7 @@ NS_IMETHODIMP nsMsgWindow::GetProtocolHandler(nsIURI * /* aURI */, nsIProtocolHa
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget,
|
||||
NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand aCommand,
|
||||
nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
|
||||
{
|
||||
if (aContentType)
|
||||
@ -409,7 +408,7 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
|
||||
if (mailnewsUrl)
|
||||
mailnewsUrl->SetMsgWindow(this);
|
||||
}
|
||||
return ctnListener->DoContent(aContentType, aCommand, aWindowTarget, request, aContentHandler, aAbortProcess);
|
||||
return ctnListener->DoContent(aContentType, aCommand, request, aContentHandler, aAbortProcess);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@ -418,7 +417,6 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
|
||||
NS_IMETHODIMP
|
||||
nsMsgWindow::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
{
|
||||
@ -428,7 +426,6 @@ nsMsgWindow::IsPreferred(const char * aContentType,
|
||||
|
||||
NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
@ -441,7 +438,7 @@ NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
|
||||
GetMessageWindowDocShell(getter_AddRefs(messageWindowDocShell));
|
||||
nsCOMPtr<nsIURIContentListener> ctnListener (do_GetInterface(messageWindowDocShell));
|
||||
if (ctnListener)
|
||||
return ctnListener->CanHandleContent(aContentType, aCommand, aWindowTarget,
|
||||
return ctnListener->CanHandleContent(aContentType, aCommand,
|
||||
aDesiredContentType, aCanHandleContent);
|
||||
else
|
||||
*aCanHandleContent = PR_FALSE;
|
||||
|
||||
@ -42,7 +42,7 @@ nsMsgComposeContentHandler::~nsMsgComposeContentHandler()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgComposeContentHandler::HandleContent(const char * aContentType, const char * aCommand,
|
||||
const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request)
|
||||
nsISupports * aWindowContext, nsIRequest *request)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!request)
|
||||
|
||||
@ -97,8 +97,7 @@ NS_IMETHODIMP nsURLFetcher::GetInterface(const nsIID & aIID, void * *aInstancePt
|
||||
|
||||
// nsIURIContentListener support
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::OnStartURIOpen(nsIURI* aURI,
|
||||
const char* aWindowTarget, PRBool* aAbortOpen)
|
||||
nsURLFetcher::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
@ -113,19 +112,17 @@ nsURLFetcher::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHan
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::IsPreferred(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
{
|
||||
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
|
||||
return CanHandleContent(aContentType, aCommand, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::CanHandleContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aDesiredContentType,
|
||||
PRBool * aCanHandleContent)
|
||||
|
||||
@ -141,7 +138,6 @@ nsURLFetcher::CanHandleContent(const char * aContentType,
|
||||
NS_IMETHODIMP
|
||||
nsURLFetcher::DoContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsIStreamListener ** aContentHandler,
|
||||
PRBool * aAbortProcess)
|
||||
@ -377,8 +373,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
|
||||
pURILoader->GetLoadGroupForContext(cntListener, getter_AddRefs(loadGroup));
|
||||
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, loadGroup, this), NS_ERROR_FAILURE);
|
||||
|
||||
rv = pURILoader->OpenURI(channel, nsIURILoader::viewNormal, nsnull /* window target */,
|
||||
cntListener);
|
||||
rv = pURILoader->OpenURI(channel, nsIURILoader::viewNormal, cntListener);
|
||||
|
||||
mOutStream = fOut;
|
||||
mCallback = cb;
|
||||
|
||||
@ -1507,7 +1507,7 @@ NS_IMETHODIMP nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIRequest *request)
|
||||
nsNntpService::HandleContent(const char * aContentType, const char * aCommand, nsISupports * aWindowContext, nsIRequest *request)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!request) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -140,4 +140,10 @@ interface nsIChannel : nsIRequest
|
||||
* via nsICachingChannel.
|
||||
*/
|
||||
const unsigned long CACHE_AS_FILE = 1 << 19;
|
||||
|
||||
|
||||
%{C++
|
||||
// There is no content available (when asyncOpen is called)
|
||||
#define NS_ERROR_NO_CONTENT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 17)
|
||||
%}
|
||||
};
|
||||
|
||||
@ -27,15 +27,10 @@ interface nsIRequest;
|
||||
interface nsIContentHandler : nsISupports
|
||||
{
|
||||
/* HandleContent works as the name implies =).
|
||||
aSourceContext --> The context associated with the originator of the content we are
|
||||
trying to display. When is this typically used? Well, if handle
|
||||
content needs to create a new window in order to display the content,
|
||||
it needs to know about the dom window where the content originated from.
|
||||
aRequest is a request whose content type is already known (aContentType) */
|
||||
void handleContent(in string aContentType,
|
||||
in string aCommand,
|
||||
in string aWindowTarget,
|
||||
in nsISupports aSourceContext,
|
||||
in nsISupports aWindowContext,
|
||||
in nsIRequest aRequest);
|
||||
};
|
||||
|
||||
|
||||
@ -46,10 +46,9 @@ interface nsIURIContentListener : nsISupports
|
||||
happens.
|
||||
|
||||
aURI --> the uri we are going to try and open.
|
||||
aWindowTarget --> the window target passed to the uriloader to open.
|
||||
return value --> specifies if the open should be aborted.
|
||||
*/
|
||||
boolean onStartURIOpen(in nsIURI aURI, in string aWindowTarget);
|
||||
boolean onStartURIOpen(in nsIURI aURI);
|
||||
|
||||
/* Give the content listener first crack at forcing us to use
|
||||
a specific content handler. Content listener's do not need to
|
||||
@ -80,7 +79,6 @@ interface nsIURIContentListener : nsISupports
|
||||
|
||||
boolean doContent(in string aContentType,
|
||||
in nsURILoadCommand aCommand,
|
||||
in string aWindowTarget,
|
||||
in nsIRequest request,
|
||||
out nsIStreamListener aContentHandler);
|
||||
|
||||
@ -96,7 +94,6 @@ interface nsIURIContentListener : nsISupports
|
||||
|
||||
aContentType --> the content type to handle
|
||||
aCommand --> verb for the action
|
||||
aWindowTarget --> name of the target window (if any)
|
||||
aDesiredContentType --> yes, we can accept aContentType but we would
|
||||
like it converted to aDesiredContentType. This argument can
|
||||
be null if you want the content directly as aContentType
|
||||
@ -105,7 +102,6 @@ interface nsIURIContentListener : nsISupports
|
||||
*/
|
||||
boolean isPreferred(in string aContentType,
|
||||
in nsURILoadCommand aCommand,
|
||||
in string aWindowTarget,
|
||||
out string aDesiredContentType);
|
||||
|
||||
/* When given a uri to dispatch, if the load type is anything but
|
||||
@ -121,7 +117,6 @@ interface nsIURIContentListener : nsISupports
|
||||
*/
|
||||
boolean canHandleContent(in string aContentType,
|
||||
in nsURILoadCommand aCommand,
|
||||
in string aWindowTarget,
|
||||
out string aDesiredContentType);
|
||||
|
||||
/* Get/Set loadCookie are methods the uri loader calls on the
|
||||
|
||||
@ -84,7 +84,6 @@ interface nsIURILoader : nsISupports
|
||||
|
||||
void openURI(in nsIChannel aChannel,
|
||||
in nsURILoadCommand aCommand,
|
||||
in string aWindowTarget,
|
||||
in nsISupports aWindowContext);
|
||||
|
||||
|
||||
@ -93,7 +92,6 @@ interface nsIURILoader : nsISupports
|
||||
|
||||
void openURIVia(in nsIChannel aChannel,
|
||||
in nsURILoadCommand aCommand,
|
||||
in string aWindowTarget,
|
||||
in nsISupports aWindowContext,
|
||||
in unsigned long adapterBinding);
|
||||
|
||||
@ -115,7 +113,6 @@ interface nsIURILoader : nsISupports
|
||||
*/
|
||||
void dispatchContent(in string aContentType,
|
||||
in nsURILoadCommand aCommand,
|
||||
in string aWindowTarget,
|
||||
in nsIRequest aRequest,
|
||||
in nsISupports aCtxt,
|
||||
in nsIURIContentListener aContentListener,
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
|
||||
@ -50,17 +51,6 @@
|
||||
|
||||
#include "nsCExternalHandlerService.h" // contains contractids for the helper app service
|
||||
|
||||
// Following are for Bug 13871: Prevent frameset spoofing
|
||||
#include "nsIPref.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsICodebasePrincipal.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
static NS_DEFINE_CID(kURILoaderCID, NS_URI_LOADER_CID);
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
|
||||
|
||||
@ -75,14 +65,10 @@ class nsDocumentOpenInfo : public nsIStreamListener
|
||||
public:
|
||||
nsDocumentOpenInfo();
|
||||
|
||||
nsresult Init(nsISupports * aRetargetedWindowContext,
|
||||
nsISupports * aOriginalWindowContext);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsresult Open(nsIChannel* channel,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsISupports * aWindowContext);
|
||||
|
||||
nsresult DispatchContent(nsIRequest *request, nsISupports * aCtxt);
|
||||
@ -108,7 +94,6 @@ protected:
|
||||
nsCOMPtr<nsIStreamListener> m_targetStreamListener;
|
||||
nsCOMPtr<nsISupports> m_originalContext;
|
||||
nsURILoadCommand mCommand;
|
||||
nsCString m_windowTarget;
|
||||
PRBool mOnStopFired;
|
||||
};
|
||||
|
||||
@ -131,16 +116,6 @@ nsDocumentOpenInfo::~nsDocumentOpenInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult nsDocumentOpenInfo::Init(nsISupports * aCurrentWindowContext,
|
||||
nsISupports * aOriginalWindowContext)
|
||||
{
|
||||
// ask the window context if it has a uri content listener...
|
||||
nsresult rv = NS_OK;
|
||||
m_contentListener = do_GetInterface(aCurrentWindowContext, &rv);
|
||||
m_originalContext = aOriginalWindowContext;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsDocumentOpenInfo* nsDocumentOpenInfo::Clone()
|
||||
{
|
||||
nsDocumentOpenInfo* newObject;
|
||||
@ -149,7 +124,6 @@ nsDocumentOpenInfo* nsDocumentOpenInfo::Clone()
|
||||
if (newObject) {
|
||||
newObject->m_contentListener = m_contentListener;
|
||||
newObject->mCommand = mCommand;
|
||||
newObject->m_windowTarget = m_windowTarget;
|
||||
newObject->m_originalContext = m_originalContext;
|
||||
}
|
||||
|
||||
@ -185,7 +159,6 @@ PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIRequest *request)
|
||||
|
||||
nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsISupports * aWindowContext)
|
||||
{
|
||||
// this method is not complete!!! Eventually, we should first go
|
||||
@ -196,10 +169,16 @@ nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel,
|
||||
// But for now, I'm going to let necko do the work for us....
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// store any local state
|
||||
m_windowTarget = aWindowTarget;
|
||||
mCommand = aCommand;
|
||||
|
||||
m_originalContext = aWindowContext;
|
||||
|
||||
// ask the window context if it has a uri content listener...
|
||||
m_contentListener = do_GetInterface(aWindowContext, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// now just open the channel!
|
||||
if (aChannel){
|
||||
rv = aChannel->AsyncOpen(this, nsnull);
|
||||
@ -286,7 +265,6 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
||||
nsCOMPtr<nsIStreamListener> contentStreamListener;
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if (!aChannel) {
|
||||
printf(">>> QI for channel from request failed!!\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -294,7 +272,8 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// go to the uri dispatcher and give them our stuff...
|
||||
NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv);
|
||||
nsCOMPtr<nsIURILoader> uriLoader;
|
||||
uriLoader = do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIURIContentListener> contentListener;
|
||||
@ -305,13 +284,13 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
||||
// content type.
|
||||
//
|
||||
PRBool abortDispatch = PR_FALSE;
|
||||
rv = pURILoader->DispatchContent(contentType, mCommand, m_windowTarget,
|
||||
request, aCtxt,
|
||||
m_contentListener,
|
||||
m_originalContext,
|
||||
getter_Copies(desiredContentType),
|
||||
getter_AddRefs(contentListener),
|
||||
&abortDispatch);
|
||||
rv = uriLoader->DispatchContent(contentType, mCommand,
|
||||
request, aCtxt,
|
||||
m_contentListener,
|
||||
m_originalContext,
|
||||
getter_Copies(desiredContentType),
|
||||
getter_AddRefs(contentListener),
|
||||
&abortDispatch);
|
||||
|
||||
// if the uri loader says to abort the dispatch then someone
|
||||
// else must have stepped in and taken over for us...so stop..
|
||||
@ -366,7 +345,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
||||
aChannel->SetLoadFlags(loadFlags);
|
||||
}
|
||||
|
||||
rv = contentListener->DoContent(contentTypeToUse, mCommand, m_windowTarget,
|
||||
rv = contentListener->DoContent(contentTypeToUse, mCommand,
|
||||
request, getter_AddRefs(contentStreamListener),
|
||||
&bAbortProcess);
|
||||
|
||||
@ -456,13 +435,6 @@ nsURILoader::nsURILoader()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
NS_NewISupportsArray(getter_AddRefs(m_listeners));
|
||||
|
||||
// Check pref to see if we should prevent frameset spoofing
|
||||
mValidateOrigin = PR_TRUE; // secure by default, pref disables check
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
NS_ASSERTION(prefs,"nsURILoader: could not get prefs service!\n");
|
||||
if (prefs)
|
||||
prefs->GetBoolPref("browser.frame.validate_origin", &mValidateOrigin);
|
||||
}
|
||||
|
||||
nsURILoader::~nsURILoader()
|
||||
@ -505,275 +477,14 @@ NS_IMETHODIMP nsURILoader::UnRegisterContentListener(nsIURIContentListener * aCo
|
||||
|
||||
NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsISupports * aWindowContext)
|
||||
{
|
||||
return OpenURIVia(channel, aCommand, aWindowTarget, aWindowContext, 0 /* ip address */);
|
||||
}
|
||||
|
||||
//
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
// Check if origin document uri is the equivalent to target's principal.
|
||||
// This takes into account subdomain checking if document.domain is set for
|
||||
// Nav 4.x compatability.
|
||||
//
|
||||
// The following was derived from nsCodeBasePrincipal::Equals but in addition
|
||||
// to the host PL_strcmp, it accepts a subdomain (nsHTMLDocument::SetDomain)
|
||||
// if the document.domain was set.
|
||||
//
|
||||
static
|
||||
PRBool SameOrSubdomainOfTarget(nsIURI* aOriginURI, nsIURI* aTargetURI, PRBool aDocumentDomainSet)
|
||||
{
|
||||
nsXPIDLCString targetScheme;
|
||||
nsresult rv = aTargetURI->GetScheme(getter_Copies(targetScheme));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetScheme, PR_TRUE);
|
||||
|
||||
nsXPIDLCString originScheme;
|
||||
rv = aOriginURI->GetScheme(getter_Copies(originScheme));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originScheme, PR_TRUE);
|
||||
|
||||
if (PL_strcmp(targetScheme, originScheme))
|
||||
return PR_FALSE; // Different schemes - check fails
|
||||
|
||||
if (! PL_strcmp(targetScheme, "file"))
|
||||
return PR_TRUE; // All file: urls are considered to have the same origin.
|
||||
|
||||
if (! PL_strcmp(targetScheme, "imap") ||
|
||||
! PL_strcmp(targetScheme, "mailbox") ||
|
||||
! PL_strcmp(targetScheme, "news"))
|
||||
{
|
||||
|
||||
// Each message is a distinct trust domain; use the whole spec for comparison
|
||||
nsXPIDLCString targetSpec;
|
||||
rv =aTargetURI->GetSpec(getter_Copies(targetSpec));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetSpec, PR_TRUE);
|
||||
|
||||
nsXPIDLCString originSpec;
|
||||
rv = aOriginURI->GetSpec(getter_Copies(originSpec));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originSpec, PR_TRUE);
|
||||
|
||||
return (! PL_strcmp(targetSpec, originSpec)); // True if full spec is same, false otherwise
|
||||
}
|
||||
|
||||
// Compare ports.
|
||||
int targetPort, originPort;
|
||||
rv = aTargetURI->GetPort(&targetPort);
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), PR_TRUE);
|
||||
|
||||
rv = aOriginURI->GetPort(&originPort);
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), PR_TRUE);
|
||||
|
||||
if (targetPort != originPort)
|
||||
return PR_FALSE; // Different port - check fails
|
||||
|
||||
// Need to check the hosts
|
||||
nsXPIDLCString targetHost;
|
||||
rv = aTargetURI->GetHost(getter_Copies(targetHost));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetHost, PR_TRUE);
|
||||
|
||||
nsXPIDLCString originHost;
|
||||
rv = aOriginURI->GetHost(getter_Copies(originHost));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originHost, PR_TRUE);
|
||||
|
||||
if (!PL_strcmp(targetHost, originHost))
|
||||
return PR_TRUE; // Hosts are the same - check passed
|
||||
|
||||
// If document.domain was set, do the relaxed check
|
||||
// Right align hostnames and compare - ensure preceeding char is . or /
|
||||
if (aDocumentDomainSet)
|
||||
{
|
||||
int targetHostLen = PL_strlen(targetHost);
|
||||
int originHostLen = PL_strlen(originHost);
|
||||
int prefixChar = originHostLen-targetHostLen-1;
|
||||
|
||||
return ((originHostLen > targetHostLen) &&
|
||||
(! PL_strcmp((originHost+prefixChar+1), targetHost)) &&
|
||||
(originHost[prefixChar] == '.' || originHost[prefixChar] == '/'));
|
||||
}
|
||||
|
||||
return PR_FALSE; // document.domain not set and hosts not same - check failed
|
||||
}
|
||||
|
||||
//
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
//
|
||||
// This routine answers: 'Is origin's document from same domain as target's document?'
|
||||
// Be optimistic that domain is same - error cases all answer 'yes'.
|
||||
//
|
||||
// We have to compare the URI of the actual document loaded in the origin,
|
||||
// ignoring any document.domain that was set, with the principal URI of the
|
||||
// target (including any document.domain that was set). This puts control
|
||||
// of loading in the hands of the target, which is more secure. (per Nav 4.x)
|
||||
//
|
||||
static
|
||||
PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem, nsIDocShellTreeItem* aTargetTreeItem)
|
||||
{
|
||||
// Get origin document uri (ignoring document.domain)
|
||||
nsCOMPtr<nsIWebNavigation> originWebNav(do_QueryInterface(aOriginTreeItem));
|
||||
NS_ENSURE_TRUE(originWebNav, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIURI> originDocumentURI;
|
||||
nsresult rv = originWebNav->GetCurrentURI(getter_AddRefs(originDocumentURI));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && originDocumentURI, PR_TRUE);
|
||||
|
||||
// Get target principal uri (including document.domain)
|
||||
nsCOMPtr<nsIDOMDocument> targetDOMDocument(do_GetInterface(aTargetTreeItem));
|
||||
NS_ENSURE_TRUE(targetDOMDocument, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> targetDocument(do_QueryInterface(targetDOMDocument));
|
||||
NS_ENSURE_TRUE(targetDocument, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> targetPrincipal;
|
||||
rv = targetDocument->GetPrincipal(getter_AddRefs(targetPrincipal));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetPrincipal, rv);
|
||||
|
||||
nsCOMPtr<nsICodebasePrincipal> targetCodebasePrincipal(do_QueryInterface(targetPrincipal));
|
||||
NS_ENSURE_TRUE(targetCodebasePrincipal, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIURI> targetPrincipalURI;
|
||||
rv = targetCodebasePrincipal->GetURI(getter_AddRefs(targetPrincipalURI));
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && targetPrincipalURI, PR_TRUE);
|
||||
|
||||
// Find out if document.domain was set for HTML documents
|
||||
PRBool documentDomainSet = PR_FALSE;
|
||||
nsCOMPtr<nsIHTMLDocument> targetHTMLDocument(do_QueryInterface(targetDocument));
|
||||
|
||||
// If we don't have an HTML document, fall through with documentDomainSet false
|
||||
if (targetHTMLDocument) {
|
||||
targetHTMLDocument->WasDomainSet(&documentDomainSet);
|
||||
}
|
||||
|
||||
// Is origin same principal or a subdomain of target's document.domain
|
||||
// Compare actual URI of origin document, not origin principal's URI. (Per Nav 4.x)
|
||||
return SameOrSubdomainOfTarget(originDocumentURI, targetPrincipalURI, documentDomainSet);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURILoader::GetTarget(nsIChannel *channel, nsCString &aWindowTarget,
|
||||
nsISupports * aWindowContext,
|
||||
nsISupports ** aRetargetedWindowContext)
|
||||
{
|
||||
nsAutoString name; name.AssignWithConversion(aWindowTarget);
|
||||
nsCOMPtr<nsIDocShellTreeItem> windowCtxtAsTreeItem (do_GetInterface(aWindowContext));
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem;
|
||||
*aRetargetedWindowContext = nsnull;
|
||||
|
||||
PRBool mustMakeNewWindow = PR_FALSE;
|
||||
|
||||
if(!name.Length() || name.EqualsIgnoreCase("_self"))
|
||||
{
|
||||
*aRetargetedWindowContext = aWindowContext;
|
||||
}
|
||||
else if (name.EqualsIgnoreCase("_blank") || name.EqualsIgnoreCase("_new"))
|
||||
{
|
||||
mustMakeNewWindow = PR_TRUE;
|
||||
aWindowTarget.Assign("");
|
||||
}
|
||||
else if(name.EqualsIgnoreCase("_parent"))
|
||||
{
|
||||
windowCtxtAsTreeItem->GetSameTypeParent(getter_AddRefs(treeItem));
|
||||
if(!treeItem)
|
||||
*aRetargetedWindowContext = aWindowContext;
|
||||
}
|
||||
else if(name.EqualsIgnoreCase("_top"))
|
||||
{
|
||||
windowCtxtAsTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(treeItem));
|
||||
if(!treeItem)
|
||||
*aRetargetedWindowContext = aWindowContext;
|
||||
}
|
||||
else if(name.EqualsIgnoreCase("_content"))
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
windowCtxtAsTreeItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
|
||||
if (treeOwner)
|
||||
treeOwner->FindItemWithName(name.GetUnicode(), nsnull, getter_AddRefs(treeItem));
|
||||
else
|
||||
{
|
||||
NS_ERROR("Someone isn't setting up the tree owner. You might like to try that."
|
||||
"Things will.....you know, work.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
windowCtxtAsTreeItem->FindItemWithName(name.GetUnicode(), nsnull, getter_AddRefs(treeItem));
|
||||
|
||||
// The named window cannot be found so it must be created to receive the
|
||||
// channel data.
|
||||
|
||||
if (!treeItem) {
|
||||
mustMakeNewWindow = PR_TRUE;
|
||||
}
|
||||
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
// See BugSplat 336170, 338737 and XP_FindNamedContextInList in the classic codebase
|
||||
// Per Nav's behaviour:
|
||||
// - pref controlled: "browser.frame.validate_origin" (mValidateOrigin)
|
||||
// - allow load if host of target or target's parent is same as host of origin
|
||||
// - allow load if target is a top level window
|
||||
|
||||
// Check to see if pref is true
|
||||
if (mValidateOrigin && windowCtxtAsTreeItem && treeItem) {
|
||||
|
||||
// Is origin frame from the same domain as target frame?
|
||||
if (! ValidateOrigin(windowCtxtAsTreeItem, treeItem)) {
|
||||
|
||||
// No. Is origin frame from the same domain as target's parent?
|
||||
nsCOMPtr<nsIDocShellTreeItem> targetParentTreeItem;
|
||||
nsresult rv = treeItem->GetSameTypeParent(getter_AddRefs(targetParentTreeItem));
|
||||
if (NS_SUCCEEDED(rv) && targetParentTreeItem) {
|
||||
if (! ValidateOrigin(windowCtxtAsTreeItem, targetParentTreeItem)) {
|
||||
|
||||
// Neither is from the origin domain, send load to a new window (_blank)
|
||||
*aRetargetedWindowContext = aWindowContext;
|
||||
aWindowTarget.Assign("_blank");
|
||||
} // else (target's parent from origin domain) allow this load
|
||||
} // else (no parent) allow this load since shell is a toplevel window
|
||||
} // else (target from origin domain) allow this load
|
||||
} // else (pref is false) allow this load
|
||||
}
|
||||
|
||||
if (mustMakeNewWindow) {
|
||||
nsCOMPtr<nsIDOMWindowInternal> parentWindow;
|
||||
|
||||
if (aWindowContext)
|
||||
{
|
||||
parentWindow = do_GetInterface(aWindowContext);
|
||||
|
||||
if (!parentWindow)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new window (context) so that the uri loader has a proper
|
||||
// target to push the content into.
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
parentWindow->Open(NS_LITERAL_STRING(""),
|
||||
NS_ConvertASCIItoUCS2(aWindowTarget),
|
||||
nsLiteralString(nsnull) /* NULL string*/, getter_AddRefs(newWindow));
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(newWindow);
|
||||
nsIDocShell *docShell = nsnull;
|
||||
sgo->GetDocShell(&docShell);
|
||||
|
||||
*aRetargetedWindowContext = (nsISupports *) docShell;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> treeItemCtxt (do_QueryInterface(treeItem));
|
||||
if (!*aRetargetedWindowContext)
|
||||
{
|
||||
*aRetargetedWindowContext = treeItemCtxt;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aRetargetedWindowContext);
|
||||
return NS_OK;
|
||||
return OpenURIVia(channel, aCommand, aWindowContext, 0 /* ip address */);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsISupports * aOriginalWindowContext,
|
||||
nsISupports * aWindowContext,
|
||||
PRUint32 aLocalIP)
|
||||
{
|
||||
// we need to create a DocumentOpenInfo object which will go ahead and open the url
|
||||
@ -785,37 +496,29 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel,
|
||||
|
||||
// Let the window context's uriListener know that the open is starting. This
|
||||
// gives that window a chance to abort the load process.
|
||||
nsCOMPtr<nsIURIContentListener> winContextListener(do_GetInterface(aOriginalWindowContext));
|
||||
if(winContextListener)
|
||||
{
|
||||
nsCOMPtr<nsIURIContentListener> winContextListener(do_GetInterface(aWindowContext));
|
||||
if(winContextListener) {
|
||||
// get channel from request
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
if(uri)
|
||||
{
|
||||
if(uri) {
|
||||
PRBool doAbort = PR_FALSE;
|
||||
winContextListener->OnStartURIOpen(uri, aWindowTarget, &doAbort);
|
||||
winContextListener->OnStartURIOpen(uri, &doAbort);
|
||||
|
||||
if(doAbort)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCAutoString windowTarget(aWindowTarget);
|
||||
nsCOMPtr<nsISupports> retargetedWindowContext;
|
||||
NS_ENSURE_SUCCESS(GetTarget(channel, windowTarget, aOriginalWindowContext, getter_AddRefs(retargetedWindowContext)), NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_NEWXPCOM(loader, nsDocumentOpenInfo);
|
||||
if (!loader) return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(loader);
|
||||
|
||||
nsCOMPtr<nsIInterfaceRequestor> loadCookie;
|
||||
SetupLoadCookie(retargetedWindowContext, getter_AddRefs(loadCookie));
|
||||
|
||||
loader->Init(retargetedWindowContext, aOriginalWindowContext); // Extra Info
|
||||
SetupLoadCookie(aWindowContext, getter_AddRefs(loadCookie));
|
||||
|
||||
// now instruct the loader to go ahead and open the url
|
||||
rv = loader->Open(channel, aCommand, windowTarget, retargetedWindowContext);
|
||||
rv = loader->Open(channel, aCommand, aWindowContext);
|
||||
NS_RELEASE(loader);
|
||||
|
||||
return rv;
|
||||
@ -947,16 +650,15 @@ nsresult nsURILoader::SetupLoadCookie(nsISupports * aWindowContext,
|
||||
PRBool nsURILoader::ShouldHandleContent(nsIURIContentListener * aCntListener,
|
||||
const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aContentTypeToUse)
|
||||
{
|
||||
PRBool foundContentHandler = PR_FALSE;
|
||||
if (aCommand == nsIURILoader::viewUserClick)
|
||||
aCntListener->IsPreferred(aContentType, aCommand, aWindowTarget,
|
||||
aCntListener->IsPreferred(aContentType, aCommand,
|
||||
aContentTypeToUse,
|
||||
&foundContentHandler);
|
||||
else
|
||||
aCntListener->CanHandleContent(aContentType, aCommand, aWindowTarget,
|
||||
aCntListener->CanHandleContent(aContentType, aCommand,
|
||||
aContentTypeToUse,
|
||||
&foundContentHandler);
|
||||
return foundContentHandler;
|
||||
@ -964,7 +666,6 @@ PRBool nsURILoader::ShouldHandleContent(nsIURIContentListener * aCntListener,
|
||||
|
||||
NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsIRequest *request,
|
||||
nsISupports * aCtxt,
|
||||
nsIURIContentListener * aContentListener,
|
||||
@ -992,69 +693,57 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIURIContentListener> listenerToUse = aContentListener;
|
||||
PRBool skipRetargetingSearch = PR_FALSE;
|
||||
// How do we determine whether we need to ask any registered content
|
||||
// listeners if they want a crack at the content?
|
||||
// (1) if the window target is blank or new, then we don't want to
|
||||
// ask...
|
||||
if (!nsCRT::strcasecmp(aWindowTarget, "_blank") || !nsCRT::strcasecmp(aWindowTarget, "_new"))
|
||||
skipRetargetingSearch = PR_TRUE;
|
||||
else
|
||||
{
|
||||
// (2) if the original content listener is NULL and we have a
|
||||
// target name then we must not be a window open with that
|
||||
// target name so skip the content listener search and skip to
|
||||
// the part that brings up the new window.
|
||||
if (aWindowTarget && *aWindowTarget && !aContentListener)
|
||||
skipRetargetingSearch = PR_TRUE;
|
||||
}
|
||||
|
||||
// find a content handler that can and will handle the content
|
||||
if (!skipRetargetingSearch)
|
||||
{
|
||||
PRBool foundContentHandler = PR_FALSE;
|
||||
if (listenerToUse)
|
||||
foundContentHandler = ShouldHandleContent(listenerToUse, aContentType,
|
||||
aCommand, aWindowTarget, aContentTypeToUse);
|
||||
|
||||
PRBool foundContentHandler = PR_FALSE;
|
||||
if (listenerToUse)
|
||||
foundContentHandler = ShouldHandleContent(listenerToUse,
|
||||
aContentType,
|
||||
aCommand,
|
||||
aContentTypeToUse);
|
||||
|
||||
|
||||
// if it can't handle the content, scan through the list of
|
||||
// registered listeners
|
||||
if (!foundContentHandler)
|
||||
// if it can't handle the content, scan through the list of
|
||||
// registered listeners
|
||||
if (!foundContentHandler)
|
||||
{
|
||||
PRUint32 count = 0;
|
||||
PRInt32 i;
|
||||
|
||||
// keep looping until we get a content listener back
|
||||
m_listeners->Count(&count);
|
||||
for(i = 0; i < (PRInt32)count && !foundContentHandler; i++)
|
||||
{
|
||||
PRInt32 i = 0;
|
||||
// keep looping until we get a content listener back
|
||||
PRUint32 count; m_listeners->Count(&count);
|
||||
for(i = 0; i < PRInt32(count) && !foundContentHandler; i++)
|
||||
{
|
||||
//nsIURIContentListener's aren't refcounted.
|
||||
nsWeakPtr weakListener;
|
||||
m_listeners->QueryElementAt(i, NS_GET_IID(nsIWeakReference),
|
||||
getter_AddRefs(weakListener));
|
||||
//nsIURIContentListener's aren't refcounted.
|
||||
nsWeakPtr weakListener;
|
||||
nsCOMPtr<nsIURIContentListener> listener;
|
||||
|
||||
m_listeners->QueryElementAt(i, NS_GET_IID(nsIWeakReference),
|
||||
getter_AddRefs(weakListener));
|
||||
|
||||
nsCOMPtr<nsIURIContentListener> listener =
|
||||
do_QueryReferent(weakListener);
|
||||
if (listener)
|
||||
{
|
||||
foundContentHandler = ShouldHandleContent(listener, aContentType,
|
||||
aCommand, aWindowTarget, aContentTypeToUse);
|
||||
if (foundContentHandler)
|
||||
listenerToUse = listener;
|
||||
} else {
|
||||
// remove from the listener list, and reset i
|
||||
m_listeners->RemoveElementAt(i);
|
||||
i--;
|
||||
}
|
||||
} // for loop
|
||||
} // if we can't handle the content
|
||||
listener = do_QueryReferent(weakListener);
|
||||
if (listener)
|
||||
{
|
||||
foundContentHandler = ShouldHandleContent(listener,
|
||||
aContentType,
|
||||
aCommand,
|
||||
aContentTypeToUse);
|
||||
if (foundContentHandler) {
|
||||
listenerToUse = listener;
|
||||
}
|
||||
} else {
|
||||
// remove from the listener list, and reset i
|
||||
m_listeners->RemoveElementAt(i);
|
||||
i--;
|
||||
}
|
||||
} // for loop
|
||||
} // if we can't handle the content
|
||||
|
||||
|
||||
if (foundContentHandler && listenerToUse)
|
||||
{
|
||||
*aContentListenerToUse = listenerToUse;
|
||||
NS_IF_ADDREF(*aContentListenerToUse);
|
||||
return rv;
|
||||
}
|
||||
if (foundContentHandler && listenerToUse)
|
||||
{
|
||||
*aContentListenerToUse = listenerToUse;
|
||||
NS_IF_ADDREF(*aContentListenerToUse);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// no registered content listeners to handle this type!!! so go to the register
|
||||
@ -1067,10 +756,10 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
|
||||
handlerContractID += aContentType;
|
||||
|
||||
nsCOMPtr<nsIContentHandler> aContentHandler;
|
||||
rv = nsComponentManager::CreateInstance(handlerContractID, nsnull, NS_GET_IID(nsIContentHandler), getter_AddRefs(aContentHandler));
|
||||
aContentHandler = do_CreateInstance(handlerContractID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) // we did indeed have a content handler for this type!! yippee...
|
||||
{
|
||||
rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aSrcWindowContext, request);
|
||||
rv = aContentHandler->HandleContent(aContentType, "view", aSrcWindowContext, request);
|
||||
*aAbortProcess = PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -45,9 +45,6 @@ protected:
|
||||
// when they go away. This array stores weak references
|
||||
nsCOMPtr<nsISupportsArray> m_listeners;
|
||||
|
||||
// If set, we will try to prevent frame spoofing (set by pref in constructor)
|
||||
PRBool mValidateOrigin;
|
||||
|
||||
// prepare the load cookie for the window context
|
||||
nsresult SetupLoadCookie(nsISupports * aWindowContext, nsIInterfaceRequestor ** aLoadCookie);
|
||||
|
||||
@ -55,12 +52,7 @@ protected:
|
||||
PRBool ShouldHandleContent(nsIURIContentListener * aCntListener,
|
||||
const char * aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char * aWindowTarget,
|
||||
char ** aContentTypeToUse);
|
||||
|
||||
NS_IMETHOD GetTarget(nsIChannel * aChannel, nsCString &aWindowTarget,
|
||||
nsISupports * aWindowContext,
|
||||
nsISupports ** aRetargetedWindowContext);
|
||||
};
|
||||
|
||||
#endif /* nsURILoader_h__ */
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
\/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
@ -109,7 +109,6 @@ RemoteHelperContentListener::~RemoteHelperContentListener()
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteHelperContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
const char *aWindowTarget,
|
||||
PRBool *aAbortOpen)
|
||||
{
|
||||
return NS_OK;
|
||||
@ -126,7 +125,6 @@ RemoteHelperContentListener::GetProtocolHandler(nsIURI *aURI,
|
||||
NS_IMETHODIMP
|
||||
RemoteHelperContentListener::DoContent(const char *aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget,
|
||||
nsIRequest *aOpenedRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
@ -138,7 +136,6 @@ RemoteHelperContentListener::DoContent(const char *aContentType,
|
||||
NS_IMETHODIMP
|
||||
RemoteHelperContentListener::IsPreferred(const char *aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
@ -149,7 +146,6 @@ RemoteHelperContentListener::IsPreferred(const char *aContentType,
|
||||
NS_IMETHODIMP
|
||||
RemoteHelperContentListener::CanHandleContent(const char *aContentType,
|
||||
nsURILoadCommand aCommand,
|
||||
const char *aWindowTarget,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
|
||||
@ -67,7 +67,7 @@ nsBrowserContentListener.prototype =
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
|
||||
},
|
||||
onStartURIOpen: function(uri, windowTarget)
|
||||
onStartURIOpen: function(uri)
|
||||
{
|
||||
// ignore and don't abort
|
||||
return false;
|
||||
@ -78,8 +78,7 @@ nsBrowserContentListener.prototype =
|
||||
return null;
|
||||
},
|
||||
|
||||
doContent: function(contentType, command, windowTarget,
|
||||
request, contentHandler)
|
||||
doContent: function(contentType, command, request, contentHandler)
|
||||
{
|
||||
// forward the doContent to our content area webshell
|
||||
var docShell = this.contentWindow.docShell;
|
||||
@ -94,12 +93,11 @@ nsBrowserContentListener.prototype =
|
||||
|
||||
if (!contentListener) return false;
|
||||
|
||||
return contentListener.doContent(contentType, command, windowTarget, request, contentHandler);
|
||||
return contentListener.doContent(contentType, command, request, contentHandler);
|
||||
|
||||
},
|
||||
|
||||
isPreferred: function(contentType, command,
|
||||
windowTarget, desiredContentType)
|
||||
isPreferred: function(contentType, command, desiredContentType)
|
||||
{
|
||||
// seems like we should be getting this from helper apps or something
|
||||
switch(contentType) {
|
||||
@ -118,8 +116,7 @@ nsBrowserContentListener.prototype =
|
||||
}
|
||||
return false;
|
||||
},
|
||||
canHandleContent: function(contentType, command,
|
||||
windowTarget, desiredContentType)
|
||||
canHandleContent: function(contentType, command, desiredContentType)
|
||||
{
|
||||
var docShell = this.contentWindow.docShell;
|
||||
var contentListener;
|
||||
@ -131,7 +128,7 @@ nsBrowserContentListener.prototype =
|
||||
}
|
||||
if (!contentListener) return false;
|
||||
|
||||
return contentListener.canHandleContent(contentType, command, windowTarget, desiredContentType);
|
||||
return contentListener.canHandleContent(contentType, command, desiredContentType);
|
||||
},
|
||||
convertWindowToDocShell: function(win) {
|
||||
// don't know how to do this
|
||||
|
||||
@ -951,7 +951,6 @@ NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs)
|
||||
|
||||
NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
|
||||
const char * aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsISupports * aWindowContext,
|
||||
nsIRequest * aRequest)
|
||||
{
|
||||
@ -971,20 +970,10 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType,
|
||||
nsXPIDLCString spec;
|
||||
uri->GetSpec(getter_Copies(spec));
|
||||
|
||||
// we only want to pass in the window target name if it isn't something like _new or _blank....
|
||||
// i.e. only real names like "my window", etc...
|
||||
const char * windowTarget = aWindowTarget;
|
||||
if (!aWindowTarget || !nsCRT::strcasecmp(aWindowTarget, "_new") ||
|
||||
!nsCRT::strcasecmp(aWindowTarget, "_blank") ||
|
||||
!nsCRT::strcasecmp(aWindowTarget, "_top") ||
|
||||
!nsCRT::strcasecmp(aWindowTarget, "_parent") ||
|
||||
!nsCRT::strcasecmp(aWindowTarget, "_content"))
|
||||
windowTarget = "";
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch) {
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
wwatch->OpenWindow(parentWindow, spec, windowTarget, 0, 0,
|
||||
wwatch->OpenWindow(parentWindow, spec, "", 0, 0,
|
||||
getter_AddRefs(newWindow));
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,6 @@ nsInstallTrigger::SetScriptObject(void *aScriptObject)
|
||||
NS_IMETHODIMP
|
||||
nsInstallTrigger::HandleContent(const char * aContentType,
|
||||
const char * aCommand,
|
||||
const char * aWindowTarget,
|
||||
nsISupports* aWindowContext,
|
||||
nsIRequest* request)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user