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 | 9 |
| 10 #include "app/l10n_util.h" |
10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.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/service/cloud_print/cloud_print_consts.h" | 18 #include "chrome/service/cloud_print/cloud_print_consts.h" |
18 #include "chrome/service/service_process.h" | 19 #include "chrome/service/service_process.h" |
19 #include "chrome/service/service_utility_process_host.h" | 20 #include "chrome/service/service_utility_process_host.h" |
20 #include "gfx/rect.h" | 21 #include "gfx/rect.h" |
| 22 #include "grit/generated_resources.h" |
21 #include "printing/backend/print_backend.h" | 23 #include "printing/backend/print_backend.h" |
22 #include "printing/backend/print_backend_consts.h" | 24 #include "printing/backend/print_backend_consts.h" |
23 #include "printing/backend/win_helper.h" | 25 #include "printing/backend/win_helper.h" |
24 #include "printing/native_metafile.h" | 26 #include "printing/native_metafile.h" |
25 #include "printing/page_range.h" | 27 #include "printing/page_range.h" |
26 | 28 |
27 using base::win::ScopedBstr; | 29 using base::win::ScopedBstr; |
28 using base::win::ScopedComPtr; | 30 using base::win::ScopedComPtr; |
29 | 31 |
30 namespace { | 32 namespace { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Visual Studio where it gets confused between multiple Delegate. | 241 // Visual Studio where it gets confused between multiple Delegate. |
240 // In this case, some compilers get confused and inherit | 242 // In this case, some compilers get confused and inherit |
241 // PrintSystemWin watchers from wrong Delegate, giving C2664 and C2259 errors. | 243 // PrintSystemWin watchers from wrong Delegate, giving C2664 and C2259 errors. |
242 typedef PrintSystemWatcherWin::Delegate PrintSystemWatcherWinDelegate; | 244 typedef PrintSystemWatcherWin::Delegate PrintSystemWatcherWinDelegate; |
243 | 245 |
244 class PrintSystemWin : public PrintSystem { | 246 class PrintSystemWin : public PrintSystem { |
245 public: | 247 public: |
246 PrintSystemWin(); | 248 PrintSystemWin(); |
247 | 249 |
248 // PrintSystem implementation. | 250 // PrintSystem implementation. |
249 virtual void Init(); | 251 virtual PrintSystemResult Init(); |
250 | 252 |
251 virtual void EnumeratePrinters(printing::PrinterList* printer_list); | 253 virtual void EnumeratePrinters(printing::PrinterList* printer_list); |
252 | 254 |
253 virtual void GetPrinterCapsAndDefaults( | 255 virtual void GetPrinterCapsAndDefaults( |
254 const std::string& printer_name, | 256 const std::string& printer_name, |
255 PrinterCapsAndDefaultsCallback* callback); | 257 PrinterCapsAndDefaultsCallback* callback); |
256 | 258 |
257 virtual bool IsValidPrinter(const std::string& printer_name); | 259 virtual bool IsValidPrinter(const std::string& printer_name); |
258 | 260 |
259 virtual bool ValidatePrintTicket(const std::string& printer_name, | 261 virtual bool ValidatePrintTicket(const std::string& printer_name, |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 virtual PrintSystem::JobSpooler* CreateJobSpooler(); | 589 virtual PrintSystem::JobSpooler* CreateJobSpooler(); |
588 | 590 |
589 private: | 591 private: |
590 scoped_refptr<printing::PrintBackend> print_backend_; | 592 scoped_refptr<printing::PrintBackend> print_backend_; |
591 }; | 593 }; |
592 | 594 |
593 PrintSystemWin::PrintSystemWin() { | 595 PrintSystemWin::PrintSystemWin() { |
594 print_backend_ = printing::PrintBackend::CreateInstance(NULL); | 596 print_backend_ = printing::PrintBackend::CreateInstance(NULL); |
595 } | 597 } |
596 | 598 |
597 void PrintSystemWin::Init() { | 599 PrintSystem::PrintSystemResult PrintSystemWin::Init() { |
| 600 if (!printing::XPSModule::Init()) { |
| 601 std::string message = l10n_util::GetStringUTF8( |
| 602 IDS_CLOUD_PRINT_XPS_UNAVAILABLE); |
| 603 return PrintSystemResult(false, message); |
| 604 } |
| 605 return PrintSystemResult(true, std::string()); |
598 } | 606 } |
599 | 607 |
600 void PrintSystemWin::EnumeratePrinters(printing::PrinterList* printer_list) { | 608 void PrintSystemWin::EnumeratePrinters(printing::PrinterList* printer_list) { |
601 print_backend_->EnumeratePrinters(printer_list); | 609 print_backend_->EnumeratePrinters(printer_list); |
602 } | 610 } |
603 | 611 |
604 void PrintSystemWin::GetPrinterCapsAndDefaults( | 612 void PrintSystemWin::GetPrinterCapsAndDefaults( |
605 const std::string& printer_name, | 613 const std::string& printer_name, |
606 PrinterCapsAndDefaultsCallback* callback) { | 614 PrinterCapsAndDefaultsCallback* callback) { |
607 // Launch as child process to retrieve the capabilities and defaults because | 615 // Launch as child process to retrieve the capabilities and defaults because |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); | 737 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); |
730 return ret; | 738 return ret; |
731 } | 739 } |
732 | 740 |
733 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 741 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
734 const DictionaryValue* print_system_settings) { | 742 const DictionaryValue* print_system_settings) { |
735 return new PrintSystemWin; | 743 return new PrintSystemWin; |
736 } | 744 } |
737 | 745 |
738 } // namespace cloud_print | 746 } // namespace cloud_print |
OLD | NEW |