From fc790462b4f248712bbc8c3734664dd6b05f80f2 Mon Sep 17 00:00:00 2001 From: "avi@chromium.org" Date: Wed, 12 May 2010 19:26:40 +0000 Subject: Set the job name for the print job on the Mac. BUG=http://crbug.com/29188 TEST=as in bug Review URL: http://codereview.chromium.org/1997016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47056 0039d316-1c4b-4281-b951-d872f2087c98 --- printing/printing_context_mac.mm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'printing/printing_context_mac.mm') diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm index c4f09b0..ad09360 100644 --- a/printing/printing_context_mac.mm +++ b/printing/printing_context_mac.mm @@ -29,7 +29,7 @@ PrintingContext::~PrintingContext() { PrintingContext::Result PrintingContext::AskUserForSettings( - gfx::NativeWindow window, int max_pages, bool has_selection) { + gfx::NativeView parent_view, int max_pages, bool has_selection) { DCHECK([NSThread isMainThread]); // We deliberately don't feed max_pages into the dialog, because setting @@ -40,6 +40,7 @@ PrintingContext::Result PrintingContext::AskUserForSettings( // adding a new custom view to the panel on 10.5; 10.6 has // NSPrintPanelShowsPrintSelection). NSPrintPanel* panel = [NSPrintPanel printPanel]; + NSPrintInfo* printInfo = [NSPrintInfo sharedPrintInfo]; NSPrintPanelOptions options = [panel options]; options |= NSPrintPanelShowsPaperSize; @@ -47,10 +48,19 @@ PrintingContext::Result PrintingContext::AskUserForSettings( options |= NSPrintPanelShowsScaling; [panel setOptions:options]; + if (parent_view) { + NSString* job_title = [[parent_view window] title]; + if (job_title) { + PMPrintSettings printSettings = + (PMPrintSettings)[printInfo PMPrintSettings]; + PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title); + [printInfo updateFromPMPrintSettings]; + } + } + // TODO(stuartmorgan): We really want a tab sheet here, not a modal window. // Will require restructuring the PrintingContext API to use a callback. - NSInteger selection = - [panel runModalWithPrintInfo:[NSPrintInfo sharedPrintInfo]]; + NSInteger selection = [panel runModalWithPrintInfo:printInfo]; if (selection != NSOKButton) { return CANCEL; } -- cgit v1.1