Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/printing/print_view_manager_base.h" | 5 #include "chrome/browser/printing/print_view_manager_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 } | 123 } |
| 124 | 124 |
| 125 void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) { | 125 void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) { |
| 126 cookie_ = cookie; | 126 cookie_ = cookie; |
| 127 } | 127 } |
| 128 | 128 |
| 129 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 130 void PrintViewManagerBase::OnPdfToEmfConverted( | 130 void PrintViewManagerBase::OnPdfToEmfConverted( |
| 131 const PrintHostMsg_DidPrintPage_Params& params, | 131 const PrintHostMsg_DidPrintPage_Params& params, |
| 132 double scale_factor, | 132 double scale_factor, |
| 133 const std::vector<base::FilePath>& emf_files) { | 133 ScopedVector<Metafile>* emf_files) { |
| 134 if (!print_job_.get()) | 134 if (!print_job_.get()) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 PrintedDocument* document = print_job_->document(); | 137 PrintedDocument* document = print_job_->document(); |
| 138 if (!document) | 138 if (!document) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 for (size_t i = 0; i < emf_files.size(); ++i) { | 141 for (size_t i = 0; i < emf_files->size(); ++i) { |
| 142 scoped_ptr<printing::Emf> metafile(new printing::Emf); | 142 if (!(*emf_files)[i]) { |
| 143 if (!metafile->InitFromFile(emf_files[i])) { | |
| 144 NOTREACHED() << "Invalid metafile"; | |
| 145 web_contents()->Stop(); | 143 web_contents()->Stop(); |
| 146 return; | 144 return; |
| 147 } | 145 } |
| 146 } | |
| 147 | |
| 148 for (size_t i = 0; i < emf_files->size(); ++i) { | |
| 148 // Update the rendered document. It will send notifications to the listener. | 149 // Update the rendered document. It will send notifications to the listener. |
| 149 document->SetPage(i, | 150 document->SetPage(i, |
| 150 metafile.release(), | 151 (*emf_files)[i], |
| 151 scale_factor, | 152 scale_factor, |
| 152 params.page_size, | 153 params.page_size, |
| 153 params.content_area); | 154 params.content_area); |
| 154 } | 155 } |
| 156 emf_files->weak_clear(); | |
|
scottmg
2014/09/08 19:06:11
Add a comment here or above SetPage that ownership
Vitaly Buka (NO REVIEWS)
2014/09/08 19:19:58
Done.
| |
| 155 | 157 |
| 156 ShouldQuitFromInnerMessageLoop(); | 158 ShouldQuitFromInnerMessageLoop(); |
| 157 } | 159 } |
| 158 #endif // OS_WIN | 160 #endif // OS_WIN |
| 159 | 161 |
| 160 void PrintViewManagerBase::OnDidPrintPage( | 162 void PrintViewManagerBase::OnDidPrintPage( |
| 161 const PrintHostMsg_DidPrintPage_Params& params) { | 163 const PrintHostMsg_DidPrintPage_Params& params) { |
| 162 if (!OpportunisticallyCreatePrintJob(params.document_cookie)) | 164 if (!OpportunisticallyCreatePrintJob(params.document_cookie)) |
| 163 return; | 165 return; |
| 164 | 166 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 scoped_refptr<printing::PrinterQuery> printer_query; | 565 scoped_refptr<printing::PrinterQuery> printer_query; |
| 564 printer_query = queue_->PopPrinterQuery(cookie); | 566 printer_query = queue_->PopPrinterQuery(cookie); |
| 565 if (!printer_query.get()) | 567 if (!printer_query.get()) |
| 566 return; | 568 return; |
| 567 BrowserThread::PostTask( | 569 BrowserThread::PostTask( |
| 568 BrowserThread::IO, FROM_HERE, | 570 BrowserThread::IO, FROM_HERE, |
| 569 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); | 571 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); |
| 570 } | 572 } |
| 571 | 573 |
| 572 } // namespace printing | 574 } // namespace printing |
| OLD | NEW |