| 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 if (!job_progress_event_.Get()) | 470 if (!job_progress_event_.Get()) |
| 471 return false; | 471 return false; |
| 472 | 472 |
| 473 PrintJobCanceler job_canceler(&xps_print_job_); | 473 PrintJobCanceler job_canceler(&xps_print_job_); |
| 474 base::win::ScopedComPtr<IXpsPrintJobStream> doc_stream; | 474 base::win::ScopedComPtr<IXpsPrintJobStream> doc_stream; |
| 475 base::win::ScopedComPtr<IXpsPrintJobStream> print_ticket_stream; | 475 base::win::ScopedComPtr<IXpsPrintJobStream> print_ticket_stream; |
| 476 if (FAILED(printing::XPSPrintModule::StartXpsPrintJob( | 476 if (FAILED(printing::XPSPrintModule::StartXpsPrintJob( |
| 477 base::UTF8ToWide(printer_name).c_str(), | 477 base::UTF8ToWide(printer_name).c_str(), |
| 478 base::UTF8ToWide(job_title).c_str(), nullptr, | 478 base::UTF8ToWide(job_title).c_str(), nullptr, |
| 479 job_progress_event_.Get(), nullptr, nullptr, 0, | 479 job_progress_event_.Get(), nullptr, nullptr, 0, |
| 480 xps_print_job_.Receive(), doc_stream.Receive(), | 480 xps_print_job_.GetAddressOf(), doc_stream.GetAddressOf(), |
| 481 print_ticket_stream.Receive()))) { | 481 print_ticket_stream.GetAddressOf()))) { |
| 482 return false; | 482 return false; |
| 483 } | 483 } |
| 484 | 484 |
| 485 ULONG print_bytes_written = 0; | 485 ULONG print_bytes_written = 0; |
| 486 if (FAILED(print_ticket_stream->Write(print_ticket.c_str(), | 486 if (FAILED(print_ticket_stream->Write(print_ticket.c_str(), |
| 487 print_ticket.length(), | 487 print_ticket.length(), |
| 488 &print_bytes_written))) { | 488 &print_bytes_written))) { |
| 489 return false; | 489 return false; |
| 490 } | 490 } |
| 491 DCHECK_EQ(print_ticket.length(), print_bytes_written); | 491 DCHECK_EQ(print_ticket.length(), print_bytes_written); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 if (!xps_initializer.initialized()) { | 723 if (!xps_initializer.initialized()) { |
| 724 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) | 724 // TODO(sanjeevr): Handle legacy proxy case (with no prntvpt.dll) |
| 725 return false; | 725 return false; |
| 726 } | 726 } |
| 727 bool ret = false; | 727 bool ret = false; |
| 728 HPTPROVIDER provider = NULL; | 728 HPTPROVIDER provider = NULL; |
| 729 printing::XPSModule::OpenProvider(base::UTF8ToWide(printer_name), 1, | 729 printing::XPSModule::OpenProvider(base::UTF8ToWide(printer_name), 1, |
| 730 &provider); | 730 &provider); |
| 731 if (provider) { | 731 if (provider) { |
| 732 base::win::ScopedComPtr<IStream> print_ticket_stream; | 732 base::win::ScopedComPtr<IStream> print_ticket_stream; |
| 733 CreateStreamOnHGlobal(NULL, TRUE, print_ticket_stream.Receive()); | 733 CreateStreamOnHGlobal(NULL, TRUE, print_ticket_stream.GetAddressOf()); |
| 734 ULONG bytes_written = 0; | 734 ULONG bytes_written = 0; |
| 735 print_ticket_stream->Write(print_ticket_data.c_str(), | 735 print_ticket_stream->Write(print_ticket_data.c_str(), |
| 736 print_ticket_data.length(), | 736 print_ticket_data.length(), |
| 737 &bytes_written); | 737 &bytes_written); |
| 738 DCHECK(bytes_written == print_ticket_data.length()); | 738 DCHECK(bytes_written == print_ticket_data.length()); |
| 739 LARGE_INTEGER pos = {}; | 739 LARGE_INTEGER pos = {}; |
| 740 ULARGE_INTEGER new_pos = {}; | 740 ULARGE_INTEGER new_pos = {}; |
| 741 print_ticket_stream->Seek(pos, STREAM_SEEK_SET, &new_pos); | 741 print_ticket_stream->Seek(pos, STREAM_SEEK_SET, &new_pos); |
| 742 base::win::ScopedBstr error; | 742 base::win::ScopedBstr error; |
| 743 base::win::ScopedComPtr<IStream> result_ticket_stream; | 743 base::win::ScopedComPtr<IStream> result_ticket_stream; |
| 744 CreateStreamOnHGlobal(NULL, TRUE, result_ticket_stream.Receive()); | 744 CreateStreamOnHGlobal(NULL, TRUE, result_ticket_stream.GetAddressOf()); |
| 745 ret = SUCCEEDED(printing::XPSModule::MergeAndValidatePrintTicket( | 745 ret = SUCCEEDED(printing::XPSModule::MergeAndValidatePrintTicket( |
| 746 provider, | 746 provider, |
| 747 print_ticket_stream.Get(), | 747 print_ticket_stream.Get(), |
| 748 NULL, | 748 NULL, |
| 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; |
| (...skipping 79 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 |