| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/service/cloud_print/print_system.h" | 5 #include "chrome/service/cloud_print/print_system.h" |
| 6 | 6 |
| 7 #include <objidl.h> | 7 #include <objidl.h> |
| 8 #include <winspool.h> | 8 #include <winspool.h> |
| 9 #if defined(_WIN32_WINNT) | 9 #if defined(_WIN32_WINNT) |
| 10 #undef _WIN32_WINNT | 10 #undef _WIN32_WINNT |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 last_page_printed_ = highest_rendered_page_number; | 457 last_page_printed_ = highest_rendered_page_number; |
| 458 if (done_printing) | 458 if (done_printing) |
| 459 PrintJobDone(); | 459 PrintJobDone(); |
| 460 else | 460 else |
| 461 RenderNextPDFPages(); | 461 RenderNextPDFPages(); |
| 462 } | 462 } |
| 463 | 463 |
| 464 // base::win::ObjectWatcher::Delegate inplementation. | 464 // base::win::ObjectWatcher::Delegate inplementation. |
| 465 virtual void OnObjectSignaled(HANDLE object) { | 465 virtual void OnObjectSignaled(HANDLE object) { |
| 466 DCHECK(xps_print_job_); | 466 DCHECK(xps_print_job_); |
| 467 DCHECK(object == job_progress_event_.Get()); |
| 468 ResetEvent(job_progress_event_.Get()); |
| 467 if (!delegate_) | 469 if (!delegate_) |
| 468 return; | 470 return; |
| 469 XPS_JOB_STATUS job_status = {0}; | 471 XPS_JOB_STATUS job_status = {0}; |
| 470 xps_print_job_->GetJobStatus(&job_status); | 472 xps_print_job_->GetJobStatus(&job_status); |
| 471 bool done = false; | 473 bool done = false; |
| 472 if ((job_status.completion == XPS_JOB_CANCELLED) || | 474 if ((job_status.completion == XPS_JOB_CANCELLED) || |
| 473 (job_status.completion == XPS_JOB_FAILED)) { | 475 (job_status.completion == XPS_JOB_FAILED)) { |
| 474 delegate_->OnJobSpoolFailed(); | 476 delegate_->OnJobSpoolFailed(); |
| 475 done = true; | 477 done = true; |
| 476 } else if (job_status.jobId) { | 478 } else if (job_status.jobId || |
| 479 (job_status.completion == XPS_JOB_COMPLETED)) { |
| 480 // Note: In the case of the XPS document being printed to the |
| 481 // Microsoft XPS Document Writer, it seems to skip spooling the job |
| 482 // and goes to the completed state without ever assigning a job id. |
| 477 delegate_->OnJobSpoolSucceeded(job_status.jobId); | 483 delegate_->OnJobSpoolSucceeded(job_status.jobId); |
| 478 done = true; | 484 done = true; |
| 479 } else { | 485 } else { |
| 480 ResetEvent(job_progress_event_.Get()); | |
| 481 job_progress_watcher_.StopWatching(); | 486 job_progress_watcher_.StopWatching(); |
| 482 job_progress_watcher_.StartWatching(job_progress_event_.Get(), this); | 487 job_progress_watcher_.StartWatching(job_progress_event_.Get(), this); |
| 483 } | 488 } |
| 484 if (done && should_couninit_) { | 489 if (done && should_couninit_) { |
| 485 CoUninitialize(); | 490 CoUninitialize(); |
| 486 should_couninit_ = false; | 491 should_couninit_ = false; |
| 487 } | 492 } |
| 488 } | 493 } |
| 489 | 494 |
| 490 virtual void OnRenderPDFPagesToMetafileFailed() { | 495 virtual void OnRenderPDFPagesToMetafileFailed() { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 NULL, | 778 NULL, |
| 774 kPTJobScope, | 779 kPTJobScope, |
| 775 result_ticket_stream.get(), | 780 result_ticket_stream.get(), |
| 776 error.Receive())); | 781 error.Receive())); |
| 777 printing::XPSModule::CloseProvider(provider); | 782 printing::XPSModule::CloseProvider(provider); |
| 778 } | 783 } |
| 779 return ret; | 784 return ret; |
| 780 } | 785 } |
| 781 | 786 |
| 782 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, | 787 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, |
| 783 PlatformJobId job_id, | 788 PlatformJobId job_id, |
| 784 PrintJobDetails *job_details) { | 789 PrintJobDetails *job_details) { |
| 785 DCHECK(job_details); | 790 DCHECK(job_details); |
| 786 HANDLE printer_handle = NULL; | 791 HANDLE printer_handle = NULL; |
| 787 std::wstring printer_name_wide = UTF8ToWide(printer_name); | 792 std::wstring printer_name_wide = UTF8ToWide(printer_name); |
| 788 OpenPrinter(const_cast<LPTSTR>(printer_name_wide.c_str()), &printer_handle, | 793 OpenPrinter(const_cast<LPTSTR>(printer_name_wide.c_str()), &printer_handle, |
| 789 NULL); | 794 NULL); |
| 790 DCHECK(printer_handle); | 795 DCHECK(printer_handle); |
| 791 bool ret = false; | 796 bool ret = false; |
| 792 if (printer_handle) { | 797 if (printer_handle) { |
| 793 DWORD bytes_needed = 0; | 798 DWORD bytes_needed = 0; |
| 794 GetJob(printer_handle, job_id, 1, NULL, 0, &bytes_needed); | 799 GetJob(printer_handle, job_id, 1, NULL, 0, &bytes_needed); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); | 864 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); |
| 860 return ret; | 865 return ret; |
| 861 } | 866 } |
| 862 | 867 |
| 863 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 868 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 864 const DictionaryValue* print_system_settings) { | 869 const DictionaryValue* print_system_settings) { |
| 865 return new PrintSystemWin; | 870 return new PrintSystemWin; |
| 866 } | 871 } |
| 867 | 872 |
| 868 } // namespace cloud_print | 873 } // namespace cloud_print |
| OLD | NEW |