mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
backout bug1757604 part from rev 591552c5 as it cause display issues
This commit is contained in:
parent
1b0e373028
commit
5d774d0709
2 changed files with 37 additions and 50 deletions
|
|
@ -596,50 +596,48 @@ nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsJARChannel::SetContentTypeGuess() {
|
|
||||||
//
|
|
||||||
// generate content type and set it
|
|
||||||
//
|
|
||||||
const char *ext = nullptr, *fileName = mJarEntry.get();
|
|
||||||
int32_t len = mJarEntry.Length();
|
|
||||||
|
|
||||||
// check if we're displaying a directory
|
|
||||||
// mJarEntry will be empty if we're trying to display
|
|
||||||
// the topmost directory in a zip, e.g. jar:foo.zip!/
|
|
||||||
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
|
|
||||||
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
|
||||||
} else {
|
|
||||||
// not a directory, take a guess by its extension
|
|
||||||
for (int32_t i = len-1; i >= 0; i--) {
|
|
||||||
if (fileName[i] == '.') {
|
|
||||||
ext = &fileName[i + 1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ext) {
|
|
||||||
nsIMIMEService *mimeServ = gJarHandler->MimeService();
|
|
||||||
if (mimeServ)
|
|
||||||
mimeServ->GetTypeFromExtension(nsDependentCString(ext), mContentType);
|
|
||||||
}
|
|
||||||
if (mContentType.IsEmpty())
|
|
||||||
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsJARChannel::GetContentType(nsACString &aResult)
|
nsJARChannel::GetContentType(nsACString &result)
|
||||||
{
|
{
|
||||||
// If the Jar file has not been open yet,
|
// If the Jar file has not been open yet,
|
||||||
// We return application/x-unknown-content-type
|
// We return application/x-unknown-content-type
|
||||||
if (!mOpened || mContentType.IsEmpty()) {
|
if (!mOpened) {
|
||||||
aResult.Assign(UNKNOWN_CONTENT_TYPE);
|
result.Assign(UNKNOWN_CONTENT_TYPE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
aResult = mContentType;
|
if (mContentType.IsEmpty()) {
|
||||||
|
|
||||||
|
//
|
||||||
|
// generate content type and set it
|
||||||
|
//
|
||||||
|
const char *ext = nullptr, *fileName = mJarEntry.get();
|
||||||
|
int32_t len = mJarEntry.Length();
|
||||||
|
|
||||||
|
// check if we're displaying a directory
|
||||||
|
// mJarEntry will be empty if we're trying to display
|
||||||
|
// the topmost directory in a zip, e.g. jar:foo.zip!/
|
||||||
|
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
|
||||||
|
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// not a directory, take a guess by its extension
|
||||||
|
for (int32_t i = len-1; i >= 0; i--) {
|
||||||
|
if (fileName[i] == '.') {
|
||||||
|
ext = &fileName[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ext) {
|
||||||
|
nsIMIMEService *mimeServ = gJarHandler->MimeService();
|
||||||
|
if (mimeServ)
|
||||||
|
mimeServ->GetTypeFromExtension(nsDependentCString(ext), mContentType);
|
||||||
|
}
|
||||||
|
if (mContentType.IsEmpty())
|
||||||
|
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = mContentType;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -750,7 +748,7 @@ nsJARChannel::Open(nsIInputStream **stream)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
input.forget(stream);
|
input.forget(stream);
|
||||||
SetOpened();
|
mOpened = true;
|
||||||
// local files are always considered safe
|
// local files are always considered safe
|
||||||
mIsUnsafe = false;
|
mIsUnsafe = false;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
@ -765,14 +763,6 @@ nsJARChannel::Open2(nsIInputStream** aStream)
|
||||||
return Open(aStream);
|
return Open(aStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
nsJARChannel::SetOpened() {
|
|
||||||
MOZ_ASSERT(!mOpened, "Opening channel twice?");
|
|
||||||
mOpened = true;
|
|
||||||
// Compute the content type now.
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(SetContentTypeGuess()), "content type guess failure");
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
|
nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
|
||||||
{
|
{
|
||||||
|
|
@ -855,7 +845,7 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
|
||||||
if (mLoadGroup)
|
if (mLoadGroup)
|
||||||
mLoadGroup->AddRequest(this, nullptr);
|
mLoadGroup->AddRequest(this, nullptr);
|
||||||
|
|
||||||
SetOpened();
|
mOpened = true;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,6 @@ private:
|
||||||
mozilla::net::MemoryDownloader::Data aData)
|
mozilla::net::MemoryDownloader::Data aData)
|
||||||
override;
|
override;
|
||||||
|
|
||||||
nsresult SetContentTypeGuess();
|
|
||||||
void SetOpened();
|
|
||||||
|
|
||||||
nsCString mSpec;
|
nsCString mSpec;
|
||||||
|
|
||||||
bool mOpened;
|
bool mOpened;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue