| 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 <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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 printer_name, printer_info)); | 503 printer_name, printer_info)); |
| 504 } | 504 } |
| 505 | 505 |
| 506 bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { | 506 bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { |
| 507 return GetPrinterInfo(printer_name, NULL); | 507 return GetPrinterInfo(printer_name, NULL); |
| 508 } | 508 } |
| 509 | 509 |
| 510 bool PrintSystemCUPS::ValidatePrintTicket(const std::string& printer_name, | 510 bool PrintSystemCUPS::ValidatePrintTicket(const std::string& printer_name, |
| 511 const std::string& print_ticket_data) { | 511 const std::string& print_ticket_data) { |
| 512 DCHECK(initialized_); | 512 DCHECK(initialized_); |
| 513 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket_data, | 513 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket_data)); |
| 514 false)); | |
| 515 return ticket_value != NULL && ticket_value->IsType(Value::TYPE_DICTIONARY); | 514 return ticket_value != NULL && ticket_value->IsType(Value::TYPE_DICTIONARY); |
| 516 } | 515 } |
| 517 | 516 |
| 518 // Print ticket on linux is a JSON string containing only one dictionary. | 517 // Print ticket on linux is a JSON string containing only one dictionary. |
| 519 bool PrintSystemCUPS::ParsePrintTicket( | 518 bool PrintSystemCUPS::ParsePrintTicket( |
| 520 const std::string& print_ticket, | 519 const std::string& print_ticket, |
| 521 std::map<std::string, std::string>* options) { | 520 std::map<std::string, std::string>* options) { |
| 522 DCHECK(options); | 521 DCHECK(options); |
| 523 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket, false)); | 522 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket)); |
| 524 if (ticket_value == NULL || !ticket_value->IsType(Value::TYPE_DICTIONARY)) | 523 if (ticket_value == NULL || !ticket_value->IsType(Value::TYPE_DICTIONARY)) |
| 525 return false; | 524 return false; |
| 526 | 525 |
| 527 options->clear(); | 526 options->clear(); |
| 528 DictionaryValue* ticket_dict = | 527 DictionaryValue* ticket_dict = |
| 529 static_cast<DictionaryValue*>(ticket_value.get()); | 528 static_cast<DictionaryValue*>(ticket_value.get()); |
| 530 DictionaryValue::key_iterator it(ticket_dict->begin_keys()); | 529 DictionaryValue::key_iterator it(ticket_dict->begin_keys()); |
| 531 for (; it != ticket_dict->end_keys(); ++it) { | 530 for (; it != ticket_dict->end_keys(); ++it) { |
| 532 const std::string& key = *it; | 531 const std::string& key = *it; |
| 533 std::string value; | 532 std::string value; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 829 |
| 831 void PrintSystemCUPS::RunCapsCallback( | 830 void PrintSystemCUPS::RunCapsCallback( |
| 832 const PrinterCapsAndDefaultsCallback& callback, | 831 const PrinterCapsAndDefaultsCallback& callback, |
| 833 bool succeeded, | 832 bool succeeded, |
| 834 const std::string& printer_name, | 833 const std::string& printer_name, |
| 835 const printing::PrinterCapsAndDefaults& printer_info) { | 834 const printing::PrinterCapsAndDefaults& printer_info) { |
| 836 callback.Run(succeeded, printer_name, printer_info); | 835 callback.Run(succeeded, printer_name, printer_info); |
| 837 } | 836 } |
| 838 | 837 |
| 839 } // namespace cloud_print | 838 } // namespace cloud_print |
| OLD | NEW |