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/browser/printing/print_job.h" | 5 #include "chrome/browser/printing/print_job.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 PdfToEmfState(const gfx::Size& page_size, const gfx::Rect& content_area) | 227 PdfToEmfState(const gfx::Size& page_size, const gfx::Rect& content_area) |
228 : page_count_(0), | 228 : page_count_(0), |
229 current_page_(0), | 229 current_page_(0), |
230 pages_in_progress_(0), | 230 pages_in_progress_(0), |
231 page_size_(page_size), | 231 page_size_(page_size), |
232 content_area_(content_area), | 232 content_area_(content_area), |
233 converter_(PdfToEmfConverter::CreateDefault()) {} | 233 converter_(PdfToEmfConverter::CreateDefault()) {} |
234 | 234 |
235 void Start(const scoped_refptr<base::RefCountedMemory>& data, | 235 void Start(const scoped_refptr<base::RefCountedMemory>& data, |
236 const PdfRenderSettings& conversion_settings, | 236 const PdfRenderSettings& conversion_settings, |
| 237 bool print_text_with_gdi, |
237 const PdfToEmfConverter::StartCallback& start_callback) { | 238 const PdfToEmfConverter::StartCallback& start_callback) { |
238 converter_->Start(data, conversion_settings, start_callback); | 239 converter_->Start(data, conversion_settings, print_text_with_gdi, |
| 240 start_callback); |
239 } | 241 } |
240 | 242 |
241 void GetMorePages( | 243 void GetMorePages( |
242 const PdfToEmfConverter::GetPageCallback& get_page_callback) { | 244 const PdfToEmfConverter::GetPageCallback& get_page_callback) { |
243 const int kMaxNumberOfTempFilesPerDocument = 3; | 245 const int kMaxNumberOfTempFilesPerDocument = 3; |
244 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && | 246 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && |
245 current_page_ < page_count_) { | 247 current_page_ < page_count_) { |
246 ++pages_in_progress_; | 248 ++pages_in_progress_; |
247 converter_->GetPage(current_page_++, get_page_callback); | 249 converter_->GetPage(current_page_++, get_page_callback); |
248 } | 250 } |
(...skipping 21 matching lines...) Expand all Loading... |
270 std::unique_ptr<PdfToEmfConverter> converter_; | 272 std::unique_ptr<PdfToEmfConverter> converter_; |
271 }; | 273 }; |
272 | 274 |
273 void PrintJob::AppendPrintedPage(int page_number) { | 275 void PrintJob::AppendPrintedPage(int page_number) { |
274 pdf_page_mapping_.push_back(page_number); | 276 pdf_page_mapping_.push_back(page_number); |
275 } | 277 } |
276 | 278 |
277 void PrintJob::StartPdfToEmfConversion( | 279 void PrintJob::StartPdfToEmfConversion( |
278 const scoped_refptr<base::RefCountedMemory>& bytes, | 280 const scoped_refptr<base::RefCountedMemory>& bytes, |
279 const gfx::Size& page_size, | 281 const gfx::Size& page_size, |
280 const gfx::Rect& content_area) { | 282 const gfx::Rect& content_area, |
| 283 bool print_text_with_gdi) { |
281 DCHECK(!pdf_to_emf_state_); | 284 DCHECK(!pdf_to_emf_state_); |
282 pdf_to_emf_state_ = base::MakeUnique<PdfToEmfState>(page_size, content_area); | 285 pdf_to_emf_state_ = base::MakeUnique<PdfToEmfState>(page_size, content_area); |
283 const int kPrinterDpi = settings().dpi(); | 286 const int kPrinterDpi = settings().dpi(); |
284 pdf_to_emf_state_->Start(bytes, | 287 pdf_to_emf_state_->Start( |
285 PdfRenderSettings(content_area, kPrinterDpi, true), | 288 bytes, PdfRenderSettings(content_area, kPrinterDpi, true), |
286 base::Bind(&PrintJob::OnPdfToEmfStarted, this)); | 289 print_text_with_gdi, base::Bind(&PrintJob::OnPdfToEmfStarted, this)); |
287 } | 290 } |
288 | 291 |
289 void PrintJob::OnPdfToEmfStarted(int page_count) { | 292 void PrintJob::OnPdfToEmfStarted(int page_count) { |
290 if (page_count <= 0) { | 293 if (page_count <= 0) { |
291 pdf_to_emf_state_.reset(); | 294 pdf_to_emf_state_.reset(); |
292 Cancel(); | 295 Cancel(); |
293 return; | 296 return; |
294 } | 297 } |
295 pdf_to_emf_state_->set_page_count(page_count); | 298 pdf_to_emf_state_->set_page_count(page_count); |
296 pdf_to_emf_state_->GetMorePages( | 299 pdf_to_emf_state_->GetMorePages( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 } | 456 } |
454 | 457 |
455 JobEventDetails::~JobEventDetails() { | 458 JobEventDetails::~JobEventDetails() { |
456 } | 459 } |
457 | 460 |
458 PrintedDocument* JobEventDetails::document() const { return document_.get(); } | 461 PrintedDocument* JobEventDetails::document() const { return document_.get(); } |
459 | 462 |
460 PrintedPage* JobEventDetails::page() const { return page_.get(); } | 463 PrintedPage* JobEventDetails::page() const { return page_.get(); } |
461 | 464 |
462 } // namespace printing | 465 } // namespace printing |
OLD | NEW |