Bug 326107 r=darin, sr=bzbarsky, branch-1.8.1=darin:

Send referrer to GlobalHistory even when it isn't being sent over the network


git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@189279 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brettw%gmail.com
2006-02-07 02:02:56 +00:00
parent f55cf11272
commit 09a08c4a09
2 changed files with 19 additions and 15 deletions

View File

@@ -4717,12 +4717,7 @@ nsDocShell::OnRedirectStateChange(nsIChannel* aOldChannel,
aOldChannel->GetURI(getter_AddRefs(oldURI));
if (! oldURI)
return; // nothing to tell anybody about
nsCOMPtr<nsIHttpChannel> httpchannel(do_QueryInterface(aOldChannel));
nsCOMPtr<nsIURI> referrer;
if (httpchannel)
httpchannel->GetReferrer(getter_AddRefs(referrer));
AddToGlobalHistory(oldURI, PR_TRUE, referrer);
AddToGlobalHistory(oldURI, PR_TRUE, aOldChannel);
}
}
@@ -7335,11 +7330,7 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel,
// Update Global history
if (aAddToGlobalHistory) {
// Get the referrer uri from the channel
nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsIHttpChannel> httpchannel(do_QueryInterface(aChannel));
if (httpchannel)
httpchannel->GetReferrer(getter_AddRefs(referrer));
AddToGlobalHistory(aURI, PR_FALSE, referrer);
AddToGlobalHistory(aURI, PR_FALSE, aChannel);
}
}
@@ -8082,7 +8073,8 @@ NS_IMETHODIMP nsDocShell::MakeEditable(PRBool inWaitForUriLoad)
}
nsresult
nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aRedirect, nsIURI * aReferrer)
nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aRedirect,
nsIChannel * aChannel)
{
if (mItemType != typeContent || !mGlobalHistory)
return NS_OK;
@@ -8091,8 +8083,19 @@ nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aRedirect, nsIURI * aReferr
nsresult rv = mGlobalHistory->IsVisited(aURI, &visited);
if (NS_FAILED(rv))
return rv;
rv = mGlobalHistory->AddURI(aURI, aRedirect, !IsFrame(), aReferrer);
// Get referrer from the channel. We have to check for a property on a
// property bag because the referrer may be empty for security reasons (for
// example, when loading a http page with a https referrer).
nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(aChannel));
if (props) {
props->GetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"),
NS_GET_IID(nsIURI),
getter_AddRefs(referrer));
}
rv = mGlobalHistory->AddURI(aURI, aRedirect, !IsFrame(), referrer);
if (NS_FAILED(rv))
return rv;