| 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 "app/l10n_util.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // PrintSystemWin watchers from wrong Delegate, giving C2664 and C2259 errors. | 243 // PrintSystemWin watchers from wrong Delegate, giving C2664 and C2259 errors. |
| 244 typedef PrintSystemWatcherWin::Delegate PrintSystemWatcherWinDelegate; | 244 typedef PrintSystemWatcherWin::Delegate PrintSystemWatcherWinDelegate; |
| 245 | 245 |
| 246 class PrintSystemWin : public PrintSystem { | 246 class PrintSystemWin : public PrintSystem { |
| 247 public: | 247 public: |
| 248 PrintSystemWin(); | 248 PrintSystemWin(); |
| 249 | 249 |
| 250 // PrintSystem implementation. | 250 // PrintSystem implementation. |
| 251 virtual PrintSystemResult Init(); | 251 virtual PrintSystemResult Init(); |
| 252 | 252 |
| 253 virtual void EnumeratePrinters(printing::PrinterList* printer_list); | 253 virtual PrintSystem::PrintSystemResult EnumeratePrinters( |
| 254 printing::PrinterList* printer_list); |
| 254 | 255 |
| 255 virtual void GetPrinterCapsAndDefaults( | 256 virtual void GetPrinterCapsAndDefaults( |
| 256 const std::string& printer_name, | 257 const std::string& printer_name, |
| 257 PrinterCapsAndDefaultsCallback* callback); | 258 PrinterCapsAndDefaultsCallback* callback); |
| 258 | 259 |
| 259 virtual bool IsValidPrinter(const std::string& printer_name); | 260 virtual bool IsValidPrinter(const std::string& printer_name); |
| 260 | 261 |
| 261 virtual bool ValidatePrintTicket(const std::string& printer_name, | 262 virtual bool ValidatePrintTicket(const std::string& printer_name, |
| 262 const std::string& print_ticket_data); | 263 const std::string& print_ticket_data); |
| 263 | 264 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 599 |
| 599 PrintSystem::PrintSystemResult PrintSystemWin::Init() { | 600 PrintSystem::PrintSystemResult PrintSystemWin::Init() { |
| 600 if (!printing::XPSModule::Init()) { | 601 if (!printing::XPSModule::Init()) { |
| 601 std::string message = l10n_util::GetStringUTF8( | 602 std::string message = l10n_util::GetStringUTF8( |
| 602 IDS_CLOUD_PRINT_XPS_UNAVAILABLE); | 603 IDS_CLOUD_PRINT_XPS_UNAVAILABLE); |
| 603 return PrintSystemResult(false, message); | 604 return PrintSystemResult(false, message); |
| 604 } | 605 } |
| 605 return PrintSystemResult(true, std::string()); | 606 return PrintSystemResult(true, std::string()); |
| 606 } | 607 } |
| 607 | 608 |
| 608 void PrintSystemWin::EnumeratePrinters(printing::PrinterList* printer_list) { | 609 PrintSystem::PrintSystemResult PrintSystemWin::EnumeratePrinters( |
| 609 print_backend_->EnumeratePrinters(printer_list); | 610 printing::PrinterList* printer_list) { |
| 611 bool ret = print_backend_->EnumeratePrinters(printer_list); |
| 612 std::string message; |
| 613 if (!ret) |
| 614 message = l10n_util::GetStringUTF8(IDS_CLOUD_PRINT_ENUM_FAILED); |
| 615 return PrintSystemResult(ret, message); |
| 610 } | 616 } |
| 611 | 617 |
| 612 void PrintSystemWin::GetPrinterCapsAndDefaults( | 618 void PrintSystemWin::GetPrinterCapsAndDefaults( |
| 613 const std::string& printer_name, | 619 const std::string& printer_name, |
| 614 PrinterCapsAndDefaultsCallback* callback) { | 620 PrinterCapsAndDefaultsCallback* callback) { |
| 615 // Launch as child process to retrieve the capabilities and defaults because | 621 // Launch as child process to retrieve the capabilities and defaults because |
| 616 // this involves invoking a printer driver DLL and crashes have been known to | 622 // this involves invoking a printer driver DLL and crashes have been known to |
| 617 // occur. | 623 // occur. |
| 618 PrinterCapsHandler* handler = | 624 PrinterCapsHandler* handler = |
| 619 new PrinterCapsHandler(printer_name, callback); | 625 new PrinterCapsHandler(printer_name, callback); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); | 743 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); |
| 738 return ret; | 744 return ret; |
| 739 } | 745 } |
| 740 | 746 |
| 741 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 747 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
| 742 const DictionaryValue* print_system_settings) { | 748 const DictionaryValue* print_system_settings) { |
| 743 return new PrintSystemWin; | 749 return new PrintSystemWin; |
| 744 } | 750 } |
| 745 | 751 |
| 746 } // namespace cloud_print | 752 } // namespace cloud_print |
| OLD | NEW |