OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 DCHECK(CurrentlyOnServiceIOThread()); | 438 DCHECK(CurrentlyOnServiceIOThread()); |
439 std::unique_ptr<ServiceUtilityProcessHost> utility_host( | 439 std::unique_ptr<ServiceUtilityProcessHost> utility_host( |
440 new ServiceUtilityProcessHost(this, client_task_runner.get())); | 440 new ServiceUtilityProcessHost(this, client_task_runner.get())); |
441 // TODO(gene): For now we disabling autorotation for CloudPrinting. | 441 // TODO(gene): For now we disabling autorotation for CloudPrinting. |
442 // Landscape/Portrait setting is passed in the print ticket and | 442 // Landscape/Portrait setting is passed in the print ticket and |
443 // server is generating portrait PDF always. | 443 // server is generating portrait PDF always. |
444 // We should enable autorotation once server will be able to generate | 444 // We should enable autorotation once server will be able to generate |
445 // PDF that matches paper size and orientation. | 445 // PDF that matches paper size and orientation. |
446 if (utility_host->StartRenderPDFPagesToMetafile( | 446 if (utility_host->StartRenderPDFPagesToMetafile( |
447 pdf_path, printing::PdfRenderSettings( | 447 pdf_path, printing::PdfRenderSettings( |
448 render_area, gfx::Point(0,0), render_dpi, | 448 render_area, gfx::Point(0, 0), render_dpi, |
449 /*autorotate=*/false, | 449 /*autorotate=*/false, |
450 printing::PdfRenderSettings::Mode::NORMAL))) { | 450 printing::PdfRenderSettings::Mode::NORMAL))) { |
451 // The object will self-destruct when the child process dies. | 451 // The object will self-destruct when the child process dies. |
452 ignore_result(utility_host.release()); | 452 ignore_result(utility_host.release()); |
453 } else { | 453 } else { |
454 client_task_runner->PostTask( | 454 client_task_runner->PostTask( |
455 FROM_HERE, base::Bind(&Core::PrintJobDone, this, false)); | 455 FROM_HERE, base::Bind(&Core::PrintJobDone, this, false)); |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 kPTJobScope, | 749 kPTJobScope, |
750 result_ticket_stream.get(), | 750 result_ticket_stream.get(), |
751 error.Receive())); | 751 error.Receive())); |
752 printing::XPSModule::CloseProvider(provider); | 752 printing::XPSModule::CloseProvider(provider); |
753 } | 753 } |
754 return ret; | 754 return ret; |
755 } | 755 } |
756 | 756 |
757 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, | 757 bool PrintSystemWin::GetJobDetails(const std::string& printer_name, |
758 PlatformJobId job_id, | 758 PlatformJobId job_id, |
759 PrintJobDetails *job_details) { | 759 PrintJobDetails* job_details) { |
760 crash_keys::ScopedPrinterInfo crash_key( | 760 crash_keys::ScopedPrinterInfo crash_key( |
761 print_backend_->GetPrinterDriverInfo(printer_name)); | 761 print_backend_->GetPrinterDriverInfo(printer_name)); |
762 DCHECK(job_details); | 762 DCHECK(job_details); |
763 printing::ScopedPrinterHandle printer_handle; | 763 printing::ScopedPrinterHandle printer_handle; |
764 std::wstring printer_name_wide = base::UTF8ToWide(printer_name); | 764 std::wstring printer_name_wide = base::UTF8ToWide(printer_name); |
765 printer_handle.OpenPrinter(printer_name_wide.c_str()); | 765 printer_handle.OpenPrinter(printer_name_wide.c_str()); |
766 DCHECK(printer_handle.IsValid()); | 766 DCHECK(printer_handle.IsValid()); |
767 bool ret = false; | 767 bool ret = false; |
768 if (printer_handle.IsValid()) { | 768 if (printer_handle.IsValid()) { |
769 DWORD bytes_needed = 0; | 769 DWORD bytes_needed = 0; |
770 GetJob(printer_handle.Get(), job_id, 1, NULL, 0, &bytes_needed); | 770 GetJob(printer_handle.Get(), job_id, 1, NULL, 0, &bytes_needed); |
771 DWORD last_error = GetLastError(); | 771 DWORD last_error = GetLastError(); |
772 if (ERROR_INVALID_PARAMETER != last_error) { | 772 if (ERROR_INVALID_PARAMETER != last_error) { |
773 // ERROR_INVALID_PARAMETER normally means that the job id is not valid. | 773 // ERROR_INVALID_PARAMETER normally means that the job id is not valid. |
774 DCHECK(last_error == ERROR_INSUFFICIENT_BUFFER); | 774 DCHECK(last_error == ERROR_INSUFFICIENT_BUFFER); |
775 std::unique_ptr<BYTE[]> job_info_buffer(new BYTE[bytes_needed]); | 775 std::unique_ptr<BYTE[]> job_info_buffer(new BYTE[bytes_needed]); |
776 if (GetJob(printer_handle.Get(), job_id, 1, job_info_buffer.get(), | 776 if (GetJob(printer_handle.Get(), job_id, 1, job_info_buffer.get(), |
777 bytes_needed, &bytes_needed)) { | 777 bytes_needed, &bytes_needed)) { |
778 JOB_INFO_1 *job_info = | 778 JOB_INFO_1* job_info = |
779 reinterpret_cast<JOB_INFO_1 *>(job_info_buffer.get()); | 779 reinterpret_cast<JOB_INFO_1*>(job_info_buffer.get()); |
780 if (job_info->pStatus) { | 780 if (job_info->pStatus) { |
781 base::WideToUTF8(job_info->pStatus, wcslen(job_info->pStatus), | 781 base::WideToUTF8(job_info->pStatus, wcslen(job_info->pStatus), |
782 &job_details->status_message); | 782 &job_details->status_message); |
783 } | 783 } |
784 job_details->platform_status_flags = job_info->Status; | 784 job_details->platform_status_flags = job_info->Status; |
785 if ((job_info->Status & JOB_STATUS_COMPLETE) || | 785 if ((job_info->Status & JOB_STATUS_COMPLETE) || |
786 (job_info->Status & JOB_STATUS_PRINTED)) { | 786 (job_info->Status & JOB_STATUS_PRINTED)) { |
787 job_details->status = PRINT_JOB_STATUS_COMPLETED; | 787 job_details->status = PRINT_JOB_STATUS_COMPLETED; |
788 } else if (job_info->Status & JOB_STATUS_ERROR) { | 788 } else if (job_info->Status & JOB_STATUS_ERROR) { |
789 job_details->status = PRINT_JOB_STATUS_ERROR; | 789 job_details->status = PRINT_JOB_STATUS_ERROR; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } | 834 } |
835 | 835 |
836 } // namespace | 836 } // namespace |
837 | 837 |
838 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 838 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
839 const base::DictionaryValue* print_system_settings) { | 839 const base::DictionaryValue* print_system_settings) { |
840 return new PrintSystemWin; | 840 return new PrintSystemWin; |
841 } | 841 } |
842 | 842 |
843 } // namespace cloud_print | 843 } // namespace cloud_print |
OLD | NEW |