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

Side by Side Diff: printing/printing_context_mac.mm

Issue 3417025: Printing: Remove the debug-only |page_number_| from PrintingContext, which has (Closed)
Patch Set: Created 10 years, 2 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
« no previous file with comments | « printing/printing_context_cairo.cc ('k') | printing/printing_context_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "printing/printing_context.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"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 12
13 namespace printing { 13 namespace printing {
14 14
15 PrintingContext::PrintingContext() 15 PrintingContext::PrintingContext()
16 : context_(NULL), 16 : context_(NULL),
17 print_info_(nil), 17 print_info_(nil),
18 #ifndef NDEBUG
19 page_number_(-1),
20 #endif
21 dialog_box_dismissed_(false), 18 dialog_box_dismissed_(false),
22 in_print_job_(false), 19 in_print_job_(false),
23 abort_printing_(false) { 20 abort_printing_(false) {
24 } 21 }
25 22
26 PrintingContext::~PrintingContext() { 23 PrintingContext::~PrintingContext() {
27 ResetSettings(); 24 ResetSettings();
28 } 25 }
29 26
30 27
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 104
108 NOTIMPLEMENTED(); 105 NOTIMPLEMENTED();
109 106
110 return FAILED; 107 return FAILED;
111 } 108 }
112 109
113 void PrintingContext::ResetSettings() { 110 void PrintingContext::ResetSettings() {
114 [print_info_ autorelease]; 111 [print_info_ autorelease];
115 print_info_ = nil; 112 print_info_ = nil;
116 settings_.Clear(); 113 settings_.Clear();
117 #ifndef NDEBUG
118 page_number_ = -1;
119 #endif
120 dialog_box_dismissed_ = false; 114 dialog_box_dismissed_ = false;
121 abort_printing_ = false; 115 abort_printing_ = false;
122 in_print_job_ = false; 116 in_print_job_ = false;
123 context_ = NULL; 117 context_ = NULL;
124 } 118 }
125 119
126 PrintingContext::Result PrintingContext::NewDocument( 120 PrintingContext::Result PrintingContext::NewDocument(
127 const string16& document_name) { 121 const string16& document_name) {
128 DCHECK(!in_print_job_); 122 DCHECK(!in_print_job_);
129 123
130 in_print_job_ = true; 124 in_print_job_ = true;
131 125
132 PMPrintSession print_session = 126 PMPrintSession print_session =
133 static_cast<PMPrintSession>([print_info_ PMPrintSession]); 127 static_cast<PMPrintSession>([print_info_ PMPrintSession]);
134 PMPrintSettings print_settings = 128 PMPrintSettings print_settings =
135 static_cast<PMPrintSettings>([print_info_ PMPrintSettings]); 129 static_cast<PMPrintSettings>([print_info_ PMPrintSettings]);
136 PMPageFormat page_format = 130 PMPageFormat page_format =
137 static_cast<PMPageFormat>([print_info_ PMPageFormat]); 131 static_cast<PMPageFormat>([print_info_ PMPageFormat]);
138 132
139 scoped_cftyperef<CFStringRef> job_title( 133 scoped_cftyperef<CFStringRef> job_title(
140 base::SysUTF16ToCFStringRef(document_name)); 134 base::SysUTF16ToCFStringRef(document_name));
141 PMPrintSettingsSetJobName(print_settings, job_title.get()); 135 PMPrintSettingsSetJobName(print_settings, job_title.get());
142 136
143 OSStatus status = PMSessionBeginCGDocumentNoDialog(print_session, 137 OSStatus status = PMSessionBeginCGDocumentNoDialog(print_session,
144 print_settings, 138 print_settings,
145 page_format); 139 page_format);
146 if (status != noErr) 140 if (status != noErr)
147 return OnError(); 141 return OnError();
148 142
149 #ifndef NDEBUG
150 page_number_ = 0;
151 #endif
152
153 return OK; 143 return OK;
154 } 144 }
155 145
156 PrintingContext::Result PrintingContext::NewPage() { 146 PrintingContext::Result PrintingContext::NewPage() {
157 if (abort_printing_) 147 if (abort_printing_)
158 return CANCEL; 148 return CANCEL;
159 DCHECK(in_print_job_); 149 DCHECK(in_print_job_);
160 DCHECK(!context_); 150 DCHECK(!context_);
161 151
162 PMPrintSession print_session = 152 PMPrintSession print_session =
163 static_cast<PMPrintSession>([print_info_ PMPrintSession]); 153 static_cast<PMPrintSession>([print_info_ PMPrintSession]);
164 PMPageFormat page_format = 154 PMPageFormat page_format =
165 static_cast<PMPageFormat>([print_info_ PMPageFormat]); 155 static_cast<PMPageFormat>([print_info_ PMPageFormat]);
166 OSStatus status; 156 OSStatus status;
167 status = PMSessionBeginPageNoDialog(print_session, page_format, NULL); 157 status = PMSessionBeginPageNoDialog(print_session, page_format, NULL);
168 if (status != noErr) 158 if (status != noErr)
169 return OnError(); 159 return OnError();
170 status = PMSessionGetCGGraphicsContext(print_session, &context_); 160 status = PMSessionGetCGGraphicsContext(print_session, &context_);
171 if (status != noErr) 161 if (status != noErr)
172 return OnError(); 162 return OnError();
173 163
174 #ifndef NDEBUG
175 ++page_number_;
176 #endif
177
178 return OK; 164 return OK;
179 } 165 }
180 166
181 PrintingContext::Result PrintingContext::PageDone() { 167 PrintingContext::Result PrintingContext::PageDone() {
182 if (abort_printing_) 168 if (abort_printing_)
183 return CANCEL; 169 return CANCEL;
184 DCHECK(in_print_job_); 170 DCHECK(in_print_job_);
185 DCHECK(context_); 171 DCHECK(context_);
186 172
187 PMPrintSession print_session = 173 PMPrintSession print_session =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void PrintingContext::DismissDialog() { 208 void PrintingContext::DismissDialog() {
223 NOTIMPLEMENTED(); 209 NOTIMPLEMENTED();
224 } 210 }
225 211
226 PrintingContext::Result PrintingContext::OnError() { 212 PrintingContext::Result PrintingContext::OnError() {
227 ResetSettings(); 213 ResetSettings();
228 return abort_printing_ ? CANCEL : FAILED; 214 return abort_printing_ ? CANCEL : FAILED;
229 } 215 }
230 216
231 } // namespace printing 217 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printing_context_cairo.cc ('k') | printing/printing_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698