Chromium Code Reviews| 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/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 // access any members other than |job_handler_task_runner_|, | 785 // access any members other than |job_handler_task_runner_|, |
| 786 // |job_spooler_| and |print_system_|. | 786 // |job_spooler_| and |print_system_|. |
| 787 void PrinterJobHandler::DoPrint(const JobDetails& job_details, | 787 void PrinterJobHandler::DoPrint(const JobDetails& job_details, |
| 788 const std::string& printer_name) { | 788 const std::string& printer_name) { |
| 789 job_spooler_ = print_system_->CreateJobSpooler(); | 789 job_spooler_ = print_system_->CreateJobSpooler(); |
| 790 UMA_HISTOGRAM_LONG_TIMES("CloudPrint.PrepareTime", | 790 UMA_HISTOGRAM_LONG_TIMES("CloudPrint.PrepareTime", |
| 791 base::Time::Now() - job_start_time_); | 791 base::Time::Now() - job_start_time_); |
| 792 DCHECK(job_spooler_.get()); | 792 DCHECK(job_spooler_.get()); |
| 793 if (!job_spooler_.get()) | 793 if (!job_spooler_.get()) |
| 794 return; | 794 return; |
| 795 base::string16 document_name = printing::SimplifyDocumentTitle( | 795 base::string16 document_name = base::UTF8ToUTF16(job_details.job_title_); |
| 796 base::UTF8ToUTF16(job_details.job_title_)); | 796 if (!job_details.job_owner_.empty()) { |
|
Aleksey Shlyapnikov
2015/07/06 23:06:25
What if it is empty? We still need to call printin
Vitaly Buka (NO REVIEWS)
2015/07/07 01:22:50
Re-done.
| |
| 797 base::string16 prefix = printing::SimplifyDocumentTitle( | |
| 798 base::UTF8ToUTF16(job_details.job_owner_ + ": ")); | |
| 799 if (prefix.size() < printing::kMaxDocumentTitleLength) { | |
| 800 document_name = | |
| 801 prefix + | |
| 802 printing::SimplifyDocumentTitleWithLength( | |
| 803 document_name, printing::kMaxDocumentTitleLength - prefix.size()); | |
| 804 } | |
| 805 } | |
| 806 | |
| 807 DCHECK_LE(document_name.size(), printing::kMaxDocumentTitleLength); | |
| 797 if (document_name.empty()) { | 808 if (document_name.empty()) { |
| 798 document_name = printing::SimplifyDocumentTitle( | 809 document_name = printing::SimplifyDocumentTitle( |
| 799 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); | 810 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); |
| 800 } | 811 } |
| 801 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", | 812 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", |
| 802 JOB_HANDLER_START_SPOOLING, JOB_HANDLER_MAX); | 813 JOB_HANDLER_START_SPOOLING, JOB_HANDLER_MAX); |
| 803 spooling_start_time_ = base::Time::Now(); | 814 spooling_start_time_ = base::Time::Now(); |
| 804 if (!job_spooler_->Spool(job_details.print_ticket_, | 815 if (!job_spooler_->Spool(job_details.print_ticket_, |
| 805 job_details.print_ticket_mime_type_, | 816 job_details.print_ticket_mime_type_, |
| 806 job_details.print_data_file_path_, | 817 job_details.print_data_file_path_, |
| 807 job_details.print_data_mime_type_, | 818 job_details.print_data_mime_type_, |
| 808 printer_name, | 819 printer_name, |
| 809 base::UTF16ToUTF8(document_name), | 820 base::UTF16ToUTF8(document_name), |
| 810 job_details.tags_, | 821 job_details.tags_, |
| 811 this)) { | 822 this)) { |
| 812 OnJobSpoolFailed(); | 823 OnJobSpoolFailed(); |
| 813 } | 824 } |
| 814 } | 825 } |
| 815 | 826 |
| 816 } // namespace cloud_print | 827 } // namespace cloud_print |
| OLD | NEW |