зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1185256 - Save originURI to the history. r=bz
--HG-- extra : rebase_source : 4321df591ab16127ca4cd6549fcdca7e20c2e890
This commit is contained in:
Родитель
0c053ea8e4
Коммит
5f14316a80
|
@ -1267,6 +1267,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
nsCOMPtr<nsIInputStream> postStream;
|
||||
nsCOMPtr<nsIInputStream> headersStream;
|
||||
nsCOMPtr<nsISupports> owner;
|
||||
|
@ -1293,6 +1294,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
// Extract the info from the DocShellLoadInfo struct...
|
||||
if (aLoadInfo) {
|
||||
aLoadInfo->GetReferrer(getter_AddRefs(referrer));
|
||||
aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI));
|
||||
|
||||
nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal;
|
||||
aLoadInfo->GetLoadType(<);
|
||||
|
@ -1547,6 +1549,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
}
|
||||
|
||||
return InternalLoad(aURI,
|
||||
originalURI,
|
||||
referrer,
|
||||
referrerPolicy,
|
||||
owner,
|
||||
|
@ -5212,7 +5215,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
|
|||
rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return InternalLoad(errorPageURI, nullptr, mozilla::net::RP_Default,
|
||||
return InternalLoad(errorPageURI, nullptr, nullptr, mozilla::net::RP_Default,
|
||||
nullptr, INTERNAL_LOAD_FLAGS_INHERIT_OWNER, nullptr,
|
||||
nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE,
|
||||
nullptr, true, NullString(), this, nullptr, nullptr,
|
||||
|
@ -5262,6 +5265,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
nsIPrincipal* principal = nullptr;
|
||||
nsAutoString contentTypeHint;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
if (doc) {
|
||||
principal = doc->NodePrincipal();
|
||||
doc->GetContentType(contentTypeHint);
|
||||
|
@ -5271,8 +5275,17 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
|
||||
baseURI = doc->GetBaseURI();
|
||||
}
|
||||
nsCOMPtr<nsIChannel> chan = doc->GetChannel();
|
||||
if (chan) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
|
||||
if (httpChan) {
|
||||
httpChan->GetOriginalURI(getter_AddRefs(originalURI));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rv = InternalLoad(mCurrentURI,
|
||||
originalURI,
|
||||
mReferrerURI,
|
||||
mReferrerPolicy,
|
||||
principal,
|
||||
|
@ -9304,7 +9317,7 @@ nsDocShell::CopyFavicon(nsIURI* aOldURI,
|
|||
class InternalLoadEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI,
|
||||
InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI, nsIURI* aOriginalURI,
|
||||
nsIURI* aReferrer, uint32_t aReferrerPolicy,
|
||||
nsISupports* aOwner, uint32_t aFlags,
|
||||
const char* aTypeHint, nsIInputStream* aPostData,
|
||||
|
@ -9315,6 +9328,7 @@ public:
|
|||
: mSrcdoc(aSrcdoc)
|
||||
, mDocShell(aDocShell)
|
||||
, mURI(aURI)
|
||||
, mOriginalURI(aOriginalURI)
|
||||
, mReferrer(aReferrer)
|
||||
, mReferrerPolicy(aReferrerPolicy)
|
||||
, mOwner(aOwner)
|
||||
|
@ -9336,7 +9350,8 @@ public:
|
|||
NS_IMETHOD
|
||||
Run()
|
||||
{
|
||||
return mDocShell->InternalLoad(mURI, mReferrer,
|
||||
return mDocShell->InternalLoad(mURI, mOriginalURI,
|
||||
mReferrer,
|
||||
mReferrerPolicy,
|
||||
mOwner, mFlags,
|
||||
nullptr, mTypeHint.get(),
|
||||
|
@ -9354,6 +9369,7 @@ private:
|
|||
|
||||
nsRefPtr<nsDocShell> mDocShell;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mReferrer;
|
||||
uint32_t mReferrerPolicy;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
@ -9397,6 +9413,7 @@ nsDocShell::CreatePrincipalFromReferrer(nsIURI* aReferrer,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::InternalLoad(nsIURI* aURI,
|
||||
nsIURI* aOriginalURI,
|
||||
nsIURI* aReferrer,
|
||||
uint32_t aReferrerPolicy,
|
||||
nsISupports* aOwner,
|
||||
|
@ -9658,6 +9675,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
//
|
||||
if (NS_SUCCEEDED(rv) && targetDocShell) {
|
||||
rv = targetDocShell->InternalLoad(aURI,
|
||||
aOriginalURI,
|
||||
aReferrer,
|
||||
aReferrerPolicy,
|
||||
owner,
|
||||
|
@ -9739,7 +9757,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
|
||||
// Do this asynchronously
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new InternalLoadEvent(this, aURI, aReferrer,
|
||||
new InternalLoadEvent(this, aURI, aOriginalURI, aReferrer,
|
||||
aReferrerPolicy, aOwner, aFlags,
|
||||
aTypeHint, aPostData, aHeadersData,
|
||||
aLoadType, aSHEntry, aFirstParty, aSrcdoc,
|
||||
|
@ -10220,7 +10238,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
nsINetworkPredictor::PREDICT_LOAD, this, nullptr);
|
||||
|
||||
nsCOMPtr<nsIRequest> req;
|
||||
rv = DoURILoad(aURI, aReferrer,
|
||||
rv = DoURILoad(aURI, aOriginalURI, aReferrer,
|
||||
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
|
||||
aReferrerPolicy,
|
||||
owner, aTypeHint, aFileName, aPostData, aHeadersData,
|
||||
|
@ -10294,6 +10312,7 @@ nsDocShell::GetInheritedPrincipal(bool aConsiderCurrentDocument)
|
|||
|
||||
nsresult
|
||||
nsDocShell::DoURILoad(nsIURI* aURI,
|
||||
nsIURI* aOriginalURI,
|
||||
nsIURI* aReferrerURI,
|
||||
bool aSendReferrer,
|
||||
uint32_t aReferrerPolicy,
|
||||
|
@ -10528,7 +10547,12 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
NS_ADDREF(*aRequest = channel);
|
||||
}
|
||||
|
||||
channel->SetOriginalURI(aURI);
|
||||
if (aOriginalURI) {
|
||||
channel->SetOriginalURI(aOriginalURI);
|
||||
} else {
|
||||
channel->SetOriginalURI(aURI);
|
||||
}
|
||||
|
||||
if (aTypeHint && *aTypeHint) {
|
||||
channel->SetContentType(nsDependentCString(aTypeHint));
|
||||
mContentTypeHint = aTypeHint;
|
||||
|
@ -11507,6 +11531,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
|
|||
} else {
|
||||
newSHEntry = mOSHE;
|
||||
newSHEntry->SetURI(newURI);
|
||||
newSHEntry->SetOriginalURI(newURI);
|
||||
}
|
||||
|
||||
// Step 4: Modify new/original session history entry and clear its POST
|
||||
|
@ -11690,6 +11715,7 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
|
|||
|
||||
// Get the post data & referrer
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
nsCOMPtr<nsIURI> referrerURI;
|
||||
uint32_t referrerPolicy = mozilla::net::RP_Default;
|
||||
nsCOMPtr<nsISupports> cacheKey;
|
||||
|
@ -11717,6 +11743,7 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
|
|||
if (uploadChannel) {
|
||||
uploadChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
}
|
||||
httpChannel->GetOriginalURI(getter_AddRefs(originalURI));
|
||||
httpChannel->GetReferrer(getter_AddRefs(referrerURI));
|
||||
httpChannel->GetReferrerPolicy(&referrerPolicy);
|
||||
|
||||
|
@ -11749,6 +11776,8 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
|
|||
owner, // Channel or provided owner
|
||||
mHistoryID,
|
||||
mDynamicallyCreated);
|
||||
|
||||
entry->SetOriginalURI(originalURI);
|
||||
entry->SetReferrerURI(referrerURI);
|
||||
entry->SetReferrerPolicy(referrerPolicy);
|
||||
nsCOMPtr<nsIInputStreamChannel> inStrmChan = do_QueryInterface(aChannel);
|
||||
|
@ -11849,6 +11878,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
nsCOMPtr<nsIInputStream> postData;
|
||||
nsCOMPtr<nsIURI> referrerURI;
|
||||
uint32_t referrerPolicy;
|
||||
|
@ -11858,6 +11888,8 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
|
|||
NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(aEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(aEntry->GetOriginalURI(getter_AddRefs(originalURI)),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(aEntry->GetReferrerPolicy(&referrerPolicy),
|
||||
|
@ -11938,6 +11970,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
|
|||
// the source browsing context that was used when the history entry was
|
||||
// first created. bug 947716 has been created to address this issue.
|
||||
rv = InternalLoad(uri,
|
||||
originalURI,
|
||||
referrerURI,
|
||||
referrerPolicy,
|
||||
owner,
|
||||
|
@ -13396,6 +13429,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
|
|||
}
|
||||
|
||||
nsresult rv = InternalLoad(clonedURI, // New URI
|
||||
nullptr, // Original URI
|
||||
referer, // Referer URI
|
||||
refererPolicy, // Referer policy
|
||||
aContent->NodePrincipal(), // Owner is our node's
|
||||
|
|
|
@ -341,7 +341,10 @@ protected:
|
|||
// not have an owner on the channel should just pass null.
|
||||
// If aSrcdoc is not void, the load will be considered as a srcdoc load,
|
||||
// and the contents of aSrcdoc will be loaded instead of aURI.
|
||||
// aOriginalURI will be set as the originalURI on the channel that does the
|
||||
// load. If aOriginalURI is null, aURI will be set as the originalURI.
|
||||
nsresult DoURILoad(nsIURI* aURI,
|
||||
nsIURI* aOriginalURI,
|
||||
nsIURI* aReferrer,
|
||||
bool aSendReferrer,
|
||||
uint32_t aReferrerPolicy,
|
||||
|
|
|
@ -50,6 +50,23 @@ nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetOriginalURI(nsIURI** aOriginalURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOriginalURI);
|
||||
|
||||
*aOriginalURI = mOriginalURI;
|
||||
NS_IF_ADDREF(*aOriginalURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetOriginalURI(nsIURI* aOriginalURI)
|
||||
{
|
||||
mOriginalURI = aOriginalURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ protected:
|
|||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mReferrer;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
bool mInheritOwner;
|
||||
bool mOwnerIsExplicit;
|
||||
|
|
|
@ -46,7 +46,7 @@ interface nsITabParent;
|
|||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(e534b6ee-c35d-4ee2-acce-1bcd08a91230)]
|
||||
[scriptable, builtinclass, uuid(df834cfd-5073-4053-96e4-4e5a4e508696)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
|
@ -123,6 +123,9 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* of an nsIDocShellLoadInfo object...
|
||||
*
|
||||
* @param aURI - The URI to load.
|
||||
* @param aOriginalURI - The URI to set as the originalURI on the channel
|
||||
* that does the load. If null, aURI will be set as
|
||||
* the originalURI.
|
||||
* @param aReferrer - Referring URI
|
||||
* @param aReferrerPolicy - Referrer policy
|
||||
* @param aOwner - Owner (security principal)
|
||||
|
@ -149,6 +152,7 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* in certain situations such as view-source.
|
||||
*/
|
||||
[noscript]void internalLoad(in nsIURI aURI,
|
||||
in nsIURI aOriginalURI,
|
||||
in nsIURI aReferrer,
|
||||
in unsigned long aReferrerPolicy,
|
||||
in nsISupports aOwner,
|
||||
|
|
|
@ -19,12 +19,17 @@ interface nsIDocShell;
|
|||
typedef long nsDocShellInfoLoadType;
|
||||
typedef unsigned long nsDocShellInfoReferrerPolicy;
|
||||
|
||||
[scriptable, uuid(c63e9d64-490d-48bf-8013-b5d8ee4dbc25)]
|
||||
[scriptable, uuid(9d3bc466-5efe-414d-ae8b-3830b45877bb)]
|
||||
interface nsIDocShellLoadInfo : nsISupports
|
||||
{
|
||||
/** This is the referrer for the load. */
|
||||
attribute nsIURI referrer;
|
||||
|
||||
/**
|
||||
* The originalURI to be passed to nsIDocShell.internalLoad. May be null.
|
||||
*/
|
||||
attribute nsIURI originalURI;
|
||||
|
||||
/** The owner of the load, that is, the entity responsible for
|
||||
* causing the load to occur. This should be a nsIPrincipal typically.
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,7 @@ class nsSHEntryShared;
|
|||
[ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData);
|
||||
[ptr] native nsSHEntryShared(nsSHEntryShared);
|
||||
|
||||
[scriptable, uuid(d5fbeb10-f373-4677-b69a-2694aa706cac)]
|
||||
[scriptable, uuid(e45ab6ef-3485-449c-b91c-0846b2bf6faf)]
|
||||
interface nsISHEntry : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -40,6 +40,13 @@ interface nsISHEntry : nsISupports
|
|||
*/
|
||||
readonly attribute nsIURI URI;
|
||||
|
||||
/**
|
||||
* A readonly property that returns the original URI of the current entry.
|
||||
* If an entry is the result of a redirect this attribute holds original
|
||||
* URI. The object returned is of type nsIURI
|
||||
*/
|
||||
attribute nsIURI originalURI;
|
||||
|
||||
/**
|
||||
* A readonly property that returns the title
|
||||
* of the current entry. The object returned
|
||||
|
|
|
@ -38,6 +38,7 @@ nsSHEntry::nsSHEntry()
|
|||
nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
|
||||
: mShared(aOther.mShared)
|
||||
, mURI(aOther.mURI)
|
||||
, mOriginalURI(aOther.mOriginalURI)
|
||||
, mReferrerURI(aOther.mReferrerURI)
|
||||
, mReferrerPolicy(aOther.mReferrerPolicy)
|
||||
, mTitle(aOther.mTitle)
|
||||
|
@ -117,6 +118,21 @@ nsSHEntry::SetURI(nsIURI* aURI)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetOriginalURI(nsIURI** aOriginalURI)
|
||||
{
|
||||
*aOriginalURI = mOriginalURI;
|
||||
NS_IF_ADDREF(*aOriginalURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::SetOriginalURI(nsIURI* aOriginalURI)
|
||||
{
|
||||
mOriginalURI = aOriginalURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetReferrerURI(nsIURI** aReferrerURI)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
|
||||
// See nsSHEntry.idl for comments on these members.
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mReferrerURI;
|
||||
uint32_t mReferrerPolicy;
|
||||
nsString mTitle;
|
||||
|
|
|
@ -1771,6 +1771,10 @@ nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
|
|||
loadInfo->SetLoadType(aLoadType);
|
||||
loadInfo->SetSHEntry(aFrameEntry);
|
||||
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
aFrameEntry->GetOriginalURI(getter_AddRefs(originalURI));
|
||||
loadInfo->SetOriginalURI(originalURI);
|
||||
|
||||
nsCOMPtr<nsIURI> nextURI;
|
||||
aFrameEntry->GetURI(getter_AddRefs(nextURI));
|
||||
// Time to initiate a document load
|
||||
|
|
Загрузка…
Ссылка в новой задаче