Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: printing/printing_context_mac.mm

Issue 6775013: PrintPreview: While printing the preview data, set the initiator tab title as print job name. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated the CL. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« printing/printing_context_mac.h ('K') | « printing/printing_context_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printing_context_mac.mm
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
index cf6ea9f9498ed8fe18d04a2fe565fd0d8824037b..275e210fc79d9e7a2899b6854b475e2e4178e2f3 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -53,15 +53,8 @@ void PrintingContextMac::AskUserForSettings(gfx::NativeView parent_view,
[panel setOptions:options];
// Set the print job title text.
- 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];
- }
- }
+ if (parent_view)
+ UpdatePrintInfoWithJobName(printInfo, [[parent_view window] title]);
// TODO(stuartmorgan): We really want a tab sheet here, not a modal window.
// Will require restructuring the PrintingContext API to use a callback.
@@ -104,6 +97,13 @@ PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
if (!SetPrinter(printer_name))
return OnError();
+ string16 job_name;
+ if (!job_settings.GetString(kSettingPrintJobTitle, &job_name))
+ return OnError();
stuartmorgan 2011/03/30 22:59:17 It's not clear to me that not having/setting a job
+
+ if (!SetPrintJobName(job_name))
+ return OnError();
+
InitPrintSettingsFromPrintInfo(ranges);
return OK;
}
@@ -135,6 +135,23 @@ bool PrintingContextMac::SetPrinter(const std::string& printer_name) {
return true;
}
+bool PrintingContextMac::SetPrintJobName(const string16& job_name) {
+ NSString* print_job_name = base::SysUTF16ToNSString(job_name);
stuartmorgan 2011/03/30 22:59:17 Indentation is wrong here.
+ if (!print_job_name)
+ return false;
+ UpdatePrintInfoWithJobName(print_info_.get(), print_job_name);
+ return true;
+}
+
+void PrintingContextMac::UpdatePrintInfoWithJobName(
+ NSPrintInfo* printInfo, NSString* job_name) {
+ if (job_name) {
stuartmorgan 2011/03/30 22:59:17 Change to if (!job_name) return; so the core
+ PMPrintSettings settings = (PMPrintSettings)[printInfo PMPrintSettings];
+ PMPrintSettingsSetJobName(settings, (CFStringRef)job_name);
+ [printInfo updateFromPMPrintSettings];
+ }
+}
+
void PrintingContextMac::ParsePrintInfo(NSPrintInfo* print_info) {
ResetSettings();
print_info_.reset([print_info retain]);
« printing/printing_context_mac.h ('K') | « printing/printing_context_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698