зеркало из https://github.com/mozilla/gecko-dev.git
Bug 971432 - Move baseURI to nsILoadInfo. r=bz
This commit is contained in:
Родитель
4dad620994
Коммит
a7839118a6
|
@ -17,11 +17,13 @@ namespace mozilla {
|
|||
LoadInfo::LoadInfo(nsIPrincipal* aPrincipal,
|
||||
nsINode* aLoadingContext,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType)
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
nsIURI* aBaseURI)
|
||||
: mPrincipal(aPrincipal)
|
||||
, mLoadingContext(do_GetWeakReference(aLoadingContext))
|
||||
, mSecurityFlags(aSecurityFlags)
|
||||
, mContentPolicyType(aContentPolicyType)
|
||||
, mBaseURI(aBaseURI)
|
||||
{
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
// if the load is sandboxed, we can not also inherit the principal
|
||||
|
@ -95,4 +97,12 @@ LoadInfo::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetBaseURI(nsIURI** aBaseURI)
|
||||
{
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsILoadInfo.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIWeakReferenceUtils.h" // for nsWeakPtr
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsINode;
|
||||
|
||||
|
@ -29,7 +30,8 @@ public:
|
|||
LoadInfo(nsIPrincipal* aPrincipal,
|
||||
nsINode* aLoadingContext,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType);
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
nsIURI* aBaseURI = nullptr);
|
||||
|
||||
private:
|
||||
~LoadInfo();
|
||||
|
@ -38,6 +40,7 @@ private:
|
|||
nsWeakPtr mLoadingContext;
|
||||
nsSecurityFlags mSecurityFlags;
|
||||
nsContentPolicyType mContentPolicyType;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -10268,12 +10268,15 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
}
|
||||
|
||||
if (!isSrcdoc) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(requestingPrincipal,
|
||||
requestingNode,
|
||||
securityFlags,
|
||||
aContentPolicyType,
|
||||
aBaseURI);
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(channel),
|
||||
aURI,
|
||||
requestingNode,
|
||||
requestingPrincipal,
|
||||
securityFlags,
|
||||
aContentPolicyType,
|
||||
loadInfo,
|
||||
nullptr, // loadGroup
|
||||
static_cast<nsIInterfaceRequestor*>(this),
|
||||
loadFlags);
|
||||
|
@ -10293,12 +10296,6 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
if (aBaseURI) {
|
||||
nsCOMPtr<nsIViewSourceChannel> vsc = do_QueryInterface(channel);
|
||||
if (vsc) {
|
||||
vsc->SetBaseURI(aBaseURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsAutoCString scheme;
|
||||
|
@ -10311,14 +10308,14 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
nsViewSourceHandler *vsh = nsViewSourceHandler::GetInstance();
|
||||
NS_ENSURE_TRUE(vsh,NS_ERROR_FAILURE);
|
||||
|
||||
rv = vsh->NewSrcdocChannel(aURI, aSrcdoc, aBaseURI,
|
||||
getter_AddRefs(channel));
|
||||
rv = vsh->NewSrcdocChannel(aURI, aSrcdoc, getter_AddRefs(channel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(requestingPrincipal,
|
||||
requestingNode,
|
||||
securityFlags,
|
||||
aContentPolicyType);
|
||||
aContentPolicyType,
|
||||
aBaseURI);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
}
|
||||
else {
|
||||
|
@ -10330,11 +10327,9 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
requestingPrincipal,
|
||||
securityFlags,
|
||||
aContentPolicyType,
|
||||
true);
|
||||
true,
|
||||
aBaseURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(channel);
|
||||
MOZ_ASSERT(isc);
|
||||
isc->SetBaseURI(aBaseURI);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11590,8 +11585,10 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
|
|||
nsAutoString srcdoc;
|
||||
inStrmChan->GetSrcdocData(srcdoc);
|
||||
entry->SetSrcdocData(srcdoc);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
inStrmChan->GetBaseURI(getter_AddRefs(baseURI));
|
||||
loadInfo->GetBaseURI(getter_AddRefs(baseURI));
|
||||
entry->SetBaseURI(baseURI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,14 @@
|
|||
interface nsIDOMDocument;
|
||||
interface nsINode;
|
||||
interface nsIPrincipal;
|
||||
interface nsIURI;
|
||||
|
||||
typedef unsigned long nsSecurityFlags;
|
||||
|
||||
/**
|
||||
* An nsILoadOwner represents per-load information about who started the load.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(046db047-a1c1-4519-8ec7-99f3054bc9ac)]
|
||||
[scriptable, builtinclass, uuid(b22b8ee7-047a-4351-a749-13c6d39f6b17)]
|
||||
interface nsILoadInfo : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -148,4 +149,10 @@ interface nsILoadInfo : nsISupports
|
|||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* A base URI for use in situations where it cannot otherwise be inferred.
|
||||
* This attribute may be null. The value of this attribute may be
|
||||
* ignored if the base URI can be inferred by the channel's URI.
|
||||
*/
|
||||
readonly attribute nsIURI baseURI;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ interface nsIURI;
|
|||
* This interface provides methods to initialize an input stream channel.
|
||||
* The input stream channel serves as a data pump for an input stream.
|
||||
*/
|
||||
[scriptable, uuid(17a17ce4-9a07-43fb-a0a3-947a6e21476c)]
|
||||
[scriptable, uuid(e1e95852-914b-4d83-b574-23f114db9b89)]
|
||||
interface nsIInputStreamChannel : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -55,10 +55,4 @@ interface nsIInputStreamChannel : nsISupports
|
|||
* Returns true if srcdocData has been set within the channel.
|
||||
*/
|
||||
readonly attribute boolean isSrcdocChannel;
|
||||
|
||||
/**
|
||||
* The base URI to be used for the channel. Used when the base URI cannot
|
||||
* be inferred by other means, for example when this is a srcdoc channel.
|
||||
*/
|
||||
attribute nsIURI baseURI;
|
||||
};
|
||||
|
|
|
@ -605,7 +605,8 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
|
|||
nsINode* aRequestingNode,
|
||||
nsIPrincipal* aRequestingPrincipal,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType)
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
nsIURI* aBaseURI = nullptr)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStreamChannel> isc =
|
||||
|
@ -633,7 +634,8 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
|
|||
new mozilla::LoadInfo(aRequestingPrincipal,
|
||||
aRequestingNode,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType);
|
||||
aContentPolicyType,
|
||||
aBaseURI);
|
||||
if (!loadInfo) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -679,7 +681,8 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
|
|||
nsIPrincipal* aRequestingPrincipal,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
bool aIsSrcdocChannel = false)
|
||||
bool aIsSrcdocChannel = false,
|
||||
nsIURI* aBaseURI = nullptr)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIStringInputStream> stream;
|
||||
|
@ -704,7 +707,8 @@ NS_NewInputStreamChannelInternal(nsIChannel** outChannel,
|
|||
aRequestingNode,
|
||||
aRequestingPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType);
|
||||
aContentPolicyType,
|
||||
aBaseURI);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -725,7 +729,8 @@ NS_NewInputStreamChannel(nsIChannel** outChannel,
|
|||
nsIPrincipal* aRequestingPrincipal,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
bool aIsSrcdocChannel = false)
|
||||
bool aIsSrcdocChannel = false,
|
||||
nsIURI* aBaseURI = nullptr)
|
||||
{
|
||||
return NS_NewInputStreamChannelInternal(outChannel,
|
||||
aUri,
|
||||
|
@ -735,7 +740,8 @@ NS_NewInputStreamChannel(nsIChannel** outChannel,
|
|||
aRequestingPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType,
|
||||
aIsSrcdocChannel);
|
||||
aIsSrcdocChannel,
|
||||
aBaseURI);
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
|
|
|
@ -89,18 +89,3 @@ nsInputStreamChannel::GetIsSrcdocChannel(bool *aIsSrcdocChannel)
|
|||
*aIsSrcdocChannel = mIsSrcdocChannel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetBaseURI(nsIURI** aBaseURI)
|
||||
{
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::SetBaseURI(nsIURI* aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ protected:
|
|||
|
||||
private:
|
||||
nsCOMPtr<nsIInputStream> mContentStream;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsString mSrcdocData;
|
||||
bool mIsSrcdocChannel;
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
[uuid(ac5bcfe9-fe54-4e9a-95fb-cd7aa558c5bc)]
|
||||
[uuid(72d9580a-b636-4392-b888-6c003c56f3d7)]
|
||||
interface nsIViewSourceChannel : nsIChannel
|
||||
{
|
||||
/**
|
||||
|
@ -24,15 +24,6 @@ interface nsIViewSourceChannel : nsIChannel
|
|||
* Whether the channel was created to view the source of a srcdoc document.
|
||||
*/
|
||||
readonly attribute boolean isSrcdocChannel;
|
||||
|
||||
/**
|
||||
* Set to indicate the base URI. If this channel is a srcdoc channel, it
|
||||
* returns the base URI provided by the embedded channel. It is used to
|
||||
* provide an indication of the base URI in circumstances where it isn't
|
||||
* otherwise recoverable. Returns null when it isn't set and isn't a
|
||||
* srcdoc channel.
|
||||
*/
|
||||
attribute nsIURI baseURI;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -72,8 +72,7 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsViewSourceChannel::InitSrcdoc(nsIURI* aURI, const nsAString &aSrcdoc,
|
||||
nsIURI* aBaseURI)
|
||||
nsViewSourceChannel::InitSrcdoc(nsIURI* aURI, const nsAString &aSrcdoc)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
|
@ -98,9 +97,6 @@ nsViewSourceChannel::InitSrcdoc(nsIURI* aURI, const nsAString &aSrcdoc,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mOriginalURI = aURI;
|
||||
mIsSrcdocChannel = true;
|
||||
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(mChannel);
|
||||
MOZ_ASSERT(isc);
|
||||
isc->SetBaseURI(aBaseURI);
|
||||
|
||||
mChannel->SetOriginalURI(mOriginalURI);
|
||||
mHttpChannel = do_QueryInterface(mChannel);
|
||||
|
@ -524,27 +520,6 @@ nsViewSourceChannel::GetIsSrcdocChannel(bool* aIsSrcdocChannel)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetBaseURI(nsIURI** aBaseURI)
|
||||
{
|
||||
if (mIsSrcdocChannel) {
|
||||
nsCOMPtr<nsIInputStreamChannel> isc = do_QueryInterface(mChannel);
|
||||
if (isc) {
|
||||
return isc->GetBaseURI(aBaseURI);
|
||||
}
|
||||
}
|
||||
*aBaseURI = mBaseURI;
|
||||
NS_IF_ADDREF(*aBaseURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::SetBaseURI(nsIURI* aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIRequestObserver methods
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
|
||||
|
|
|
@ -49,8 +49,7 @@ public:
|
|||
|
||||
nsresult Init(nsIURI* uri);
|
||||
|
||||
nsresult InitSrcdoc(nsIURI* aURI, const nsAString &aSrcdoc,
|
||||
nsIURI* aBaseURI);
|
||||
nsresult InitSrcdoc(nsIURI* aURI, const nsAString &aSrcdoc);
|
||||
|
||||
protected:
|
||||
~nsViewSourceChannel() {}
|
||||
|
@ -63,7 +62,6 @@ protected:
|
|||
nsCOMPtr<nsIUploadChannel> mUploadChannel;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCString mContentType;
|
||||
bool mIsDocument; // keeps track of the LOAD_DOCUMENT_URI flag
|
||||
bool mOpened;
|
||||
|
|
|
@ -118,7 +118,7 @@ nsViewSourceHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
|||
|
||||
nsresult
|
||||
nsViewSourceHandler::NewSrcdocChannel(nsIURI* uri, const nsAString &srcdoc,
|
||||
nsIURI* baseURI, nsIChannel* *result)
|
||||
nsIChannel* *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(uri);
|
||||
nsViewSourceChannel *channel = new nsViewSourceChannel();
|
||||
|
@ -126,7 +126,7 @@ nsViewSourceHandler::NewSrcdocChannel(nsIURI* uri, const nsAString &srcdoc,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(channel);
|
||||
|
||||
nsresult rv = channel->InitSrcdoc(uri, srcdoc, baseURI);
|
||||
nsresult rv = channel->InitSrcdoc(uri, srcdoc);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
// Creates a new nsViewSourceChannel to view the source of an about:srcdoc
|
||||
// URI with contents specified by srcdoc.
|
||||
nsresult NewSrcdocChannel(nsIURI* uri, const nsAString &srcdoc,
|
||||
nsIURI* baseURI, nsIChannel** result);
|
||||
nsIChannel** result);
|
||||
|
||||
static nsViewSourceHandler* GetInstance();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче