| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/win/object_watcher.h" | 14 #include "base/win/object_watcher.h" |
| 14 #include "base/win/scoped_bstr.h" | 15 #include "base/win/scoped_bstr.h" |
| 15 #include "base/win/scoped_comptr.h" | 16 #include "base/win/scoped_comptr.h" |
| 16 #include "base/win/scoped_hdc.h" | 17 #include "base/win/scoped_hdc.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/cloud_print/cloud_print_cdd_conversion.h" | 19 #include "chrome/common/cloud_print/cloud_print_cdd_conversion.h" |
| 19 #include "chrome/common/cloud_print/cloud_print_constants.h" | 20 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 new ServiceUtilityProcessHost(this, client_task_runner.get())); | 429 new ServiceUtilityProcessHost(this, client_task_runner.get())); |
| 429 // TODO(gene): For now we disabling autorotation for CloudPrinting. | 430 // TODO(gene): For now we disabling autorotation for CloudPrinting. |
| 430 // Landscape/Portrait setting is passed in the print ticket and | 431 // Landscape/Portrait setting is passed in the print ticket and |
| 431 // server is generating portrait PDF always. | 432 // server is generating portrait PDF always. |
| 432 // We should enable autorotation once server will be able to generate | 433 // We should enable autorotation once server will be able to generate |
| 433 // PDF that matches paper size and orientation. | 434 // PDF that matches paper size and orientation. |
| 434 if (utility_host->StartRenderPDFPagesToMetafile( | 435 if (utility_host->StartRenderPDFPagesToMetafile( |
| 435 pdf_path, | 436 pdf_path, |
| 436 printing::PdfRenderSettings(render_area, render_dpi, false))) { | 437 printing::PdfRenderSettings(render_area, render_dpi, false))) { |
| 437 // The object will self-destruct when the child process dies. | 438 // The object will self-destruct when the child process dies. |
| 438 utility_host.release(); | 439 ignore_result(utility_host.release()); |
| 439 } else { | 440 } else { |
| 440 client_task_runner->PostTask( | 441 client_task_runner->PostTask( |
| 441 FROM_HERE, base::Bind(&Core::PrintJobDone, this, false)); | 442 FROM_HERE, base::Bind(&Core::PrintJobDone, this, false)); |
| 442 } | 443 } |
| 443 } | 444 } |
| 444 | 445 |
| 445 bool PrintXPSDocument(const std::string& printer_name, | 446 bool PrintXPSDocument(const std::string& printer_name, |
| 446 const std::string& job_title, | 447 const std::string& job_title, |
| 447 const base::FilePath& print_data_file_path, | 448 const base::FilePath& print_data_file_path, |
| 448 const std::string& print_ticket) { | 449 const std::string& print_ticket) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 private: | 569 private: |
| 569 ~PrinterCapsHandler() override {} | 570 ~PrinterCapsHandler() override {} |
| 570 | 571 |
| 571 void GetPrinterCapsAndDefaultsImpl( | 572 void GetPrinterCapsAndDefaultsImpl( |
| 572 const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { | 573 const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { |
| 573 DCHECK(g_service_process->io_task_runner()->BelongsToCurrentThread()); | 574 DCHECK(g_service_process->io_task_runner()->BelongsToCurrentThread()); |
| 574 scoped_ptr<ServiceUtilityProcessHost> utility_host( | 575 scoped_ptr<ServiceUtilityProcessHost> utility_host( |
| 575 new ServiceUtilityProcessHost(this, client_task_runner.get())); | 576 new ServiceUtilityProcessHost(this, client_task_runner.get())); |
| 576 if (utility_host->StartGetPrinterCapsAndDefaults(printer_name_)) { | 577 if (utility_host->StartGetPrinterCapsAndDefaults(printer_name_)) { |
| 577 // The object will self-destruct when the child process dies. | 578 // The object will self-destruct when the child process dies. |
| 578 utility_host.release(); | 579 ignore_result(utility_host.release()); |
| 579 } else { | 580 } else { |
| 580 client_task_runner->PostTask( | 581 client_task_runner->PostTask( |
| 581 FROM_HERE, base::Bind(&PrinterCapsHandler::OnChildDied, this)); | 582 FROM_HERE, base::Bind(&PrinterCapsHandler::OnChildDied, this)); |
| 582 } | 583 } |
| 583 } | 584 } |
| 584 | 585 |
| 585 void GetPrinterSemanticCapsAndDefaultsImpl( | 586 void GetPrinterSemanticCapsAndDefaultsImpl( |
| 586 const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { | 587 const scoped_refptr<base::SingleThreadTaskRunner>& client_task_runner) { |
| 587 DCHECK(g_service_process->io_task_runner()->BelongsToCurrentThread()); | 588 DCHECK(g_service_process->io_task_runner()->BelongsToCurrentThread()); |
| 588 scoped_ptr<ServiceUtilityProcessHost> utility_host( | 589 scoped_ptr<ServiceUtilityProcessHost> utility_host( |
| 589 new ServiceUtilityProcessHost(this, client_task_runner.get())); | 590 new ServiceUtilityProcessHost(this, client_task_runner.get())); |
| 590 if (utility_host->StartGetPrinterSemanticCapsAndDefaults(printer_name_)) { | 591 if (utility_host->StartGetPrinterSemanticCapsAndDefaults(printer_name_)) { |
| 591 // The object will self-destruct when the child process dies. | 592 // The object will self-destruct when the child process dies. |
| 592 utility_host.release(); | 593 ignore_result(utility_host.release()); |
| 593 } else { | 594 } else { |
| 594 client_task_runner->PostTask( | 595 client_task_runner->PostTask( |
| 595 FROM_HERE, base::Bind(&PrinterCapsHandler::OnChildDied, this)); | 596 FROM_HERE, base::Bind(&PrinterCapsHandler::OnChildDied, this)); |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 | 599 |
| 599 std::string printer_name_; | 600 std::string printer_name_; |
| 600 PrintSystem::PrinterCapsAndDefaultsCallback callback_; | 601 PrintSystem::PrinterCapsAndDefaultsCallback callback_; |
| 601 }; | 602 }; |
| 602 | 603 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 } | 811 } |
| 811 | 812 |
| 812 } // namespace | 813 } // namespace |
| 813 | 814 |
| 814 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 815 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 815 const base::DictionaryValue* print_system_settings) { | 816 const base::DictionaryValue* print_system_settings) { |
| 816 return new PrintSystemWin; | 817 return new PrintSystemWin; |
| 817 } | 818 } |
| 818 | 819 |
| 819 } // namespace cloud_print | 820 } // namespace cloud_print |
| OLD | NEW |