bug 247607 http-index-format -> html conversion should be done by the necko caller, not by the channels
r+sr=darin git-svn-id: svn://10.0.0.236/trunk@158494 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -109,7 +109,6 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIHistoryEntry.h"
|
||||
#include "nsISHistoryListener.h"
|
||||
#include "nsIDirectoryListing.h"
|
||||
|
||||
// Pull in various NS_ERROR_* definitions
|
||||
#include "nsIDNSService.h"
|
||||
@@ -5646,11 +5645,6 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
||||
if (aReferrerURI) // Referrer is currenly only set for link clicks here.
|
||||
httpChannel->SetReferrer(aReferrerURI);
|
||||
}
|
||||
// We want to use the pref for directory listings
|
||||
nsCOMPtr<nsIDirectoryListing> dirList = do_QueryInterface(channel);
|
||||
if (dirList) {
|
||||
(void)dirList->SetListFormat(nsIDirectoryListing::FORMAT_PREF);
|
||||
}
|
||||
//
|
||||
// Set the owner of the channel - only for javascript and data channels.
|
||||
//
|
||||
|
||||
@@ -63,7 +63,6 @@ XPIDLSRCS = \
|
||||
nsIAuthPrompt.idl \
|
||||
nsIAsyncStreamCopier.idl \
|
||||
nsIBufferedStreams.idl \
|
||||
nsIDirectoryListing.idl \
|
||||
nsIDownloader.idl \
|
||||
nsIEncodedChannel.idl \
|
||||
nsIFileStreams.idl \
|
||||
|
||||
@@ -60,7 +60,6 @@ nsFileChannel::nsFileChannel()
|
||||
, mUploadLength(-1)
|
||||
, mLoadFlags(LOAD_NORMAL)
|
||||
, mStatus(NS_OK)
|
||||
, mListFormat(FORMAT_HTML)
|
||||
, mIsDir(PR_FALSE)
|
||||
, mUploading(PR_FALSE)
|
||||
{
|
||||
@@ -126,15 +125,14 @@ nsFileChannel::EnsureStream()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// XXX this only needs to be threadsafe because of bug 101252
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS8(nsFileChannel,
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS7(nsFileChannel,
|
||||
nsIRequest,
|
||||
nsIChannel,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIUploadChannel,
|
||||
nsIFileChannel,
|
||||
nsITransportEventSink,
|
||||
nsIDirectoryListing)
|
||||
nsITransportEventSink)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsIRequest
|
||||
@@ -285,10 +283,7 @@ nsFileChannel::GetContentType(nsACString &aContentType)
|
||||
|
||||
if (mContentType.IsEmpty()) {
|
||||
if (mIsDir) {
|
||||
if (mListFormat == FORMAT_HTML)
|
||||
mContentType.AssignLiteral(TEXT_HTML);
|
||||
else
|
||||
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
} else {
|
||||
// Get content type from file extension
|
||||
nsCOMPtr<nsIFile> file;
|
||||
@@ -361,23 +356,7 @@ nsFileChannel::Open(nsIInputStream **result)
|
||||
rv = EnsureStream();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mIsDir && mListFormat == FORMAT_HTML) {
|
||||
nsCOMPtr<nsIStreamConverterService> scs =
|
||||
do_GetService(kStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIInputStream> temp;
|
||||
|
||||
rv = scs->Convert(mStream,
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
NS_LITERAL_STRING(TEXT_HTML).get(),
|
||||
nsnull, getter_AddRefs(temp));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ADDREF(*result = temp);
|
||||
}
|
||||
else
|
||||
NS_ADDREF(*result = mStream);
|
||||
NS_ADDREF(*result = mStream);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -454,23 +433,6 @@ nsFileChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
|
||||
rv = EnsureStream();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//
|
||||
// push stream converter if opening a directory.
|
||||
//
|
||||
if (mIsDir && mListFormat == FORMAT_HTML) {
|
||||
nsCOMPtr<nsIStreamConverterService> scs =
|
||||
do_GetService(kStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = scs->AsyncConvertData(NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
NS_LITERAL_STRING(TEXT_HTML).get(),
|
||||
listener, nsnull,
|
||||
getter_AddRefs(grip));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
listener = grip;
|
||||
}
|
||||
|
||||
//
|
||||
// create asynchronous input stream wrapping file input stream.
|
||||
//
|
||||
@@ -612,33 +574,4 @@ nsFileChannel::OnTransportStatus(nsITransport *trans, nsresult status,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::SetListFormat(PRUint32 format)
|
||||
{
|
||||
// Convert the pref value
|
||||
if (format == FORMAT_PREF) {
|
||||
format = FORMAT_HTML; // default
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
PRInt32 sFormat;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref("network.dir.format", &sFormat)))
|
||||
format = sFormat;
|
||||
}
|
||||
}
|
||||
if (format != FORMAT_RAW &&
|
||||
format != FORMAT_HTML &&
|
||||
format != FORMAT_HTTP_INDEX) {
|
||||
NS_WARNING("invalid directory format");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mListFormat = format;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetListFormat(PRUint32 *format)
|
||||
{
|
||||
*format = mListFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIDirectoryListing.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@@ -56,7 +55,6 @@ class nsFileChannel : public nsIFileChannel
|
||||
, public nsIUploadChannel
|
||||
, public nsIStreamListener
|
||||
, public nsITransportEventSink
|
||||
, public nsIDirectoryListing
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -67,7 +65,6 @@ public:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSITRANSPORTEVENTSINK
|
||||
NS_DECL_NSIDIRECTORYLISTING
|
||||
|
||||
nsFileChannel();
|
||||
virtual ~nsFileChannel() {}
|
||||
@@ -96,7 +93,6 @@ private:
|
||||
|
||||
nsCOMPtr<nsIRequest> mRequest;
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
PRUint32 mListFormat;
|
||||
PRBool mIsDir;
|
||||
PRBool mUploading;
|
||||
};
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "nsNetCID.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDirectoryListing.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ PRTimeToSeconds(PRTime t_usec)
|
||||
nsFTPChannel::nsFTPChannel()
|
||||
: mIsPending(0),
|
||||
mLoadFlags(LOAD_NORMAL),
|
||||
mListFormat(FORMAT_HTML),
|
||||
mSourceOffset(0),
|
||||
mAmount(0),
|
||||
mContentLength(-1),
|
||||
@@ -116,7 +115,6 @@ NS_INTERFACE_MAP_BEGIN(nsFTPChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICacheListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDirectoryListing)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
@@ -753,32 +751,3 @@ nsFTPChannel::GetUploadStream(nsIInputStream **stream)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::SetListFormat(PRUint32 format)
|
||||
{
|
||||
// Convert the pref value
|
||||
if (format == FORMAT_PREF) {
|
||||
format = FORMAT_HTML; // default
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
PRInt32 sFormat;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref("network.dir.format", &sFormat)))
|
||||
format = sFormat;
|
||||
}
|
||||
}
|
||||
if (format != FORMAT_RAW &&
|
||||
format != FORMAT_HTML &&
|
||||
format != FORMAT_HTTP_INDEX) {
|
||||
NS_WARNING("invalid directory format");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mListFormat = format;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetListFormat(PRUint32 *format)
|
||||
{
|
||||
*format = mListFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
#include "nsIProxyInfo.h"
|
||||
#include "nsIResumableChannel.h"
|
||||
#include "nsIResumableEntityID.h"
|
||||
#include "nsIDirectoryListing.h"
|
||||
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
@@ -82,8 +81,7 @@ class nsFTPChannel : public nsIFTPChannel,
|
||||
public nsIProgressEventSink,
|
||||
public nsIStreamListener,
|
||||
public nsICacheListener,
|
||||
public nsIResumableChannel,
|
||||
public nsIDirectoryListing
|
||||
public nsIResumableChannel
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -97,7 +95,6 @@ public:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSICACHELISTENER
|
||||
NS_DECL_NSIRESUMABLECHANNEL
|
||||
NS_DECL_NSIDIRECTORYLISTING
|
||||
|
||||
// nsFTPChannel methods:
|
||||
nsFTPChannel();
|
||||
@@ -129,7 +126,6 @@ protected:
|
||||
|
||||
PRBool mIsPending;
|
||||
PRUint32 mLoadFlags;
|
||||
PRUint32 mListFormat;
|
||||
|
||||
PRUint32 mSourceOffset;
|
||||
PRInt32 mAmount;
|
||||
|
||||
@@ -1395,28 +1395,7 @@ nsFtpState::R_mdtm() {
|
||||
nsresult
|
||||
nsFtpState::SetContentType()
|
||||
{
|
||||
nsCOMPtr<nsIDirectoryListing> list = do_QueryInterface(mChannel);
|
||||
NS_ASSERTION(list, "ftp channel isn't listable!");
|
||||
(void)list->GetListFormat(&mListFormat);
|
||||
nsCAutoString contentType;
|
||||
switch (mListFormat) {
|
||||
case nsIDirectoryListing::FORMAT_RAW:
|
||||
{
|
||||
contentType.AssignLiteral("text/ftp-dir-");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unknown directory type");
|
||||
// fall through
|
||||
case nsIDirectoryListing::FORMAT_HTML:
|
||||
contentType.AssignLiteral(TEXT_HTML);
|
||||
break;
|
||||
case nsIDirectoryListing::FORMAT_HTTP_INDEX:
|
||||
contentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
break;
|
||||
}
|
||||
|
||||
return mChannel->SetContentType(contentType);
|
||||
return mChannel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_HTTP_INDEX_FORMAT));
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -2429,42 +2408,11 @@ nsFtpState::BuildStreamConverter(nsIStreamListener** convertStreamListener)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsAutoString fromStr(NS_LITERAL_STRING("text/ftp-dir"));
|
||||
|
||||
switch (mListFormat) {
|
||||
case nsIDirectoryListing::FORMAT_RAW:
|
||||
converterListener = listener;
|
||||
break;
|
||||
default:
|
||||
// fall through
|
||||
case nsIDirectoryListing::FORMAT_HTML:
|
||||
// XXX - work arround bug 126417. We have to do the chaining
|
||||
// manually so that we don't crash
|
||||
{
|
||||
nsCOMPtr<nsIStreamListener> tmpListener;
|
||||
rv = scs->AsyncConvertData(NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
NS_LITERAL_STRING(TEXT_HTML).get(),
|
||||
listener,
|
||||
mURL,
|
||||
getter_AddRefs(tmpListener));
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = scs->AsyncConvertData(fromStr.get(),
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
tmpListener,
|
||||
mURL,
|
||||
getter_AddRefs(converterListener));
|
||||
|
||||
}
|
||||
break;
|
||||
case nsIDirectoryListing::FORMAT_HTTP_INDEX:
|
||||
rv = scs->AsyncConvertData(fromStr.get(),
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
listener,
|
||||
mURL,
|
||||
getter_AddRefs(converterListener));
|
||||
break;
|
||||
}
|
||||
|
||||
rv = scs->AsyncConvertData(NS_LITERAL_STRING("text/ftp-dir").get(),
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
listener,
|
||||
mURL,
|
||||
getter_AddRefs(converterListener));
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) scs->AsyncConvertData failed (rv=%x)\n", this, rv));
|
||||
return rv;
|
||||
|
||||
@@ -231,7 +231,6 @@ private:
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
PRUint32 mListFormat;
|
||||
|
||||
static PRUint32 mSessionStartTime;
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ extern PRLogModuleInfo* gGopherLog;
|
||||
// nsGopherChannel methods
|
||||
nsGopherChannel::nsGopherChannel()
|
||||
: mContentLength(-1),
|
||||
mListFormat(FORMAT_HTML),
|
||||
mType(-1),
|
||||
mStatus(NS_OK),
|
||||
mIsPending(PR_FALSE)
|
||||
@@ -91,12 +90,11 @@ nsGopherChannel::~nsGopherChannel()
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS6(nsGopherChannel,
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS5(nsGopherChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIDirectoryListing,
|
||||
nsITransportEventSink)
|
||||
|
||||
nsresult
|
||||
@@ -354,20 +352,7 @@ nsGopherChannel::GetContentType(nsACString &aContentType)
|
||||
aContentType.AssignLiteral(TEXT_HTML);
|
||||
break;
|
||||
case '1':
|
||||
switch (mListFormat) {
|
||||
case nsIDirectoryListing::FORMAT_RAW:
|
||||
aContentType.AssignLiteral("text/gopher-dir");
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unknown directory type");
|
||||
// fall through
|
||||
case nsIDirectoryListing::FORMAT_HTML:
|
||||
aContentType.AssignLiteral(TEXT_HTML);
|
||||
break;
|
||||
case nsIDirectoryListing::FORMAT_HTTP_INDEX:
|
||||
aContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
break;
|
||||
}
|
||||
aContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
break;
|
||||
case '2': // CSO search - unhandled, should not be selectable
|
||||
aContentType.AssignLiteral(TEXT_HTML);
|
||||
@@ -718,38 +703,11 @@ nsGopherChannel::PushStreamConverters(nsIStreamListener *listener, nsIStreamList
|
||||
// What we now do depends on what type of file we have
|
||||
if (mType=='1' || mType=='7') {
|
||||
// Send the directory format back for a directory
|
||||
switch (mListFormat) {
|
||||
case nsIDirectoryListing::FORMAT_RAW:
|
||||
break;
|
||||
default:
|
||||
// fall through
|
||||
case nsIDirectoryListing::FORMAT_HTML:
|
||||
// XXX - work arround bug 126417. We have to do the chaining
|
||||
// manually so that we don't crash
|
||||
{
|
||||
nsCOMPtr<nsIStreamListener> tmpListener;
|
||||
rv = StreamConvService->AsyncConvertData(
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
NS_LITERAL_STRING(TEXT_HTML).get(),
|
||||
listener,
|
||||
mUrl,
|
||||
getter_AddRefs(tmpListener));
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = StreamConvService->AsyncConvertData(NS_LITERAL_STRING("text/gopher-dir").get(),
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
tmpListener,
|
||||
mUrl,
|
||||
getter_AddRefs(converterListener));
|
||||
}
|
||||
break;
|
||||
case nsIDirectoryListing::FORMAT_HTTP_INDEX:
|
||||
rv = StreamConvService->AsyncConvertData(NS_LITERAL_STRING("text/gopher-dir").get(),
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
listener,
|
||||
mUrl,
|
||||
getter_AddRefs(converterListener));
|
||||
break;
|
||||
}
|
||||
rv = StreamConvService->AsyncConvertData(NS_LITERAL_STRING("text/gopher-dir").get(),
|
||||
NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(),
|
||||
listener,
|
||||
mUrl,
|
||||
getter_AddRefs(converterListener));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else if (mType=='0') {
|
||||
// Convert general file
|
||||
@@ -773,36 +731,6 @@ nsGopherChannel::PushStreamConverters(nsIStreamListener *listener, nsIStreamList
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGopherChannel::SetListFormat(PRUint32 format)
|
||||
{
|
||||
// Convert the pref value
|
||||
if (format == FORMAT_PREF) {
|
||||
format = FORMAT_HTML; // default
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
PRInt32 sFormat;
|
||||
if (NS_SUCCEEDED(prefs->GetIntPref("network.dir.format", &sFormat)))
|
||||
format = sFormat;
|
||||
}
|
||||
}
|
||||
if (format != FORMAT_RAW &&
|
||||
format != FORMAT_HTML &&
|
||||
format != FORMAT_HTTP_INDEX) {
|
||||
NS_WARNING("invalid directory format");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mListFormat = format;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGopherChannel::GetListFormat(PRUint32 *format)
|
||||
{
|
||||
*format = mListFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGopherChannel::OnTransportStatus(nsITransport *trans, nsresult status,
|
||||
PRUint32 progress, PRUint32 progressMax)
|
||||
|
||||
@@ -58,13 +58,11 @@
|
||||
#include "nsISocketTransport.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIProxyInfo.h"
|
||||
#include "nsIDirectoryListing.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIInputStreamPump.h"
|
||||
|
||||
class nsGopherChannel : public nsIChannel,
|
||||
public nsIStreamListener,
|
||||
public nsIDirectoryListing,
|
||||
public nsITransportEventSink {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -72,7 +70,6 @@ public:
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSIDIRECTORYLISTING
|
||||
NS_DECL_NSITRANSPORTEVENTSINK
|
||||
|
||||
// nsGopherChannel methods:
|
||||
@@ -95,7 +92,6 @@ protected:
|
||||
nsCString mContentTypeHint;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
PRUint32 mListFormat;
|
||||
|
||||
nsXPIDLCString mHost;
|
||||
PRInt32 mPort;
|
||||
|
||||
@@ -80,19 +80,21 @@
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIDirectoryListing.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
|
||||
static const int FORMAT_HTML = 2;
|
||||
static const int FORMAT_XUL = 3;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Common CIDs
|
||||
@@ -1031,12 +1033,6 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && (channel)) {
|
||||
channel->SetNotificationCallbacks(httpIndex);
|
||||
nsCOMPtr<nsIDirectoryListing> dirList = do_QueryInterface(channel);
|
||||
NS_ASSERTION(dirList, "Directory listing doesn't impl nsIDirectoryListing");
|
||||
if (dirList) {
|
||||
rv = dirList->SetListFormat(nsIDirectoryListing::FORMAT_HTTP_INDEX);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not set directory list format");
|
||||
}
|
||||
rv = channel->AsyncOpen(httpIndex, aSource);
|
||||
}
|
||||
}
|
||||
@@ -1380,27 +1376,16 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand,
|
||||
nsresult rv;
|
||||
|
||||
// OK - are we going to be using the html listing or not?
|
||||
nsCOMPtr<nsIPref> prefSrv = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIPrefBranch> prefSrv = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool useXUL = PR_FALSE;
|
||||
PRInt32 dirPref;
|
||||
rv = prefSrv->GetIntPref("network.dir.format", &dirPref);
|
||||
if (NS_SUCCEEDED(rv) && dirPref == nsIDirectoryListing::FORMAT_HTTP_INDEX) {
|
||||
if (NS_SUCCEEDED(rv) && dirPref == FORMAT_XUL) {
|
||||
useXUL = PR_TRUE;
|
||||
}
|
||||
|
||||
// We need to disable html mode for file:///, at least for the moment
|
||||
// The charset coding isn't quite right for non ASCII systems
|
||||
// XXX - This is a temporary hack
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool isFile;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("file", &isFile)) && isFile)
|
||||
useXUL = PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool viewSource = (PL_strstr(aContentType,"view-source") != 0);
|
||||
|
||||
if ((NS_FAILED(rv) || useXUL) && !viewSource) {
|
||||
|
||||
Reference in New Issue
Block a user