Bug 773942 - Use a generic string for the PDF description since it is not necessarily tied to the default handler. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D72777
This commit is contained in:
Jared Wein 2020-05-16 05:59:50 +00:00
parent 3074d7ebb9
commit e2e5ff74a3
2 changed files with 23 additions and 0 deletions

View File

@ -16,3 +16,4 @@ unknownCancel.label=Cancel
fileType=%S file
# LOCALIZATION NOTE (orderedFileSizeWithType): first %S is type, second %S is size, and third %S is unit
orderedFileSizeWithType=%1$S (%2$S %3$S)
pdfHandlerDescription=Portable Document Format

View File

@ -2465,6 +2465,28 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(
// If we got no mimeinfo, something went wrong. Probably lack of memory.
if (!*_retval) return NS_ERROR_OUT_OF_MEMORY;
// (1.5) Overwrite with generic description if the extension is PDF
// since the file format is supported by Firefox and we don't want
// other brands positioning themselves as the sole viewer for a system.
if (aFileExt.LowerCaseEqualsASCII("pdf") ||
aFileExt.LowerCaseEqualsASCII(".pdf")) {
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> unknownContentTypeBundle;
rv = bundleService->CreateBundle(
"chrome://mozapps/locale/downloads/unknownContentType.properties",
getter_AddRefs(unknownContentTypeBundle));
if (NS_SUCCEEDED(rv)) {
nsAutoString pdfHandlerDescription;
rv = unknownContentTypeBundle->GetStringFromName("pdfHandlerDescription",
pdfHandlerDescription);
if (NS_SUCCEEDED(rv)) {
(*_retval)->SetDescription(pdfHandlerDescription);
}
}
}
// (2) Now, let's see if we can find something in our datastore
// This will not overwrite the OS information that interests us
// (i.e. default application, default app. description)