| 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> |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <list> | 13 #include <list> |
| 14 #include <map> | 14 #include <map> |
| 15 | 15 |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/file_path.h" | 17 #include "base/file_path.h" |
| 18 #include "base/json/json_reader.h" | 18 #include "base/json/json_reader.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/md5.h" | 20 #include "base/md5.h" |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
| 23 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 24 #include "base/string_number_conversions.h" | 24 #include "base/string_number_conversions.h" |
| 25 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 27 #include "base/values.h" | 27 #include "base/values.h" |
| 28 #include "chrome/common/child_process_logging.h" | 28 #include "chrome/common/child_process_logging.h" |
| 29 #include "chrome/service/cloud_print/cloud_print_consts.h" | 29 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 30 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 30 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 31 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 33 #include "printing/backend/cups_helper.h" | 33 #include "printing/backend/cups_helper.h" |
| 34 #include "printing/backend/print_backend.h" | 34 #include "printing/backend/print_backend.h" |
| 35 #include "printing/backend/print_backend_consts.h" | 35 #include "printing/backend/print_backend_consts.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 server_info->backend->GetPrinterDriverInfo(printer_name)); | 779 server_info->backend->GetPrinterDriverInfo(printer_name)); |
| 780 | 780 |
| 781 // We need to store options as char* string for the duration of the | 781 // We need to store options as char* string for the duration of the |
| 782 // cupsPrintFile2 call. We'll use map here to store options, since | 782 // cupsPrintFile2 call. We'll use map here to store options, since |
| 783 // Dictionary value from JSON parser returns wchat_t. | 783 // Dictionary value from JSON parser returns wchat_t. |
| 784 std::map<std::string, std::string> options; | 784 std::map<std::string, std::string> options; |
| 785 bool res = ParsePrintTicket(print_ticket, &options); | 785 bool res = ParsePrintTicket(print_ticket, &options); |
| 786 DCHECK(res); // If print ticket is invalid we still print using defaults. | 786 DCHECK(res); // If print ticket is invalid we still print using defaults. |
| 787 | 787 |
| 788 // Check if this is a dry run (test) job. | 788 // Check if this is a dry run (test) job. |
| 789 *dry_run = CloudPrintHelpers::IsDryRunJob(tags); | 789 *dry_run = IsDryRunJob(tags); |
| 790 if (*dry_run) { | 790 if (*dry_run) { |
| 791 VLOG(1) << "CP_CUPS: Dry run job spooled"; | 791 VLOG(1) << "CP_CUPS: Dry run job spooled"; |
| 792 return kDryRunJobId; | 792 return kDryRunJobId; |
| 793 } | 793 } |
| 794 | 794 |
| 795 std::vector<cups_option_t> cups_options; | 795 std::vector<cups_option_t> cups_options; |
| 796 std::map<std::string, std::string>::iterator it; | 796 std::map<std::string, std::string>::iterator it; |
| 797 | 797 |
| 798 for (it = options.begin(); it != options.end(); ++it) { | 798 for (it = options.begin(); it != options.end(); ++it) { |
| 799 cups_option_t opt; | 799 cups_option_t opt; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 | 864 |
| 865 void PrintSystemCUPS::RunCapsCallback( | 865 void PrintSystemCUPS::RunCapsCallback( |
| 866 const PrinterCapsAndDefaultsCallback& callback, | 866 const PrinterCapsAndDefaultsCallback& callback, |
| 867 bool succeeded, | 867 bool succeeded, |
| 868 const std::string& printer_name, | 868 const std::string& printer_name, |
| 869 const printing::PrinterCapsAndDefaults& printer_info) { | 869 const printing::PrinterCapsAndDefaults& printer_info) { |
| 870 callback.Run(succeeded, printer_name, printer_info); | 870 callback.Run(succeeded, printer_name, printer_info); |
| 871 } | 871 } |
| 872 | 872 |
| 873 } // namespace cloud_print | 873 } // namespace cloud_print |
| OLD | NEW |