Bug 1329216 - Move default printer name querying. r=bobowen

This commit is contained in:
Julian Hector 2017-02-13 13:08:20 +01:00
Родитель 94cad21ec7
Коммит 3610edb99c
3 изменённых файлов: 34 добавлений и 5 удалений

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

@ -7776,7 +7776,19 @@ nsGlobalWindow::PrintOuter(ErrorResult& aError)
nsXPIDLString printerName;
printSettings->GetPrinterName(getter_Copies(printerName));
if (printerName.IsEmpty()) {
bool shouldGetDefaultPrinterName = printerName.IsEmpty();
#ifdef MOZ_X11
// In Linux, GTK backend does not support per printer settings.
// Calling GetDefaultPrinterName causes a sandbox violation (see Bug 1329216).
// The printer name is not needed anywhere else on Linux before it gets to the parent.
// In the parent, we will then query the default printer name if no name is set.
// Unless we are in the parent, we will skip this part.
if (!XRE_IsParentProcess()) {
shouldGetDefaultPrinterName = false;
}
#endif
if (shouldGetDefaultPrinterName) {
printSettingsService->GetDefaultPrinterName(getter_Copies(printerName));
printSettings->SetPrinterName(printerName);
}

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

@ -980,6 +980,13 @@ nsPrintEngine::CheckForPrinters(nsIPrintSettings* aPrintSettings)
// Mac doesn't support retrieving a printer list.
return NS_OK;
#else
#if defined(MOZ_X11)
// On Linux, default printer name should be requested on the parent side.
// Unless we are in the parent, we ignore this function
if (!XRE_IsParentProcess()) {
return NS_OK;
}
#endif
NS_ENSURE_ARG_POINTER(aPrintSettings);
// See if aPrintSettings already has a printer

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

@ -129,14 +129,24 @@ PrintingParent::ShowPrintDialog(PBrowserParent* aParent,
rv = settings->SetPrintSilent(printSilently);
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLString printerName;
settings->GetPrinterName(getter_Copies(printerName));
#ifdef MOZ_X11
// Requesting the default printer name on Linux has been removed in the child,
// because it was causing a sandbox violation (see Bug 1329216).
// If no printer name is set at this point, use the print settings service
// to get the default printer name.
if (printerName.IsEmpty()) {
mPrintSettingsSvc->GetDefaultPrinterName(getter_Copies(printerName));
settings->SetPrinterName(printerName);
}
mPrintSettingsSvc->InitPrintSettingsFromPrinter(printerName, settings);
#endif
// If this is for print preview or we are printing silently then we just need
// to initialize the print settings with anything specific from the printer.
if (isPrintPreview || printSilently ||
Preferences::GetBool("print.always_print_silent", printSilently)) {
nsXPIDLString printerName;
rv = settings->GetPrinterName(getter_Copies(printerName));
NS_ENSURE_SUCCESS(rv, rv);
settings->SetIsInitializedFromPrinter(false);
mPrintSettingsSvc->InitPrintSettingsFromPrinter(printerName, settings);
} else {