Bug 1420171 Part 1: Only default the print-to file name on Linux if not already set. r=karlt

This allows the web extension saveAsPDF function to work properly.
This commit is contained in:
Bob Owen 2017-11-28 08:58:43 +00:00
Родитель d397e88daf
Коммит 546d657b09
1 изменённых файлов: 19 добавлений и 13 удалений

Просмотреть файл

@ -411,20 +411,26 @@ nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const nsAString& aPrinterNa
NS_ENSURE_ARG_POINTER(aPrintSettings);
/* Set filename */
nsAutoCString filename;
const char *path;
if (!(path = PR_GetEnv("PWD")))
path = PR_GetEnv("HOME");
if (path)
filename = nsPrintfCString("%s/mozilla.pdf", path);
else
filename.AssignLiteral("mozilla.pdf");
// Set a default file name.
nsAutoString filename;
nsresult rv = aPrintSettings->GetToFileName(filename);
if (NS_FAILED(rv) || filename.IsEmpty()) {
const char* path = PR_GetEnv("PWD");
if (!path) {
path = PR_GetEnv("HOME");
}
DO_PR_DEBUG_LOG(("Setting default filename to '%s'\n", filename.get()));
aPrintSettings->SetToFileName(NS_ConvertUTF8toUTF16(filename));
if (path) {
CopyUTF8toUTF16(path, filename);
filename.AppendLiteral("/mozilla.pdf");
} else {
filename.AssignLiteral("mozilla.pdf");
}
DO_PR_DEBUG_LOG(("Setting default filename to '%s'\n",
NS_ConvertUTF16toUTF8(filename).get()));
aPrintSettings->SetToFileName(filename);
}
aPrintSettings->SetIsInitializedFromPrinter(true);