summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorkmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-17 00:44:37 +0000
committerkmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-17 00:44:37 +0000
commit97c29575ab1cc3b1bcb53449c3d9627ee1382d04 (patch)
tree1633e14bbcc4cdb0c451a93c1982ddcd3b03ecad /printing
parent1bf1b92d64df4e58c7f9b17285fc67ad4025feb2 (diff)
downloadchromium_src-97c29575ab1cc3b1bcb53449c3d9627ee1382d04.zip
chromium_src-97c29575ab1cc3b1bcb53449c3d9627ee1382d04.tar.gz
chromium_src-97c29575ab1cc3b1bcb53449c3d9627ee1382d04.tar.bz2
PrintPreview:[MAC] Added "Open PDF In Preview" option to open the pdf in native preview app.
BUG=101724 TEST=Preview a webpage. Click "Open PDF In Preview" option Observe that the pdf is displayed in native preview app. Complete the printing workflow by clicking "Print" or "Cancel" button at the bottom of the preview app. Review URL: http://codereview.chromium.org/8425008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110398 0039d316-1c4b-4281-b951-d872f2087c98
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 =