OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 493 |
494 bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { | 494 bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { |
495 return GetPrinterInfo(printer_name, NULL); | 495 return GetPrinterInfo(printer_name, NULL); |
496 } | 496 } |
497 | 497 |
498 bool PrintSystemCUPS::ValidatePrintTicket(const std::string& printer_name, | 498 bool PrintSystemCUPS::ValidatePrintTicket(const std::string& printer_name, |
499 const std::string& print_ticket_data) { | 499 const std::string& print_ticket_data) { |
500 DCHECK(initialized_); | 500 DCHECK(initialized_); |
501 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket_data, | 501 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket_data, |
502 false)); | 502 false)); |
503 return ticket_value != NULL && ticket_value->IsType(Value::TYPE_DICTIONARY); | 503 return ticket_value != NULL && ticket_value->IsDictionary(); |
504 } | 504 } |
505 | 505 |
506 // Print ticket on linux is a JSON string containing only one dictionary. | 506 // Print ticket on linux is a JSON string containing only one dictionary. |
507 bool PrintSystemCUPS::ParsePrintTicket(const std::string& print_ticket, | 507 bool PrintSystemCUPS::ParsePrintTicket(const std::string& print_ticket, |
508 std::map<std::string, std::string>* options) { | 508 std::map<std::string, std::string>* options) { |
509 DCHECK(options); | 509 DCHECK(options); |
510 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket, false)); | 510 scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket, false)); |
511 if (ticket_value == NULL || !ticket_value->IsType(Value::TYPE_DICTIONARY)) | 511 if (ticket_value == NULL || !ticket_value->IsDictionary()) |
512 return false; | 512 return false; |
513 | 513 |
514 options->clear(); | 514 options->clear(); |
515 DictionaryValue* ticket_dict = | 515 DictionaryValue* ticket_dict = |
516 static_cast<DictionaryValue*>(ticket_value.get()); | 516 static_cast<DictionaryValue*>(ticket_value.get()); |
517 DictionaryValue::key_iterator it(ticket_dict->begin_keys()); | 517 DictionaryValue::key_iterator it(ticket_dict->begin_keys()); |
518 for (; it != ticket_dict->end_keys(); ++it) { | 518 for (; it != ticket_dict->end_keys(); ++it) { |
519 const std::string& key = *it; | 519 const std::string& key = *it; |
520 std::string value; | 520 std::string value; |
521 if (ticket_dict->GetString(key, &value)) { | 521 if (ticket_dict->GetString(key, &value)) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 void PrintSystemCUPS::RunCapsCallback( | 811 void PrintSystemCUPS::RunCapsCallback( |
812 PrinterCapsAndDefaultsCallback* callback, | 812 PrinterCapsAndDefaultsCallback* callback, |
813 bool succeeded, | 813 bool succeeded, |
814 const std::string& printer_name, | 814 const std::string& printer_name, |
815 const printing::PrinterCapsAndDefaults& printer_info) { | 815 const printing::PrinterCapsAndDefaults& printer_info) { |
816 callback->Run(succeeded, printer_name, printer_info); | 816 callback->Run(succeeded, printer_name, printer_info); |
817 delete callback; | 817 delete callback; |
818 } | 818 } |
819 | 819 |
820 } // namespace cloud_print | 820 } // namespace cloud_print |
OLD | NEW |