зеркало из https://github.com/mozilla/pjs.git
Merge e10s -> m-c. a=patches
This commit is contained in:
Коммит
16a3298070
|
@ -6718,14 +6718,11 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIMultiPartChannel> partChannel = do_QueryInterface(aChannel);
|
||||
if (partChannel) {
|
||||
nsCAutoString contentDisp;
|
||||
rv = partChannel->GetContentDisposition(contentDisp);
|
||||
if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) {
|
||||
SetHeaderData(nsGkAtoms::headerContentDisposition,
|
||||
NS_ConvertASCIItoUTF16(contentDisp));
|
||||
}
|
||||
nsCAutoString contentDisp;
|
||||
rv = aChannel->GetContentDisposition(contentDisp);
|
||||
if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) {
|
||||
SetHeaderData(nsGkAtoms::headerContentDisposition,
|
||||
NS_ConvertASCIItoUTF16(contentDisp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2407,6 +2407,7 @@ NOT_IMPLEMENTED_IF_FUNC_1(GetContentType, nsACString &value)
|
|||
NOT_IMPLEMENTED_IF_FUNC_1(SetContentType, const nsACString &value)
|
||||
NOT_IMPLEMENTED_IF_FUNC_1(GetContentCharset, nsACString &value)
|
||||
NOT_IMPLEMENTED_IF_FUNC_1(SetContentCharset, const nsACString &value)
|
||||
NOT_IMPLEMENTED_IF_FUNC_1(GetContentDisposition, nsACString &value)
|
||||
NOT_IMPLEMENTED_IF_FUNC_1(GetContentLength, PRInt64 *value)
|
||||
NOT_IMPLEMENTED_IF_FUNC_1(SetContentLength, PRInt64 value)
|
||||
NOT_IMPLEMENTED_IF_FUNC_1(Open, nsIInputStream **_retval)
|
||||
|
|
|
@ -264,6 +264,13 @@ nsWyciwygChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWyciwygChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWyciwygChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
|
|
|
@ -121,7 +121,9 @@ parent:
|
|||
|
||||
__delete__();
|
||||
|
||||
PExternalHelperApp(URI uri, nsCString aMimeContentType, bool aForceSave, PRInt64 aContentLength);
|
||||
PExternalHelperApp(URI uri, nsCString aMimeContentType,
|
||||
nsCString aContentDisposition, bool aForceSave,
|
||||
PRInt64 aContentLength);
|
||||
|
||||
child:
|
||||
CreateWidget(MagicWindowHandle parentWidget);
|
||||
|
|
|
@ -1252,6 +1252,7 @@ TabChildGlobal::GetPrincipal()
|
|||
PExternalHelperAppChild*
|
||||
TabChild::AllocPExternalHelperApp(const IPC::URI& uri,
|
||||
const nsCString& aMimeContentType,
|
||||
const nsCString& aContentDisposition,
|
||||
const bool& aForceSave,
|
||||
const PRInt64& aContentLength)
|
||||
{
|
||||
|
|
|
@ -227,6 +227,7 @@ public:
|
|||
virtual PExternalHelperAppChild *AllocPExternalHelperApp(
|
||||
const IPC::URI& uri,
|
||||
const nsCString& aMimeContentType,
|
||||
const nsCString& aContentDisposition,
|
||||
const bool& aForceSave,
|
||||
const PRInt64& aContentLength);
|
||||
virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService);
|
||||
|
|
|
@ -811,12 +811,13 @@ TabParent::GetFrameLoader() const
|
|||
PExternalHelperAppParent*
|
||||
TabParent::AllocPExternalHelperApp(const IPC::URI& uri,
|
||||
const nsCString& aMimeContentType,
|
||||
const nsCString& aContentDisposition,
|
||||
const bool& aForceSave,
|
||||
const PRInt64& aContentLength)
|
||||
{
|
||||
ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
|
||||
parent->AddRef();
|
||||
parent->Init(this, aMimeContentType, aForceSave);
|
||||
parent->Init(this, aMimeContentType, aContentDisposition, aForceSave);
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ public:
|
|||
virtual PExternalHelperAppParent* AllocPExternalHelperApp(
|
||||
const IPC::URI& uri,
|
||||
const nsCString& aMimeContentType,
|
||||
const nsCString& aContentDisposition,
|
||||
const bool& aForceSave,
|
||||
const PRInt64& aContentLength);
|
||||
virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);
|
||||
|
|
|
@ -1011,6 +1011,12 @@ nsJSChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return mStreamChannel->SetContentCharset(aContentCharset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
return mStreamChannel->GetContentDisposition(aContentDisposition);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
|
|
|
@ -631,6 +631,13 @@ nsJARChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetContentDisposition(nsACString &result)
|
||||
{
|
||||
result = mContentDisposition;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetContentLength(PRInt64 *result)
|
||||
{
|
||||
|
@ -771,7 +778,6 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
|
|||
}
|
||||
|
||||
if (NS_SUCCEEDED(status) && channel) {
|
||||
nsCAutoString header;
|
||||
// Grab the security info from our base channel
|
||||
channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
|
||||
|
||||
|
@ -780,6 +786,7 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
|
|||
// We only want to run scripts if the server really intended to
|
||||
// send us a JAR file. Check the server-supplied content type for
|
||||
// a JAR type.
|
||||
nsCAutoString header;
|
||||
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"),
|
||||
header);
|
||||
nsCAutoString contentType;
|
||||
|
@ -790,10 +797,6 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
|
|||
mIsUnsafe = !(contentType.Equals(channelContentType) &&
|
||||
(contentType.EqualsLiteral("application/java-archive") ||
|
||||
contentType.EqualsLiteral("application/x-jar")));
|
||||
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Disposition"),
|
||||
header);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
SetPropertyAsACString(NS_CHANNEL_PROP_CONTENT_DISPOSITION, header);
|
||||
} else {
|
||||
nsCOMPtr<nsIJARChannel> innerJARChannel(do_QueryInterface(channel));
|
||||
if (innerJARChannel) {
|
||||
|
@ -801,11 +804,9 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
|
|||
innerJARChannel->GetIsUnsafe(&unsafe);
|
||||
mIsUnsafe = unsafe;
|
||||
}
|
||||
// Soon-to-be common way to get Disposition: right now only nsIJARChannel
|
||||
rv = NS_GetContentDisposition(request, header);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
SetPropertyAsACString(NS_CHANNEL_PROP_CONTENT_DISPOSITION, header);
|
||||
}
|
||||
|
||||
channel->GetContentDisposition(mContentDisposition);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(status) && mIsUnsafe) {
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
nsCOMPtr<nsISupports> mListenerContext;
|
||||
nsCString mContentType;
|
||||
nsCString mContentCharset;
|
||||
nsCString mContentDisposition;
|
||||
PRInt64 mContentLength;
|
||||
PRUint32 mLoadFlags;
|
||||
nsresult mStatus;
|
||||
|
|
|
@ -407,6 +407,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
|
|
|
@ -399,6 +399,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
|
|
|
@ -636,6 +636,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
|
|
|
@ -693,6 +693,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
*aContentLength = mContentLength;
|
||||
|
|
|
@ -973,11 +973,10 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
|
|||
/* NS_WARNING if the content type from the channel isn't the same if the sniffing */
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
|
||||
if (mContentType.IsEmpty()) {
|
||||
LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |sniffing of mimetype failed|");
|
||||
|
||||
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
|
||||
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (chan) {
|
||||
rv = chan->GetContentType(mContentType);
|
||||
|
@ -1017,14 +1016,8 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
|
|||
|
||||
/* set our content disposition as a property */
|
||||
nsCAutoString disposition;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
|
||||
if (httpChannel) {
|
||||
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), disposition);
|
||||
} else {
|
||||
nsCOMPtr<nsIMultiPartChannel> multiPartChannel(do_QueryInterface(aRequest));
|
||||
if (multiPartChannel) {
|
||||
multiPartChannel->GetContentDisposition(disposition);
|
||||
}
|
||||
if (chan) {
|
||||
chan->GetContentDisposition(disposition);
|
||||
}
|
||||
if (!disposition.IsEmpty()) {
|
||||
nsCOMPtr<nsISupportsCString> contentDisposition(do_CreateInstance("@mozilla.org/supports-cstring;1"));
|
||||
|
@ -1084,6 +1077,7 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
|
|||
|
||||
if (imageType == imgIContainer::TYPE_RASTER) {
|
||||
/* Use content-length as a size hint for http channels. */
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
|
||||
if (httpChannel) {
|
||||
PRInt64 contentLength;
|
||||
rv = httpChannel->GetContentLength(&contentLength);
|
||||
|
|
|
@ -50,13 +50,6 @@
|
|||
*/
|
||||
|
||||
|
||||
/**
|
||||
* MIME Content-Disposition header of channel.
|
||||
* Not available before onStartRequest.
|
||||
* Type: nsACString
|
||||
*/
|
||||
#define NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR "content-disposition"
|
||||
|
||||
/**
|
||||
* Exists to allow content policy mechanism to function properly during channel
|
||||
* redirects. Contains security contextual information about the load.
|
||||
|
@ -65,11 +58,8 @@
|
|||
#define NS_CHANNEL_PROP_CHANNEL_POLICY_STR "channel-policy"
|
||||
|
||||
#ifdef IMPL_NS_NET
|
||||
#define NS_CHANNEL_PROP_CONTENT_DISPOSITION gNetStrings->kContentDisposition
|
||||
#define NS_CHANNEL_PROP_CHANNEL_POLICY gNetStrings->kChannelPolicy
|
||||
#else
|
||||
#define NS_CHANNEL_PROP_CONTENT_DISPOSITION \
|
||||
NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR)
|
||||
#define NS_CHANNEL_PROP_CHANNEL_POLICY \
|
||||
NS_LITERAL_STRING(NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
|
||||
#endif
|
||||
|
|
|
@ -56,7 +56,7 @@ interface nsIStreamListener;
|
|||
*
|
||||
* This interface must be used only from the XPCOM main thread.
|
||||
*/
|
||||
[scriptable, uuid(e0bb5c49-c54e-4efb-8f0d-6a7edd926fab)]
|
||||
[scriptable, uuid(3906f857-3d79-4716-be55-ed2455d666f4)]
|
||||
interface nsIChannel : nsIRequest
|
||||
{
|
||||
/**
|
||||
|
@ -157,6 +157,13 @@ interface nsIChannel : nsIRequest
|
|||
*/
|
||||
attribute PRInt64 contentLength;
|
||||
|
||||
/**
|
||||
* Access to the Content-Disposition header if available and if applicable.
|
||||
* This allows getting the preferred handling method, preferred filename,
|
||||
* etc. See RFC 2183.
|
||||
*/
|
||||
readonly attribute ACString contentDisposition;
|
||||
|
||||
/**
|
||||
* Synchronously open the channel.
|
||||
*
|
||||
|
|
|
@ -45,7 +45,7 @@ interface nsIChannel;
|
|||
* associated with a MultiPartChannel.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(ba78db7b-b88c-4b76-baf9-3c2296a585ae)]
|
||||
[scriptable, uuid(51698f28-c975-4bce-a951-25130cda0113)]
|
||||
interface nsIMultiPartChannel : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -53,13 +53,6 @@ interface nsIMultiPartChannel : nsISupports
|
|||
*/
|
||||
readonly attribute nsIChannel baseChannel;
|
||||
|
||||
/**
|
||||
* Access to the Content-Disposition header field of this part of
|
||||
* a multipart message. This allows getting the preferred
|
||||
* handling method, preferred filename, etc. See RFC 2183.
|
||||
*/
|
||||
attribute ACString contentDisposition;
|
||||
|
||||
/**
|
||||
* Attribute guaranteed to be different for different parts of
|
||||
* the same multipart document.
|
||||
|
|
|
@ -47,7 +47,6 @@ class nsNetStrings {
|
|||
public:
|
||||
nsNetStrings();
|
||||
|
||||
const nsLiteralString kContentDisposition;
|
||||
const nsLiteralString kChannelPolicy;
|
||||
};
|
||||
|
||||
|
|
|
@ -238,19 +238,6 @@ NS_NewChannel(nsIChannel **result,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// For now, works only with JARChannel. Future: with all channels that may
|
||||
// have Content-Disposition header (JAR, nsIHttpChannel, and nsIMultiPartChannel).
|
||||
inline nsresult
|
||||
NS_GetContentDisposition(nsIRequest *channel,
|
||||
nsACString &result)
|
||||
{
|
||||
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(channel));
|
||||
if (props)
|
||||
return props->GetPropertyAsACString(NS_CHANNEL_PROP_CONTENT_DISPOSITION,
|
||||
result);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Use this function with CAUTION. It creates a stream that blocks when you
|
||||
// Read() from it and blocking the UI thread is a bad idea. If you don't want
|
||||
// to implement a full blown asynchronous consumer (via nsIStreamListener) look
|
||||
|
|
|
@ -503,6 +503,13 @@ nsBaseChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition = mContentDisposition;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
|
|
|
@ -290,6 +290,7 @@ private:
|
|||
nsCOMPtr<nsIChannel> mRedirectChannel;
|
||||
nsCString mContentType;
|
||||
nsCString mContentCharset;
|
||||
nsCString mContentDisposition;
|
||||
PRInt64 mContentLength;
|
||||
PRUint32 mLoadFlags;
|
||||
nsresult mStatus;
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
NS_HIDDEN_(nsNetStrings*) gNetStrings;
|
||||
|
||||
nsNetStrings::nsNetStrings()
|
||||
: NS_LITERAL_STRING_INIT(kContentDisposition, NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR),
|
||||
NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
|
||||
: NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
|
||||
{}
|
||||
|
||||
|
||||
|
|
|
@ -358,6 +358,18 @@ HttpBaseChannel::SetContentCharset(const nsACString& aContentCharset)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetContentDisposition(nsACString& aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
|
||||
if (!mResponseHead)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
mResponseHead->GetHeader(nsHttp::Content_Disposition, aContentDisposition);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
|
|
|
@ -129,6 +129,7 @@ public:
|
|||
NS_IMETHOD SetContentType(const nsACString& aContentType);
|
||||
NS_IMETHOD GetContentCharset(nsACString& aContentCharset);
|
||||
NS_IMETHOD SetContentCharset(const nsACString& aContentCharset);
|
||||
NS_IMETHOD GetContentDisposition(nsACString& aContentDisposition);
|
||||
NS_IMETHOD GetContentLength(PRInt64 *aContentLength);
|
||||
NS_IMETHOD SetContentLength(PRInt64 aContentLength);
|
||||
NS_IMETHOD Open(nsIInputStream **aResult);
|
||||
|
|
|
@ -369,6 +369,14 @@ nsViewSourceChannel::SetContentCharset(const nsACString &aContentCharset)
|
|||
return mChannel->SetContentCharset(aContentCharset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);
|
||||
|
||||
return mChannel->GetContentDisposition(aContentDisposition);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
|
|
|
@ -344,13 +344,6 @@ nsPartChannel::GetContentDisposition(nsACString &aContentDisposition)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPartChannel::SetContentDisposition(const nsACString &aContentDisposition)
|
||||
{
|
||||
mContentDisposition = aContentDisposition;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPartChannel::GetPartID(PRUint32 *aPartID)
|
||||
{
|
||||
|
@ -800,8 +793,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
|
|||
rv = mPartChannel->SetContentLength(mContentLength);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mPartChannel->SetContentDisposition(mContentDisposition);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mPartChannel->SetContentDisposition(mContentDisposition);
|
||||
|
||||
nsLoadFlags loadFlags = 0;
|
||||
mPartChannel->GetLoadFlags(&loadFlags);
|
||||
|
|
|
@ -77,6 +77,11 @@ public:
|
|||
PRUint32 aOffset, PRUint32 aLen);
|
||||
nsresult SendOnStopRequest(nsISupports* aContext, nsresult aStatus);
|
||||
|
||||
void SetContentDisposition(const nsACString& aDisposition)
|
||||
{
|
||||
mContentDisposition = aDisposition;
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIPropertyBag.idl"
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIInputStream;
|
||||
interface nsILocalFile;
|
||||
|
@ -391,8 +391,8 @@ interface nsIHttpRequestHandler : nsISupports
|
|||
/**
|
||||
* A representation of the data included in an HTTP request.
|
||||
*/
|
||||
[scriptable, uuid(80cbca71-dc51-4fa0-9010-1cec262dbd4a)]
|
||||
interface nsIHttpRequest : nsIPropertyBag
|
||||
[scriptable, uuid(978cf30e-ad73-42ee-8f22-fe0aaf1bf5d2)]
|
||||
interface nsIHttpRequest : nsISupports
|
||||
{
|
||||
/**
|
||||
* The request type for this request (see RFC 2616, section 5.1.1).
|
||||
|
|
|
@ -386,26 +386,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
|||
// future, because the user has specified external handling for the MIME
|
||||
// type.
|
||||
PRBool forceExternalHandling = PR_FALSE;
|
||||
nsCAutoString disposition;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (httpChannel)
|
||||
{
|
||||
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"),
|
||||
disposition);
|
||||
httpChannel->GetURI(getter_AddRefs(uri));
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIMultiPartChannel> multipartChannel(do_QueryInterface(request));
|
||||
if (multipartChannel)
|
||||
{
|
||||
rv = multipartChannel->GetContentDisposition(disposition);
|
||||
} else {
|
||||
// Soon-to-be common way to get Disposition: right now only JARChannel
|
||||
rv = NS_GetContentDisposition(request, disposition);
|
||||
}
|
||||
}
|
||||
nsCAutoString disposition;
|
||||
rv = aChannel->GetContentDisposition(disposition);
|
||||
|
||||
LOG((" Disposition header: '%s'", disposition.get()));
|
||||
|
||||
|
@ -415,6 +398,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
|
|||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCAutoString fallbackCharset;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (httpChannel)
|
||||
httpChannel->GetURI(getter_AddRefs(uri));
|
||||
if (uri)
|
||||
uri->GetOriginCharset(fallbackCharset);
|
||||
nsAutoString dispToken;
|
||||
|
|
|
@ -69,6 +69,7 @@ ExternalHelperAppParent::ExternalHelperAppParent(
|
|||
void
|
||||
ExternalHelperAppParent::Init(TabParent *parent,
|
||||
const nsCString& aMimeContentType,
|
||||
const nsCString& aContentDisposition,
|
||||
const PRBool& aForceSave)
|
||||
{
|
||||
nsHashPropertyBag::Init();
|
||||
|
@ -82,6 +83,7 @@ ExternalHelperAppParent::Init(TabParent *parent,
|
|||
do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(helperAppService, "No Helper App Service!");
|
||||
|
||||
mContentDisposition = aContentDisposition;
|
||||
helperAppService->DoContent(aMimeContentType, this, ir,
|
||||
aForceSave, getter_AddRefs(mListener));
|
||||
}
|
||||
|
@ -295,6 +297,13 @@ ExternalHelperAppParent::SetContentCharset(const nsACString& aContentCharset)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ExternalHelperAppParent::GetContentDisposition(nsACString& aContentDisposition)
|
||||
{
|
||||
aContentDisposition = mContentDisposition;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength)
|
||||
{
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
ExternalHelperAppParent(const IPC::URI& uri, const PRInt64& contentLength);
|
||||
void Init(TabParent *parent,
|
||||
const nsCString& aMimeContentType,
|
||||
const nsCString& aContentDisposition,
|
||||
const PRBool& aForceSave);
|
||||
virtual ~ExternalHelperAppParent();
|
||||
|
||||
|
@ -79,6 +80,7 @@ private:
|
|||
nsLoadFlags mLoadFlags;
|
||||
nsresult mStatus;
|
||||
PRInt64 mContentLength;
|
||||
nsCString mContentDisposition;
|
||||
nsCString mEntityID;
|
||||
};
|
||||
|
||||
|
|
|
@ -222,31 +222,6 @@ static nsresult UnescapeFragment(const nsACString& aFragment, nsIURI* aURI,
|
|||
return rv;
|
||||
}
|
||||
|
||||
/** Gets the content-disposition header from a channel, using nsIHttpChannel
|
||||
* or nsIMultipartChannel if available
|
||||
* @param aChannel The channel to extract the disposition header from
|
||||
* @param aDisposition Reference to a string where the header is to be stored
|
||||
*/
|
||||
static void ExtractDisposition(nsIChannel* aChannel, nsACString& aDisposition)
|
||||
{
|
||||
aDisposition.Truncate();
|
||||
// First see whether this is an http channel
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
|
||||
if (httpChannel)
|
||||
{
|
||||
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), aDisposition);
|
||||
}
|
||||
if (aDisposition.IsEmpty())
|
||||
{
|
||||
nsCOMPtr<nsIMultiPartChannel> multipartChannel(do_QueryInterface(aChannel));
|
||||
if (multipartChannel)
|
||||
{
|
||||
multipartChannel->GetContentDisposition(aDisposition);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Extracts the filename out of a content-disposition header
|
||||
* @param aFilename [out] The filename. Can be empty on error.
|
||||
* @param aDisposition Value of a Content-Disposition header
|
||||
|
@ -314,7 +289,7 @@ static PRBool GetFilenameAndExtensionFromChannel(nsIChannel* aChannel,
|
|||
* permission... otherwise just use our temp file
|
||||
*/
|
||||
nsCAutoString disp;
|
||||
ExtractDisposition(aChannel, disp);
|
||||
aChannel->GetContentDisposition(disp);
|
||||
PRBool handleExternally = PR_FALSE;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv;
|
||||
|
@ -678,8 +653,12 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt64 contentLength = -1;
|
||||
if (channel)
|
||||
nsCString disp;
|
||||
if (channel) {
|
||||
channel->GetContentLength(&contentLength);
|
||||
channel->GetContentDisposition(disp);
|
||||
}
|
||||
|
||||
|
||||
// Now we build a protocol for forwarding our data to the parent. The
|
||||
// protocol will act as a listener on the child-side and create a "real"
|
||||
|
@ -690,7 +669,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
|
|||
TabChild *child = static_cast<TabChild*>(tabchild.get());
|
||||
mozilla::dom::PExternalHelperAppChild *pc;
|
||||
pc = child->SendPExternalHelperAppConstructor(IPC::URI(uri),
|
||||
nsCString(aMimeContentType),
|
||||
nsCString(aMimeContentType), disp,
|
||||
aForceSave, contentLength);
|
||||
ExternalHelperAppChild *childListener = static_cast<ExternalHelperAppChild *>(pc);
|
||||
|
||||
|
|
|
@ -247,6 +247,12 @@ NS_IMETHODIMP nsExtProtocolChannel::SetContentCharset(const nsACString &aContent
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::GetContentDisposition(nsACString &aContentDisposition)
|
||||
{
|
||||
aContentDisposition.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::GetContentLength(PRInt64 * aContentLength)
|
||||
{
|
||||
*aContentLength = -1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче