This commit is contained in:
mstoltz%netscape.com 2000-08-11 04:31:08 +00:00
Родитель 65066903b4
Коммит d25a91b6a0
2 изменённых файлов: 24 добавлений и 19 удалений

Просмотреть файл

@ -70,6 +70,7 @@ class LocationImpl;
class NavigatorImpl;
class ScreenImpl;
class HistoryImpl;
class nsIDocShellLoadInfo;
//*****************************************************************************
// GlobalWindowImpl: Global Object for Scripting
@ -361,7 +362,7 @@ protected:
PRBool aReplace);
nsresult GetSourceURL(JSContext* cx,
nsIURI** sourceURL);
nsresult CheckURL(nsIURI *url, nsIURI** aReferrer);
nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
nsIDocShell *mDocShell; // Weak Reference
void *mScriptObject;

Просмотреть файл

@ -104,7 +104,7 @@ NS_IMETHODIMP_(void) LocationImpl::SetDocShell(nsIDocShell *aDocShell)
}
nsresult
LocationImpl::CheckURL(nsIURI* aURL, nsIURI** aReferrer)
LocationImpl::CheckURL(nsIURI* aURL, nsIDocShellLoadInfo** aLoadInfo)
{
nsresult result;
// Get JSContext from stack.
@ -126,16 +126,31 @@ LocationImpl::CheckURL(nsIURI* aURL, nsIURI** aReferrer)
if (NS_FAILED(result = secMan->CheckLoadURIFromScript(cx, aURL)))
return result;
// Now get the referrer to use when loading the URI
// Create load info
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
// Now get the principal and referrer to use when loading the URI
nsCOMPtr<nsIPrincipal> principal;
if (NS_FAILED(secMan->GetSubjectPrincipal(getter_AddRefs(principal))))
if (NS_FAILED(secMan->GetSubjectPrincipal(getter_AddRefs(principal))) ||
!principal)
return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> owner = do_QueryInterface(principal);
loadInfo->SetOwner(owner);
nsCOMPtr<nsICodebasePrincipal> codebase = do_QueryInterface(principal);
if (codebase) {
if (NS_FAILED(result = codebase->GetURI(aReferrer)))
if (codebase)
{
nsCOMPtr<nsIURI> referrer;
if (NS_FAILED(result = codebase->GetURI(getter_AddRefs(referrer))))
return result;
loadInfo->SetReferrer(referrer);
}
*aLoadInfo = loadInfo.get();
NS_ADDREF(*aLoadInfo);
return NS_OK;
}
@ -146,15 +161,9 @@ LocationImpl::SetURL(nsIURI* aURL)
if (mDocShell) {
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
nsCOMPtr<nsIURI> referrer;
if(NS_FAILED(CheckURL(aURL, getter_AddRefs(referrer))))
if(NS_FAILED(CheckURL(aURL, getter_AddRefs(loadInfo))))
return NS_ERROR_FAILURE;
loadInfo->SetReferrer(referrer);
return mDocShell->LoadURI(aURL, loadInfo);
}
else {
@ -371,14 +380,9 @@ LocationImpl::SetHrefWithBase(const nsString& aHref,
if ((NS_OK == result) && (mDocShell)) {
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
nsCOMPtr<nsIURI> referrer;
if(NS_FAILED(CheckURL(newUrl, getter_AddRefs(referrer))))
if(NS_FAILED(CheckURL(newUrl, getter_AddRefs(loadInfo))))
return NS_ERROR_FAILURE;
loadInfo->SetReferrer(referrer);
if (aReplace)
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadNormalReplace);