| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // the number of requests. | 65 // the number of requests. |
| 66 typedef std::map<std::string, printing::PrinterCapsAndDefaults> CapsMap; | 66 typedef std::map<std::string, printing::PrinterCapsAndDefaults> CapsMap; |
| 67 CapsMap caps_cache; | 67 CapsMap caps_cache; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 class PrintSystemCUPS : public PrintSystem { | 70 class PrintSystemCUPS : public PrintSystem { |
| 71 public: | 71 public: |
| 72 explicit PrintSystemCUPS(const DictionaryValue* print_system_settings); | 72 explicit PrintSystemCUPS(const DictionaryValue* print_system_settings); |
| 73 | 73 |
| 74 // PrintSystem implementation. | 74 // PrintSystem implementation. |
| 75 virtual void Init(); | 75 virtual PrintSystemResult Init(); |
| 76 | 76 |
| 77 virtual void EnumeratePrinters(printing::PrinterList* printer_list); | 77 virtual void EnumeratePrinters(printing::PrinterList* printer_list); |
| 78 | 78 |
| 79 virtual void GetPrinterCapsAndDefaults( | 79 virtual void GetPrinterCapsAndDefaults( |
| 80 const std::string& printer_name, | 80 const std::string& printer_name, |
| 81 PrinterCapsAndDefaultsCallback* callback); | 81 PrinterCapsAndDefaultsCallback* callback); |
| 82 | 82 |
| 83 virtual bool IsValidPrinter(const std::string& printer_name); | 83 virtual bool IsValidPrinter(const std::string& printer_name); |
| 84 | 84 |
| 85 virtual bool ValidatePrintTicket(const std::string& printer_name, | 85 virtual bool ValidatePrintTicket(const std::string& printer_name, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 backend_settings.SetString(kCUPSBlocking, kValueFalse); | 398 backend_settings.SetString(kCUPSBlocking, kValueFalse); |
| 399 | 399 |
| 400 PrintServerInfoCUPS print_server; | 400 PrintServerInfoCUPS print_server; |
| 401 print_server.backend = | 401 print_server.backend = |
| 402 printing::PrintBackend::CreateInstance(&backend_settings); | 402 printing::PrintBackend::CreateInstance(&backend_settings); |
| 403 print_server.url = GURL(url.c_str()); | 403 print_server.url = GURL(url.c_str()); |
| 404 | 404 |
| 405 print_servers_.push_back(print_server); | 405 print_servers_.push_back(print_server); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void PrintSystemCUPS::Init() { | 408 PrintSystem::PrintSystemResult PrintSystemCUPS::Init() { |
| 409 UpdatePrinters(); | 409 UpdatePrinters(); |
| 410 initialized_ = true; | 410 initialized_ = true; |
| 411 return PrintSystemResult(true, std::string()); |
| 411 } | 412 } |
| 412 | 413 |
| 413 void PrintSystemCUPS::UpdatePrinters() { | 414 void PrintSystemCUPS::UpdatePrinters() { |
| 414 PrintServerList::iterator it; | 415 PrintServerList::iterator it; |
| 415 for (it = print_servers_.begin(); it != print_servers_.end(); ++it) { | 416 for (it = print_servers_.begin(); it != print_servers_.end(); ++it) { |
| 416 it->backend->EnumeratePrinters(&it->printers); | 417 it->backend->EnumeratePrinters(&it->printers); |
| 417 it->caps_cache.clear(); | 418 it->caps_cache.clear(); |
| 418 printing::PrinterList::iterator printer_it; | 419 printing::PrinterList::iterator printer_it; |
| 419 for (printer_it = it->printers.begin(); | 420 for (printer_it = it->printers.begin(); |
| 420 printer_it != it->printers.end(); ++printer_it) { | 421 printer_it != it->printers.end(); ++printer_it) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 void PrintSystemCUPS::RunCapsCallback( | 767 void PrintSystemCUPS::RunCapsCallback( |
| 767 PrinterCapsAndDefaultsCallback* callback, | 768 PrinterCapsAndDefaultsCallback* callback, |
| 768 bool succeeded, | 769 bool succeeded, |
| 769 const std::string& printer_name, | 770 const std::string& printer_name, |
| 770 const printing::PrinterCapsAndDefaults& printer_info) { | 771 const printing::PrinterCapsAndDefaults& printer_info) { |
| 771 callback->Run(succeeded, printer_name, printer_info); | 772 callback->Run(succeeded, printer_name, printer_info); |
| 772 delete callback; | 773 delete callback; |
| 773 } | 774 } |
| 774 | 775 |
| 775 } // namespace cloud_print | 776 } // namespace cloud_print |
| OLD | NEW |