summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 19:26:40 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-12 19:26:40 +0000
commitfc790462b4f248712bbc8c3734664dd6b05f80f2 (patch)
tree4ef04b11c6620ac2c95fb3f87e0d722e7bbcd1ee /printing
parent1d0ee423b6a0bb307c7c19fe28c95d8761691e9a (diff)
downloadchromium_src-fc790462b4f248712bbc8c3734664dd6b05f80f2.zip
chromium_src-fc790462b4f248712bbc8c3734664dd6b05f80f2.tar.gz
chromium_src-fc790462b4f248712bbc8c3734664dd6b05f80f2.tar.bz2
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
Diffstat (limited to 'printing')
-rw-r--r--printing/printing_context.h2
-rw-r--r--printing/printing_context_cairo.cc2
-rw-r--r--printing/printing_context_mac.mm16
-rw-r--r--printing/printing_context_win.cc13
4 files changed, 26 insertions, 7 deletions
diff --git a/printing/printing_context.h b/printing/printing_context.h
index e6efe7e..ec8a7d8 100644
--- a/printing/printing_context.h
+++ b/printing/printing_context.h
@@ -47,7 +47,7 @@ class PrintingContext {
// Asks the user what printer and format should be used to print. Updates the
// context with the select device settings.
- Result AskUserForSettings(gfx::NativeWindow window, int max_pages,
+ Result AskUserForSettings(gfx::NativeView parent_view, int max_pages,
bool has_selection);
// Selects the user's default printer and format. Updates the context with the
diff --git a/printing/printing_context_cairo.cc b/printing/printing_context_cairo.cc
index d0a571f..4d438d1 100644
--- a/printing/printing_context_cairo.cc
+++ b/printing/printing_context_cairo.cc
@@ -23,7 +23,7 @@ PrintingContext::~PrintingContext() {
}
PrintingContext::Result PrintingContext::AskUserForSettings(
- gfx::NativeWindow window,
+ gfx::NativeView parent_view,
int max_pages,
bool has_selection) {
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;
}
diff --git a/printing/printing_context_win.cc b/printing/printing_context_win.cc
index 2142b0f..6215cd4 100644
--- a/printing/printing_context_win.cc
+++ b/printing/printing_context_win.cc
@@ -152,12 +152,21 @@ PrintingContext::~PrintingContext() {
}
PrintingContext::Result PrintingContext::AskUserForSettings(
- HWND window,
+ HWND view,
int max_pages,
bool has_selection) {
- DCHECK(window);
DCHECK(!in_print_job_);
dialog_box_dismissed_ = false;
+
+ HWND window;
+ if (!view || !IsWindow(view)) {
+ // TODO(maruel): bug 1214347 Get the right browser window instead.
+ window = GetDesktopWindow();
+ } else {
+ window = GetAncestor(view, GA_ROOTOWNER);
+ }
+ DCHECK(window);
+
// Show the OS-dependent dialog box.
// If the user press
// - OK, the settings are reset and reinitialized with the new settings. OK is