зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1639990 - Rename defaultPrinterName to lastUsedPrinterName r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D76955
This commit is contained in:
Родитель
ed4a64a653
Коммит
4c06dea151
|
@ -5215,20 +5215,20 @@ void nsGlobalWindowOuter::PrintOuter(ErrorResult& aError) {
|
|||
nsAutoString printerName;
|
||||
printSettings->GetPrinterName(printerName);
|
||||
|
||||
bool shouldGetDefaultPrinterName = printerName.IsEmpty();
|
||||
bool shouldGetLastUsedPrinterName = printerName.IsEmpty();
|
||||
# ifdef MOZ_X11
|
||||
// In Linux, GTK backend does not support per printer settings.
|
||||
// Calling GetDefaultPrinterName causes a sandbox violation (see Bug
|
||||
// Calling GetLastUsedPrinterName 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,
|
||||
// last-used printer name if no name is set. Unless we are in the parent,
|
||||
// we will skip this part.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
shouldGetDefaultPrinterName = false;
|
||||
shouldGetLastUsedPrinterName = false;
|
||||
}
|
||||
# endif
|
||||
if (shouldGetDefaultPrinterName) {
|
||||
printSettingsService->GetDefaultPrinterName(printerName);
|
||||
if (shouldGetLastUsedPrinterName) {
|
||||
printSettingsService->GetLastUsedPrinterName(printerName);
|
||||
printSettings->SetPrinterName(printerName);
|
||||
}
|
||||
printSettingsService->InitPrintSettingsFromPrinter(printerName,
|
||||
|
|
|
@ -56,10 +56,10 @@ support-files =
|
|||
chrome_over_plugin_window.xhtml
|
||||
chrome_over_plugin_window_frame.html
|
||||
[test_default_background.xhtml]
|
||||
[test_default_printer_name.html]
|
||||
[test_dialog_with_positioning.html]
|
||||
tags = openwindow
|
||||
[test_fixed_bg_scrolling_repaints.html]
|
||||
[test_last_used_printer_name.html]
|
||||
[test_leaf_layers_partition_browser_window.xhtml]
|
||||
skip-if = true # Bug 992311
|
||||
[test_prerendered_transforms.html]
|
||||
|
|
|
@ -62,7 +62,7 @@ function run()
|
|||
var printService = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
||||
.getService(Ci.nsIPrintSettingsService);
|
||||
|
||||
if (printService.defaultPrinterName != '') {
|
||||
if (printService.lastUsedPrinterName != '') {
|
||||
printpreview();
|
||||
ok(gWbp.doingPrintPreview, "Should be doing print preview");
|
||||
exitprintpreview();
|
||||
|
|
|
@ -62,7 +62,7 @@ function run1()
|
|||
var printService = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
||||
.getService(Ci.nsIPrintSettingsService);
|
||||
|
||||
if (printService.defaultPrinterName != '') {
|
||||
if (printService.lastUsedPrinterName != '') {
|
||||
printpreview();
|
||||
ok(gWbp.doingPrintPreview, "Should be doing print preview");
|
||||
exitprintpreview();
|
||||
|
|
|
@ -82,7 +82,7 @@ function runTests()
|
|||
var printService = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
||||
.getService(Ci.nsIPrintSettingsService);
|
||||
|
||||
if (printService.defaultPrinterName != '') {
|
||||
if (printService.lastUsedPrinterName != '') {
|
||||
startTest1();
|
||||
} else {
|
||||
todo(false, "No printer seems installed on this machine, that is necessary for this test");
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function getDefaultPrinterName() {
|
||||
function getLastUsedPrinterName() {
|
||||
try {
|
||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
|
||||
Ci.nsIPrintSettingsService
|
||||
);
|
||||
|
||||
return PSSVC.defaultPrinterName;
|
||||
return PSSVC.lastUsedPrinterName;
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ function getDefaultPrinterName() {
|
|||
}
|
||||
|
||||
function run() {
|
||||
isnot(getDefaultPrinterName(), null);
|
||||
isnot(getLastUsedPrinterName(), null);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
@ -436,10 +436,10 @@ static void BuildNestedPrintObjects(Document* aDocument,
|
|||
|
||||
/**
|
||||
* On platforms that support it, sets the printer name stored in the
|
||||
* nsIPrintSettings to the default printer if a printer name is not already
|
||||
* nsIPrintSettings to the last-used printer if a printer name is not already
|
||||
* set.
|
||||
* XXXjwatt: Why is this necessary? Can't the code that reads the printer
|
||||
* name later "just" use the default printer if a name isn't specified? Then
|
||||
* name later "just" use the last-used printer if a name isn't specified? Then
|
||||
* we wouldn't have this inconsistency between platforms and processes.
|
||||
*/
|
||||
static nsresult EnsureSettingsHasPrinterNameSet(
|
||||
|
@ -449,7 +449,7 @@ static nsresult EnsureSettingsHasPrinterNameSet(
|
|||
return NS_OK;
|
||||
#else
|
||||
# if defined(MOZ_X11)
|
||||
// On Linux, default printer name should be requested on the parent side.
|
||||
// On Linux, last-used 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;
|
||||
|
@ -464,12 +464,13 @@ static nsresult EnsureSettingsHasPrinterNameSet(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// aPrintSettings doesn't have a printer set. Try to fetch the default.
|
||||
// aPrintSettings doesn't have a printer set.
|
||||
// Try to fetch the name of the last-used printer.
|
||||
nsCOMPtr<nsIPrintSettingsService> printSettingsService =
|
||||
do_GetService(sPrintSettingsServiceContractID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = printSettingsService->GetDefaultPrinterName(printerName);
|
||||
rv = printSettingsService->GetLastUsedPrinterName(printerName);
|
||||
if (NS_SUCCEEDED(rv) && !printerName.IsEmpty()) {
|
||||
rv = aPrintSettings->SetPrinterName(printerName);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class PrintingChild extends ActorChild {
|
|||
Services.wm.getOuterWindowWithId(data.windowID),
|
||||
data.simplifiedMode,
|
||||
data.changingBrowsers,
|
||||
data.defaultPrinterName
|
||||
data.lastUsedPrinterName
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -113,14 +113,14 @@ class PrintingChild extends ActorChild {
|
|||
this.print(
|
||||
Services.wm.getOuterWindowWithId(data.windowID),
|
||||
data.simplifiedMode,
|
||||
data.defaultPrinterName
|
||||
data.lastUsedPrinterName
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getPrintSettings(defaultPrinterName) {
|
||||
getPrintSettings(lastUsedPrinterName) {
|
||||
try {
|
||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
|
||||
Ci.nsIPrintSettingsService
|
||||
|
@ -128,7 +128,7 @@ class PrintingChild extends ActorChild {
|
|||
|
||||
let printSettings = PSSVC.globalPrintSettings;
|
||||
if (!printSettings.printerName) {
|
||||
printSettings.printerName = defaultPrinterName;
|
||||
printSettings.printerName = lastUsedPrinterName;
|
||||
}
|
||||
// First get any defaults from the printer
|
||||
PSSVC.initPrintSettingsFromPrinter(
|
||||
|
@ -319,11 +319,11 @@ class PrintingChild extends ActorChild {
|
|||
contentWindow,
|
||||
simplifiedMode,
|
||||
changingBrowsers,
|
||||
defaultPrinterName
|
||||
lastUsedPrinterName
|
||||
) {
|
||||
const { docShell } = this;
|
||||
try {
|
||||
let printSettings = this.getPrintSettings(defaultPrinterName);
|
||||
let printSettings = this.getPrintSettings(lastUsedPrinterName);
|
||||
|
||||
// If we happen to be on simplified mode, we need to set docURL in order
|
||||
// to generate header/footer content correctly, since simplified tab has
|
||||
|
@ -379,8 +379,8 @@ class PrintingChild extends ActorChild {
|
|||
this.docShell.initOrReusePrintPreviewViewer().exitPrintPreview();
|
||||
}
|
||||
|
||||
print(contentWindow, simplifiedMode, defaultPrinterName) {
|
||||
let printSettings = this.getPrintSettings(defaultPrinterName);
|
||||
print(contentWindow, simplifiedMode, lastUsedPrinterName) {
|
||||
let printSettings = this.getPrintSettings(lastUsedPrinterName);
|
||||
// Set the title so that the print dialog can pick it up and
|
||||
// use it to generate the filename for save-to-PDF.
|
||||
printSettings.title = contentWindow.document.title;
|
||||
|
|
|
@ -228,7 +228,7 @@ function hfIdToValue(node) {
|
|||
|
||||
function setPrinterDefaultsForSelectedPrinter() {
|
||||
if (gPrintSettings.printerName == "") {
|
||||
gPrintSettings.printerName = gPrintService.defaultPrinterName;
|
||||
gPrintSettings.printerName = gPrintService.lastUsedPrinterName;
|
||||
}
|
||||
|
||||
// First get any defaults from the printer
|
||||
|
|
|
@ -96,13 +96,13 @@ var PrintUtils = {
|
|||
return true;
|
||||
},
|
||||
|
||||
_getDefaultPrinterName() {
|
||||
_getLastUsedPrinterName() {
|
||||
try {
|
||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
|
||||
Ci.nsIPrintSettingsService
|
||||
);
|
||||
|
||||
return PSSVC.defaultPrinterName;
|
||||
return PSSVC.lastUsedPrinterName;
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ var PrintUtils = {
|
|||
topBrowser.messageManager.sendAsyncMessage("Printing:Print", {
|
||||
windowID,
|
||||
simplifiedMode: this._shouldSimplify,
|
||||
defaultPrinterName: this._getDefaultPrinterName(),
|
||||
lastUsedPrinterName: this._getLastUsedPrinterName(),
|
||||
});
|
||||
|
||||
if (printPreviewIsOpen) {
|
||||
|
@ -393,7 +393,7 @@ var PrintUtils = {
|
|||
|
||||
_setPrinterDefaultsForSelectedPrinter(aPSSVC, aPrintSettings) {
|
||||
if (!aPrintSettings.printerName) {
|
||||
aPrintSettings.printerName = aPSSVC.defaultPrinterName;
|
||||
aPrintSettings.printerName = aPSSVC.lastUsedPrinterName;
|
||||
}
|
||||
|
||||
// First get any defaults from the printer
|
||||
|
@ -487,14 +487,14 @@ var PrintUtils = {
|
|||
}
|
||||
this._currentPPBrowser = ppBrowser;
|
||||
let mm = ppBrowser.messageManager;
|
||||
let defaultPrinterName = this._getDefaultPrinterName();
|
||||
let lastUsedPrinterName = this._getLastUsedPrinterName();
|
||||
|
||||
let sendEnterPreviewMessage = function(browser, simplified) {
|
||||
mm.sendAsyncMessage("Printing:Preview:Enter", {
|
||||
windowID: browser.outerWindowID,
|
||||
simplifiedMode: simplified,
|
||||
changingBrowsers: changingPrintPreviewBrowsers,
|
||||
defaultPrinterName,
|
||||
lastUsedPrinterName,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -126,14 +126,14 @@ nsresult PrintingParent::ShowPrintDialog(PBrowserParent* aParent,
|
|||
nsString printerName;
|
||||
settings->GetPrinterName(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, unless we're printing to file.
|
||||
// Requesting the last-used 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 last-used printer name, unless we're printing to file.
|
||||
bool printToFile = false;
|
||||
MOZ_ALWAYS_SUCCEEDS(settings->GetPrintToFile(&printToFile));
|
||||
if (!printToFile && printerName.IsEmpty()) {
|
||||
mPrintSettingsSvc->GetDefaultPrinterName(printerName);
|
||||
mPrintSettingsSvc->GetLastUsedPrinterName(printerName);
|
||||
settings->SetPrinterName(printerName);
|
||||
}
|
||||
mPrintSettingsSvc->InitPrintSettingsFromPrinter(printerName, settings);
|
||||
|
|
|
@ -1015,7 +1015,7 @@ nsPrintDialogServiceGTK::ShowPageSetup(nsPIDOMWindowOuter* aParent,
|
|||
nsString printName;
|
||||
aNSSettings->GetPrinterName(printName);
|
||||
if (printName.IsVoid()) {
|
||||
psService->GetDefaultPrinterName(printName);
|
||||
psService->GetLastUsedPrinterName(printName);
|
||||
aNSSettings->SetPrinterName(printName);
|
||||
}
|
||||
psService->InitPrintSettingsFromPrefs(aNSSettings, true,
|
||||
|
|
|
@ -58,7 +58,7 @@ interface nsIPrintSettingsService : nsISupports
|
|||
/**
|
||||
* The name of the last printer used, or else the system default printer.
|
||||
*/
|
||||
readonly attribute AString defaultPrinterName;
|
||||
readonly attribute AString lastUsedPrinterName;
|
||||
|
||||
/**
|
||||
* Initializes certain settings from the native printer into the PrintSettings
|
||||
|
|
|
@ -883,7 +883,7 @@ nsresult nsPrintSettingsService::_CreatePrintSettings(
|
|||
NS_ADDREF(*_retval = printSettings); // ref count
|
||||
|
||||
nsString printerName;
|
||||
nsresult rv = GetDefaultPrinterName(printerName);
|
||||
nsresult rv = GetLastUsedPrinterName(printerName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
(*_retval)->SetPrinterName(printerName);
|
||||
|
||||
|
@ -913,7 +913,8 @@ nsPrintSettingsService::GetNewPrintSettings(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsService::GetDefaultPrinterName(nsAString& aDefaultPrinterName) {
|
||||
nsPrintSettingsService::GetLastUsedPrinterName(
|
||||
nsAString& aLastUsedPrinterName) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrinterEnumerator> prtEnum =
|
||||
do_GetService(NS_PRINTER_ENUMERATOR_CONTRACTID, &rv);
|
||||
|
@ -938,7 +939,7 @@ nsPrintSettingsService::GetDefaultPrinterName(nsAString& aDefaultPrinterName) {
|
|||
}
|
||||
}
|
||||
if (isValid) {
|
||||
aDefaultPrinterName = lastPrinterName;
|
||||
aLastUsedPrinterName = lastPrinterName;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -946,7 +947,7 @@ nsPrintSettingsService::GetDefaultPrinterName(nsAString& aDefaultPrinterName) {
|
|||
|
||||
// There is no last printer preference, or it doesn't name a valid printer.
|
||||
// Return the default from the printer enumeration.
|
||||
return prtEnum->GetDefaultPrinterName(aDefaultPrinterName);
|
||||
return prtEnum->GetDefaultPrinterName(aLastUsedPrinterName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче