| 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/printer_job_handler.h" | 5 #include "chrome/service/cloud_print/printer_job_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/md5.h" | 11 #include "base/md5.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/common/cloud_print/cloud_print_helpers.h" | 15 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
| 16 #include "chrome/service/cloud_print/cloud_print_consts.h" | 16 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 17 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 17 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 18 #include "chrome/service/cloud_print/job_status_updater.h" | 18 #include "chrome/service/cloud_print/job_status_updater.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "grit/generated_resources.h" |
| 20 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
| 21 #include "net/http/http_status_code.h" | 22 #include "net/http/http_status_code.h" |
| 23 #include "printing/backend/print_backend.h" |
| 24 #include "ui/base/l10n/l10n_util.h" |
| 22 | 25 |
| 23 PrinterJobHandler::JobDetails::JobDetails() {} | 26 PrinterJobHandler::JobDetails::JobDetails() {} |
| 24 | 27 |
| 25 PrinterJobHandler::JobDetails::~JobDetails() {} | 28 PrinterJobHandler::JobDetails::~JobDetails() {} |
| 26 | 29 |
| 27 void PrinterJobHandler::JobDetails::Clear() { | 30 void PrinterJobHandler::JobDetails::Clear() { |
| 28 job_id_.clear(); | 31 job_id_.clear(); |
| 29 job_title_.clear(); | 32 job_title_.clear(); |
| 30 print_ticket_.clear(); | 33 print_ticket_.clear(); |
| 31 print_data_mime_type_.clear(); | 34 print_data_mime_type_.clear(); |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 672 } |
| 670 } | 673 } |
| 671 | 674 |
| 672 // The following methods are called on |print_thread_|. It is not safe to | 675 // The following methods are called on |print_thread_|. It is not safe to |
| 673 // access any members other than |job_handler_message_loop_proxy_|, | 676 // access any members other than |job_handler_message_loop_proxy_|, |
| 674 // |job_spooler_| and |print_system_|. | 677 // |job_spooler_| and |print_system_|. |
| 675 void PrinterJobHandler::DoPrint(const JobDetails& job_details, | 678 void PrinterJobHandler::DoPrint(const JobDetails& job_details, |
| 676 const std::string& printer_name) { | 679 const std::string& printer_name) { |
| 677 job_spooler_ = print_system_->CreateJobSpooler(); | 680 job_spooler_ = print_system_->CreateJobSpooler(); |
| 678 DCHECK(job_spooler_); | 681 DCHECK(job_spooler_); |
| 679 if (!job_spooler_ || !job_spooler_->Spool(job_details.print_ticket_, | 682 if (!job_spooler_) |
| 680 job_details.print_data_file_path_, | 683 return; |
| 681 job_details.print_data_mime_type_, | 684 string16 document_name = |
| 682 printer_name, | 685 printing::PrintBackend::SimplifyDocumentTitle( |
| 683 job_details.job_title_, | 686 UTF8ToWide(job_details.job_title_)); |
| 684 job_details.tags_, | 687 if (document_name.empty()) { |
| 685 this)) { | 688 document_name = printing::PrintBackend::SimplifyDocumentTitle( |
| 689 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); |
| 690 } |
| 691 if (!job_spooler_->Spool(job_details.print_ticket_, |
| 692 job_details.print_data_file_path_, |
| 693 job_details.print_data_mime_type_, |
| 694 printer_name, |
| 695 WideToUTF8(document_name), |
| 696 job_details.tags_, |
| 697 this)) { |
| 686 OnJobSpoolFailed(); | 698 OnJobSpoolFailed(); |
| 687 } | 699 } |
| 688 } | 700 } |
| OLD | NEW |