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

Side by Side Diff: printing/printing_context_win.cc

Issue 3292019: Printing: Convert several wstrings to string16. (Closed)
Patch Set: Review fixes. Created 10 years, 3 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_mac.mm ('k') | no next file » | 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 #include <winspool.h> 7 #include <winspool.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/i18n/file_util_icu.h" 10 #include "base/i18n/file_util_icu.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/utf_string_conversions.h"
14 #include "printing/printed_document.h" 15 #include "printing/printed_document.h"
15 #include "skia/ext/platform_device_win.h" 16 #include "skia/ext/platform_device_win.h"
16 17
17 using base::Time; 18 using base::Time;
18 19
19 namespace printing { 20 namespace printing {
20 21
21 class PrintingContext::CallbackHandler : public IPrintDialogCallback, 22 class PrintingContext::CallbackHandler : public IPrintDialogCallback,
22 public IObjectWithSite { 23 public IObjectWithSite {
23 public: 24 public:
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 240 }
240 settings_.Clear(); 241 settings_.Clear();
241 in_print_job_ = false; 242 in_print_job_ = false;
242 243
243 #ifndef NDEBUG 244 #ifndef NDEBUG
244 page_number_ = -1; 245 page_number_ = -1;
245 #endif 246 #endif
246 } 247 }
247 248
248 PrintingContext::Result PrintingContext::NewDocument( 249 PrintingContext::Result PrintingContext::NewDocument(
249 const std::wstring& document_name) { 250 const string16& document_name) {
250 DCHECK(!in_print_job_); 251 DCHECK(!in_print_job_);
251 if (!context_) 252 if (!context_)
252 return OnError(); 253 return OnError();
253 254
254 // Set the flag used by the AbortPrintJob dialog procedure. 255 // Set the flag used by the AbortPrintJob dialog procedure.
255 abort_printing_ = false; 256 abort_printing_ = false;
256 257
257 in_print_job_ = true; 258 in_print_job_ = true;
258 259
259 // Register the application's AbortProc function with GDI. 260 // Register the application's AbortProc function with GDI.
260 if (SP_ERROR == SetAbortProc(context_, &AbortProc)) 261 if (SP_ERROR == SetAbortProc(context_, &AbortProc))
261 return OnError(); 262 return OnError();
262 263
263 DOCINFO di = { sizeof(DOCINFO) }; 264 DOCINFO di = { sizeof(DOCINFO) };
264 di.lpszDocName = document_name.c_str(); 265 di.lpszDocName = UTF16ToWide(document_name).c_str();
265 266
266 // Is there a debug dump directory specified? If so, force to print to a file. 267 // Is there a debug dump directory specified? If so, force to print to a file.
267 std::wstring debug_dump_path = PrintedDocument::debug_dump_path(); 268 FilePath debug_dump_path = PrintedDocument::debug_dump_path();
268 if (!debug_dump_path.empty()) { 269 if (!debug_dump_path.empty()) {
269 // Create a filename. 270 // Create a filename.
270 std::wstring filename; 271 std::wstring filename;
271 Time now(Time::Now()); 272 Time now(Time::Now());
272 filename = base::TimeFormatShortDateNumeric(now); 273 filename = base::TimeFormatShortDateNumeric(now);
273 filename += L"_"; 274 filename += L"_";
274 filename += base::TimeFormatTimeOfDay(now); 275 filename += base::TimeFormatTimeOfDay(now);
275 filename += L"_"; 276 filename += L"_";
276 filename += document_name; 277 filename += UTF16ToWide(document_name);
277 filename += L"_"; 278 filename += L"_";
278 filename += L"buffer.prn"; 279 filename += L"buffer.prn";
279 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); 280 file_util::ReplaceIllegalCharactersInPath(&filename, '_');
280 file_util::AppendToPath(&debug_dump_path, filename); 281 debug_dump_path.Append(filename);
281 di.lpszOutput = debug_dump_path.c_str(); 282 di.lpszOutput = debug_dump_path.value().c_str();
282 } 283 }
283 284
284 // No message loop running in unit tests. 285 // No message loop running in unit tests.
285 DCHECK(!MessageLoop::current() ? true : 286 DCHECK(!MessageLoop::current() ? true :
286 !MessageLoop::current()->NestableTasksAllowed()); 287 !MessageLoop::current()->NestableTasksAllowed());
287 288
288 // Begin a print job by calling the StartDoc function. 289 // Begin a print job by calling the StartDoc function.
289 // NOTE: StartDoc() starts a message loop. That causes a lot of problems with 290 // NOTE: StartDoc() starts a message loop. That causes a lot of problems with
290 // IPC. Make sure recursive task processing is disabled. 291 // IPC. Make sure recursive task processing is disabled.
291 if (StartDoc(context_, &di) <= 0) 292 if (StartDoc(context_, &di) <= 0)
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (buf_size) { 611 if (buf_size) {
611 buffer->reset(new uint8[buf_size]); 612 buffer->reset(new uint8[buf_size]);
612 memset(buffer->get(), 0, buf_size); 613 memset(buffer->get(), 0, buf_size);
613 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { 614 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) {
614 buffer->reset(); 615 buffer->reset();
615 } 616 }
616 } 617 }
617 } 618 }
618 619
619 } // namespace printing 620 } // namespace printing
OLDNEW
« no previous file with comments | « printing/printing_context_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698