summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
Diffstat (limited to 'printing')
-rw-r--r--printing/print_job_constants.cc4
-rw-r--r--printing/print_job_constants.h5
-rw-r--r--printing/printing_context_mac.h4
-rw-r--r--printing/printing_context_mac.mm16
4 files changed, 29 insertions, 0 deletions
diff --git a/printing/print_job_constants.cc b/printing/print_job_constants.cc
index adebd14..c671326 100644
--- a/printing/print_job_constants.cc
+++ b/printing/print_job_constants.cc
@@ -123,6 +123,10 @@ const char kSettingPrintToPDF[] = "printToPDF";
const int FIRST_PAGE_INDEX = 0;
const int COMPLETE_PREVIEW_DOCUMENT_INDEX = -1;
+#if defined(OS_MACOSX)
+const char kSettingOpenPDFInPreview[] = "OpenPDFInPreview";
+#endif
+
#if defined (USE_CUPS)
const char kBlack[] = "Black";
const char kCMYK[] = "CMYK";
diff --git a/printing/print_job_constants.h b/printing/print_job_constants.h
index a44fcbf..cd6aa93 100644
--- a/printing/print_job_constants.h
+++ b/printing/print_job_constants.h
@@ -5,6 +5,7 @@
#ifndef PRINTING_PRINT_JOB_CONSTANTS_H_
#define PRINTING_PRINT_JOB_CONSTANTS_H_
+#include "build/build_config.h"
#include "printing/printing_export.h"
namespace printing {
@@ -49,6 +50,10 @@ PRINTING_EXPORT extern const char kSettingPrintToPDF[];
PRINTING_EXPORT extern const int FIRST_PAGE_INDEX;
PRINTING_EXPORT extern const int COMPLETE_PREVIEW_DOCUMENT_INDEX;
+#if defined(OS_MACOSX)
+PRINTING_EXPORT extern const char kSettingOpenPDFInPreview[];
+#endif // defined(OS_MACOSX)
+
#if defined (USE_CUPS)
// Printer color models
PRINTING_EXPORT extern const char kBlack[];
diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h
index e44c118..e9cad8f 100644
--- a/printing/printing_context_mac.h
+++ b/printing/printing_context_mac.h
@@ -61,6 +61,10 @@ class PRINTING_EXPORT PrintingContextMac : public PrintingContext {
// Returns true if the paper was set else returns false.
bool UpdatePageFormatWithPaperInfo();
+ // Sets the print job destination type as preview job.
+ // Returns true if the print job destination type is set.
+ bool SetPrintPreviewJob();
+
// Sets |copies| in PMPrintSettings.
// Returns true if the number of copies is set.
bool SetCopiesInPrintSettings(int copies);
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
index 5b11c18..9c56ace 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -124,6 +124,7 @@ PrintingContext::Result PrintingContextMac::UpdatePrinterSettings(
}
bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId);
+ bool open_pdf_in_preview = job_settings.HasKey(kSettingOpenPDFInPreview);
if (!print_to_pdf && !print_to_cloud && !is_cloud_dialog) {
if (!SetPrinter(device_name))
@@ -143,6 +144,11 @@ PrintingContext::Result PrintingContextMac::UpdatePrinterSettings(
if (!SetOutputColor(color))
return OnError();
}
+ if (open_pdf_in_preview) {
+ if (!SetPrintPreviewJob())
+ return OnError();
+ }
+
if (!UpdatePageFormatWithPaperInfo())
return OnError();
@@ -155,6 +161,16 @@ PrintingContext::Result PrintingContextMac::UpdatePrinterSettings(
return OK;
}
+bool PrintingContextMac::SetPrintPreviewJob() {
+ PMPrintSession print_session =
+ static_cast<PMPrintSession>([print_info_.get() PMPrintSession]);
+ PMPrintSettings print_settings =
+ static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
+ return PMSessionSetDestination(
+ print_session, print_settings, kPMDestinationPreview,
+ NULL, NULL) == noErr;
+}
+
void PrintingContextMac::InitPrintSettingsFromPrintInfo(
const PageRanges& ranges) {
PMPrintSession print_session =