Revert bug 1425188 in order to restore 'Print to LPR' option.

diff --git widget/gtk/nsDeviceContextSpecG.cpp widget/gtk/nsDeviceContextSpecG.cpp
index a90f13b43b006..ca2449aa766f5 100644
--- widget/gtk/nsDeviceContextSpecG.cpp
+++ widget/gtk/nsDeviceContextSpecG.cpp
@@ -150,8 +150,8 @@ already_AddRefed<PrintTarget> nsDeviceContextSpecGTK::MakePrintTarget()
   // Determine the real format with some GTK magic
   if (format == nsIPrintSettings::kOutputFormatNative) {
     if (mIsPPreview) {
-      // There is nothing to detect on Print Preview, use PDF.
-      format = nsIPrintSettings::kOutputFormatPDF;
+      // There is nothing to detect on Print Preview, use PS.
+      format = nsIPrintSettings::kOutputFormatPS;
     } else {
       return nullptr;
     }
diff --git widget/gtk/nsPrintDialogGTK.cpp widget/gtk/nsPrintDialogGTK.cpp
index d499fd2f37729..75ec90c2f9c9a 100644
--- widget/gtk/nsPrintDialogGTK.cpp
+++ widget/gtk/nsPrintDialogGTK.cpp
@@ -180,6 +180,7 @@ nsPrintDialogWidgetGTK::nsPrintDialogWidgetGTK(nsPIDOMWindowOuter *aParent,
                       | GTK_PRINT_CAPABILITY_REVERSE
                       | GTK_PRINT_CAPABILITY_SCALE
                       | GTK_PRINT_CAPABILITY_GENERATE_PDF
+                      | GTK_PRINT_CAPABILITY_GENERATE_PS
                     )
                   );
 
diff --git widget/gtk/nsPrintSettingsGTK.cpp widget/gtk/nsPrintSettingsGTK.cpp
index 44dc63375a598..dafab1795d943 100644
--- widget/gtk/nsPrintSettingsGTK.cpp
+++ widget/gtk/nsPrintSettingsGTK.cpp
@@ -214,12 +214,22 @@ NS_IMETHODIMP nsPrintSettingsGTK::GetOutputFormat(int16_t *aOutputFormat)
     return rv;
   }
 
-  if (format == nsIPrintSettings::kOutputFormatNative &&
-      GTK_IS_PRINTER(mGTKPrinter)) {
-    if (gtk_printer_accepts_pdf(mGTKPrinter)) {
-      format = nsIPrintSettings::kOutputFormatPDF;
-    } else {
-      format = nsIPrintSettings::kOutputFormatPS;
+  if (format == nsIPrintSettings::kOutputFormatNative) {
+    const gchar* fmtGTK =
+      gtk_print_settings_get(mPrintSettings,
+                             GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
+    if (fmtGTK) {
+      if (nsDependentCString(fmtGTK).EqualsIgnoreCase("pdf")) {
+        format = nsIPrintSettings::kOutputFormatPDF;
+      } else {
+        format = nsIPrintSettings::kOutputFormatPS;
+      }
+    } else if (GTK_IS_PRINTER(mGTKPrinter)) {
+      if (gtk_printer_accepts_pdf(mGTKPrinter)) {
+        format = nsIPrintSettings::kOutputFormatPDF;
+      } else {
+        format = nsIPrintSettings::kOutputFormatPS;
+      }
     }
   }
 
@@ -424,7 +434,11 @@ nsPrintSettingsGTK::SetToFileName(const nsAString& aToFileName)
     return NS_OK;
   }
 
-  gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "pdf");
+  if (StringEndsWith(aToFileName, NS_LITERAL_STRING(".ps"))) {
+    gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "ps");
+  } else {
+    gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "pdf");
+  }
 
   nsCOMPtr<nsIFile> file;
   nsresult rv = NS_NewLocalFile(aToFileName, true, getter_AddRefs(file));
diff --git widget/nsPrintSettingsService.cpp widget/nsPrintSettingsService.cpp
index ad50088a48082..df1879ecdbf39 100644
--- widget/nsPrintSettingsService.cpp
+++ widget/nsPrintSettingsService.cpp
@@ -612,14 +612,6 @@ nsPrintSettingsService::ReadPrefs(nsIPrintSettings* aPS,
 
   if (aFlags & nsIPrintSettings::kInitSaveToFileName) {
     if (GETSTRPREF(kPrintToFileName, str)) {
-      if (StringEndsWith(str, NS_LITERAL_STRING(".ps"))) {
-        // We only support PDF since bug 1425188 landed.  Users may still have
-        // prefs with .ps filenames if they last saved a file as Postscript
-        // though, so we fix that up here.  (The pref values will be
-        // overwritten the next time they save to file as a PDF.)
-        str.Truncate(str.Length() - 2);
-        str.AppendLiteral("pdf");
-      }
       aPS->SetToFileName(str);
       DUMP_STR(kReadStr, kPrintToFileName, str.get());
     }
