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 <cups/cups.h> | 7 #include <cups/cups.h> |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <pthread.h> | 10 #include <pthread.h> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 const std::string& print_ticket_data); | 88 const std::string& print_ticket_data); |
89 | 89 |
90 virtual bool GetJobDetails(const std::string& printer_name, | 90 virtual bool GetJobDetails(const std::string& printer_name, |
91 PlatformJobId job_id, | 91 PlatformJobId job_id, |
92 PrintJobDetails *job_details); | 92 PrintJobDetails *job_details); |
93 | 93 |
94 virtual PrintSystem::PrintServerWatcher* CreatePrintServerWatcher(); | 94 virtual PrintSystem::PrintServerWatcher* CreatePrintServerWatcher(); |
95 virtual PrintSystem::PrinterWatcher* CreatePrinterWatcher( | 95 virtual PrintSystem::PrinterWatcher* CreatePrinterWatcher( |
96 const std::string& printer_name); | 96 const std::string& printer_name); |
97 virtual PrintSystem::JobSpooler* CreateJobSpooler(); | 97 virtual PrintSystem::JobSpooler* CreateJobSpooler(); |
98 virtual std::string GetSupportedMimeTypes(); | |
98 | 99 |
99 // Helper functions. | 100 // Helper functions. |
100 PlatformJobId SpoolPrintJob(const std::string& print_ticket, | 101 PlatformJobId SpoolPrintJob(const std::string& print_ticket, |
101 const FilePath& print_data_file_path, | 102 const FilePath& print_data_file_path, |
102 const std::string& print_data_mime_type, | 103 const std::string& print_data_mime_type, |
103 const std::string& printer_name, | 104 const std::string& printer_name, |
104 const std::string& job_title, | 105 const std::string& job_title, |
105 const std::vector<std::string>& tags, | 106 const std::vector<std::string>& tags, |
106 bool* dry_run); | 107 bool* dry_run); |
107 bool GetPrinterInfo(const std::string& printer_name, | 108 bool GetPrinterInfo(const std::string& printer_name, |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 DCHECK(initialized_); | 638 DCHECK(initialized_); |
638 DCHECK(!printer_name.empty()); | 639 DCHECK(!printer_name.empty()); |
639 return new PrinterWatcherCUPS(this, printer_name); | 640 return new PrinterWatcherCUPS(this, printer_name); |
640 } | 641 } |
641 | 642 |
642 PrintSystem::JobSpooler* PrintSystemCUPS::CreateJobSpooler() { | 643 PrintSystem::JobSpooler* PrintSystemCUPS::CreateJobSpooler() { |
643 DCHECK(initialized_); | 644 DCHECK(initialized_); |
644 return new JobSpoolerCUPS(this); | 645 return new JobSpoolerCUPS(this); |
645 } | 646 } |
646 | 647 |
648 std::string PrintSystemCUPS::GetSupportedMimeTypes() { | |
649 // Since we hand off the document to the CUPS server directly, list some types | |
650 // that we know CUPS supports (http://www.cups.org/articles.php?L205+TFAQ+Q) | |
651 // TODO(sanjeevr): Determine this dynamically. | |
Scott Byer
2011/02/17 00:31:02
A bug + link for the TODO?
sanjeevr
2011/02/17 00:53:52
Done.
| |
652 return | |
653 "application/pdf,application/postscript,image/jpeg,image/png,image/gif"; | |
654 } | |
655 | |
647 std::string PrintSystem::GenerateProxyId() { | 656 std::string PrintSystem::GenerateProxyId() { |
648 // TODO(gene): This code should generate a unique id for proxy. ID should be | 657 // TODO(gene): This code should generate a unique id for proxy. ID should be |
649 // unique for this user. Rand may return the same number. We'll need to change | 658 // unique for this user. Rand may return the same number. We'll need to change |
650 // this in the future. | 659 // this in the future. |
651 std::string id("CP_PROXY_"); | 660 std::string id("CP_PROXY_"); |
652 id += base::Uint64ToString(base::RandUint64()); | 661 id += base::Uint64ToString(base::RandUint64()); |
653 return id; | 662 return id; |
654 } | 663 } |
655 | 664 |
656 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 665 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 void PrintSystemCUPS::RunCapsCallback( | 789 void PrintSystemCUPS::RunCapsCallback( |
781 PrinterCapsAndDefaultsCallback* callback, | 790 PrinterCapsAndDefaultsCallback* callback, |
782 bool succeeded, | 791 bool succeeded, |
783 const std::string& printer_name, | 792 const std::string& printer_name, |
784 const printing::PrinterCapsAndDefaults& printer_info) { | 793 const printing::PrinterCapsAndDefaults& printer_info) { |
785 callback->Run(succeeded, printer_name, printer_info); | 794 callback->Run(succeeded, printer_name, printer_info); |
786 delete callback; | 795 delete callback; |
787 } | 796 } |
788 | 797 |
789 } // namespace cloud_print | 798 } // namespace cloud_print |
OLD | NEW |