OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/printing/win_printing_context.h" | 5 #include "chrome/browser/printing/win_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/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "base/time_format.h" | 12 #include "base/time_format.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/printing/print_job_manager.h" | 14 #include "chrome/browser/printing/printed_document.h" |
15 #include "skia/ext/platform_device_win.h" | 15 #include "skia/ext/platform_device_win.h" |
16 | 16 |
17 using base::Time; | 17 using base::Time; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Retrieves the content of a GetPrinter call. | 21 // Retrieves the content of a GetPrinter call. |
22 void GetPrinterHelper(HANDLE printer, int level, scoped_array<uint8>* buffer) { | 22 void GetPrinterHelper(HANDLE printer, int level, scoped_array<uint8>* buffer) { |
23 DWORD buf_size = 0; | 23 DWORD buf_size = 0; |
24 GetPrinter(printer, level, NULL, 0, &buf_size); | 24 GetPrinter(printer, level, NULL, 0, &buf_size); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 in_print_job_ = true; | 265 in_print_job_ = true; |
266 | 266 |
267 // Register the application's AbortProc function with GDI. | 267 // Register the application's AbortProc function with GDI. |
268 if (SP_ERROR == SetAbortProc(hdc_, &AbortProc)) | 268 if (SP_ERROR == SetAbortProc(hdc_, &AbortProc)) |
269 return OnError(); | 269 return OnError(); |
270 | 270 |
271 DOCINFO di = { sizeof(DOCINFO) }; | 271 DOCINFO di = { sizeof(DOCINFO) }; |
272 di.lpszDocName = document_name.c_str(); | 272 di.lpszDocName = document_name.c_str(); |
273 | 273 |
274 // Is there a debug dump directory specified? If so, force to print to a file. | 274 // Is there a debug dump directory specified? If so, force to print to a file. |
275 std::wstring debug_dump_path; | 275 std::wstring debug_dump_path = PrintedDocument::debug_dump_path(); |
276 if (!g_browser_process || !g_browser_process->print_job_manager()) { | |
277 // Happens only inside a unit test. | |
278 debug_dump_path = L"."; | |
279 } else { | |
280 debug_dump_path = g_browser_process->print_job_manager()->debug_dump_path(); | |
281 } | |
282 | |
283 if (!debug_dump_path.empty()) { | 276 if (!debug_dump_path.empty()) { |
284 // Create a filename. | 277 // Create a filename. |
285 std::wstring filename; | 278 std::wstring filename; |
286 Time now(Time::Now()); | 279 Time now(Time::Now()); |
287 filename = base::TimeFormatShortDateNumeric(now); | 280 filename = base::TimeFormatShortDateNumeric(now); |
288 filename += L"_"; | 281 filename += L"_"; |
289 filename += base::TimeFormatTimeOfDay(now); | 282 filename += base::TimeFormatTimeOfDay(now); |
290 filename += L"_"; | 283 filename += L"_"; |
291 filename += document_name; | 284 filename += document_name; |
292 filename += L"_"; | 285 filename += L"_"; |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 | 599 |
607 if (dialog_options.hDevMode != NULL) | 600 if (dialog_options.hDevMode != NULL) |
608 GlobalFree(dialog_options.hDevMode); | 601 GlobalFree(dialog_options.hDevMode); |
609 if (dialog_options.hDevNames != NULL) | 602 if (dialog_options.hDevNames != NULL) |
610 GlobalFree(dialog_options.hDevNames); | 603 GlobalFree(dialog_options.hDevNames); |
611 | 604 |
612 return hdc_ ? OK : FAILED; | 605 return hdc_ ? OK : FAILED; |
613 } | 606 } |
614 | 607 |
615 } // namespace printing | 608 } // namespace printing |
OLD | NEW |