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

Side by Side Diff: printing/printing_context_mac.mm

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Changes based on Kausalya's comments Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/printing_context_mac.h" 5 #include "printing/printing_context_mac.h"
6 6
7 #import <ApplicationServices/ApplicationServices.h> 7 #import <ApplicationServices/ApplicationServices.h>
8 #import <AppKit/AppKit.h> 8 #import <AppKit/AppKit.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title); 75 PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title);
76 [printInfo updateFromPMPrintSettings]; 76 [printInfo updateFromPMPrintSettings];
77 } 77 }
78 } 78 }
79 79
80 // TODO(stuartmorgan): We really want a tab sheet here, not a modal window. 80 // TODO(stuartmorgan): We really want a tab sheet here, not a modal window.
81 // Will require restructuring the PrintingContext API to use a callback. 81 // Will require restructuring the PrintingContext API to use a callback.
82 NSInteger selection = [panel runModalWithPrintInfo:printInfo]; 82 NSInteger selection = [panel runModalWithPrintInfo:printInfo];
83 if (selection == NSOKButton) { 83 if (selection == NSOKButton) {
84 print_info_.reset([[panel printInfo] retain]); 84 print_info_.reset([[panel printInfo] retain]);
85 InitPrintSettingsFromPrintInfo(GetPageRangesFromPrintInfo()); 85 DictionaryValue header_footer_info;
86 header_footer_info.SetBoolean(printing::kSettingHeaderFooterEnabled,
87 false);
88 InitPrintSettingsFromPrintInfo(GetPageRangesFromPrintInfo(),
89 header_footer_info);
86 callback->Run(OK); 90 callback->Run(OK);
87 } else { 91 } else {
88 callback->Run(CANCEL); 92 callback->Run(CANCEL);
89 } 93 }
90 } 94 }
91 95
92 PrintingContext::Result PrintingContextMac::UseDefaultSettings() { 96 PrintingContext::Result PrintingContextMac::UseDefaultSettings() {
93 DCHECK(!in_print_job_); 97 DCHECK(!in_print_job_);
94 98
95 print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]); 99 print_info_.reset([[NSPrintInfo sharedPrintInfo] copy]);
96 InitPrintSettingsFromPrintInfo(GetPageRangesFromPrintInfo()); 100 DictionaryValue header_footer_info;
101 header_footer_info.SetBoolean(printing::kSettingHeaderFooterEnabled,
kmadhusu 2011/08/12 20:27:11 nit: If possible, have a function that populates t
Aayush Kumar 2011/08/13 04:04:53 Done.
102 false);
103 InitPrintSettingsFromPrintInfo(GetPageRangesFromPrintInfo(),
104 header_footer_info);
97 105
98 return OK; 106 return OK;
99 } 107 }
100 108
101 PrintingContext::Result PrintingContextMac::UpdatePrintSettings( 109 PrintingContext::Result PrintingContextMac::UpdatePrintSettings(
102 const DictionaryValue& job_settings, const PageRanges& ranges) { 110 const DictionaryValue& job_settings, const PageRanges& ranges) {
103 DCHECK(!in_print_job_); 111 DCHECK(!in_print_job_);
104 112
105 // NOTE: Reset |print_info_| with a copy of |sharedPrintInfo| so as to start 113 // NOTE: Reset |print_info_| with a copy of |sharedPrintInfo| so as to start
106 // with a clean slate. 114 // with a clean slate.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 151
144 if (!SetOutputIsColor(color)) 152 if (!SetOutputIsColor(color))
145 return OnError(); 153 return OnError();
146 } 154 }
147 155
148 if (!SetOrientationIsLandscape(landscape)) 156 if (!SetOrientationIsLandscape(landscape))
149 return OnError(); 157 return OnError();
150 158
151 [print_info_.get() updateFromPMPrintSettings]; 159 [print_info_.get() updateFromPMPrintSettings];
152 160
153 InitPrintSettingsFromPrintInfo(ranges); 161 DictionaryValue header_footer_info;
162 GetHeaderFooterInfo(job_settings, &header_footer_info);
163
164 InitPrintSettingsFromPrintInfo(ranges, header_footer_info);
154 return OK; 165 return OK;
155 } 166 }
156 167
157 void PrintingContextMac::InitPrintSettingsFromPrintInfo( 168 void PrintingContextMac::InitPrintSettingsFromPrintInfo(
158 const PageRanges& ranges) { 169 const PageRanges& ranges,
170 const DictionaryValue& header_footer_info) {
159 PMPrintSession print_session = 171 PMPrintSession print_session =
160 static_cast<PMPrintSession>([print_info_.get() PMPrintSession]); 172 static_cast<PMPrintSession>([print_info_.get() PMPrintSession]);
161 PMPageFormat page_format = 173 PMPageFormat page_format =
162 static_cast<PMPageFormat>([print_info_.get() PMPageFormat]); 174 static_cast<PMPageFormat>([print_info_.get() PMPageFormat]);
163 PMPrinter printer; 175 PMPrinter printer;
164 PMSessionGetCurrentPrinter(print_session, &printer); 176 PMSessionGetCurrentPrinter(print_session, &printer);
165 PrintSettingsInitializerMac::InitPrintSettings( 177 PrintSettingsInitializerMac::InitPrintSettings(
166 printer, page_format, ranges, false, &settings_); 178 printer, page_format, ranges, false, &settings_);
167 } 179 }
168 180
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void PrintingContextMac::ReleaseContext() { 382 void PrintingContextMac::ReleaseContext() {
371 print_info_.reset(); 383 print_info_.reset();
372 context_ = NULL; 384 context_ = NULL;
373 } 385 }
374 386
375 gfx::NativeDrawingContext PrintingContextMac::context() const { 387 gfx::NativeDrawingContext PrintingContextMac::context() const {
376 return context_; 388 return context_;
377 } 389 }
378 390
379 } // namespace printing 391 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698