Bug 224209 - Correct filename on title when viewing an image from a PHP file. r=bz

This commit is contained in:
Akshendra Pratap 2014-10-30 06:08:00 +01:00
parent 4b609c3d9e
commit 08ba44731a
5 changed files with 14 additions and 6 deletions

View File

@ -781,7 +781,7 @@ ImageDocument::UpdateTitleAndCharset()
"ImageTitleWithDimensions2AndFile",
};
MediaDocument::UpdateTitleAndCharset(typeStr, formatNames,
MediaDocument::UpdateTitleAndCharset(typeStr, mChannel, formatNames,
mImageWidth, mImageHeight, status);
}

View File

@ -278,10 +278,16 @@ MediaDocument::StartLayout()
}
void
MediaDocument::GetFileName(nsAString& aResult)
MediaDocument::GetFileName(nsAString& aResult, nsIChannel* aChannel)
{
aResult.Truncate();
if (aChannel) {
aChannel->GetContentDispositionFilename(aResult);
if (!aResult.IsEmpty())
return;
}
nsCOMPtr<nsIURL> url = do_QueryInterface(mDocumentURI);
if (!url)
return;
@ -339,12 +345,13 @@ MediaDocument::LinkStylesheet(const nsAString& aStylesheet)
void
MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
nsIChannel* aChannel,
const char* const* aFormatNames,
int32_t aWidth, int32_t aHeight,
const nsAString& aStatus)
{
nsXPIDLString fileStr;
GetFileName(fileStr);
GetFileName(fileStr, aChannel);
NS_ConvertASCIItoUTF16 typeStr(aTypeStr);
nsXPIDLString title;

View File

@ -48,7 +48,7 @@ protected:
friend class MediaDocumentStreamListener;
nsresult StartLayout();
void GetFileName(nsAString& aResult);
void GetFileName(nsAString& aResult, nsIChannel* aChannel);
nsresult LinkStylesheet(const nsAString& aStylesheet);
@ -64,6 +64,7 @@ protected:
// but could be in other units for other 'media', in which case you have to
// define format names accordingly.
void UpdateTitleAndCharset(const nsACString& aTypeStr,
nsIChannel* aChannel,
const char* const* aFormatNames = sFormatNames,
int32_t aWidth = 0,
int32_t aHeight = 0,

View File

@ -185,7 +185,7 @@ PluginDocument::StartDocumentLoad(const char* aCommand,
return rv;
}
MediaDocument::UpdateTitleAndCharset(mMimeType);
MediaDocument::UpdateTitleAndCharset(mMimeType, aChannel);
mStreamListener = new PluginStreamListener(this);
NS_ASSERTION(aDocListener, "null aDocListener");

View File

@ -128,7 +128,7 @@ VideoDocument::UpdateTitle(nsIChannel* aChannel)
return;
nsAutoString fileName;
GetFileName(fileName);
GetFileName(fileName, aChannel);
SetTitle(fileName);
}