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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.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 17 matching lines...) Expand all Loading... |
266 int current_page_; | 268 int current_page_; |
267 int pages_in_progress_; | 269 int pages_in_progress_; |
268 gfx::Size page_size_; | 270 gfx::Size page_size_; |
269 gfx::Rect content_area_; | 271 gfx::Rect content_area_; |
270 std::unique_ptr<PdfToEmfConverter> converter_; | 272 std::unique_ptr<PdfToEmfConverter> converter_; |
271 }; | 273 }; |
272 | 274 |
273 void PrintJob::StartPdfToEmfConversion( | 275 void PrintJob::StartPdfToEmfConversion( |
274 const scoped_refptr<base::RefCountedMemory>& bytes, | 276 const scoped_refptr<base::RefCountedMemory>& bytes, |
275 const gfx::Size& page_size, | 277 const gfx::Size& page_size, |
276 const gfx::Rect& content_area) { | 278 const gfx::Rect& content_area, |
| 279 bool print_text_with_gdi) { |
277 DCHECK(!ptd_to_emf_state_.get()); | 280 DCHECK(!ptd_to_emf_state_.get()); |
278 ptd_to_emf_state_.reset(new PdfToEmfState(page_size, content_area)); | 281 ptd_to_emf_state_.reset(new PdfToEmfState(page_size, content_area)); |
279 const int kPrinterDpi = settings().dpi(); | 282 const int kPrinterDpi = settings().dpi(); |
280 ptd_to_emf_state_->Start( | 283 ptd_to_emf_state_->Start( |
281 bytes, | 284 bytes, printing::PdfRenderSettings(content_area, kPrinterDpi, true), |
282 printing::PdfRenderSettings(content_area, kPrinterDpi, true), | 285 print_text_with_gdi, base::Bind(&PrintJob::OnPdfToEmfStarted, this)); |
283 base::Bind(&PrintJob::OnPdfToEmfStarted, this)); | |
284 } | 286 } |
285 | 287 |
286 void PrintJob::OnPdfToEmfStarted(int page_count) { | 288 void PrintJob::OnPdfToEmfStarted(int page_count) { |
287 if (page_count <= 0) { | 289 if (page_count <= 0) { |
288 ptd_to_emf_state_.reset(); | 290 ptd_to_emf_state_.reset(); |
289 Cancel(); | 291 Cancel(); |
290 return; | 292 return; |
291 } | 293 } |
292 ptd_to_emf_state_->set_page_count(page_count); | 294 ptd_to_emf_state_->set_page_count(page_count); |
293 ptd_to_emf_state_->GetMorePages( | 295 ptd_to_emf_state_->GetMorePages( |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 452 } |
451 | 453 |
452 JobEventDetails::~JobEventDetails() { | 454 JobEventDetails::~JobEventDetails() { |
453 } | 455 } |
454 | 456 |
455 PrintedDocument* JobEventDetails::document() const { return document_.get(); } | 457 PrintedDocument* JobEventDetails::document() const { return document_.get(); } |
456 | 458 |
457 PrintedPage* JobEventDetails::page() const { return page_.get(); } | 459 PrintedPage* JobEventDetails::page() const { return page_.get(); } |
458 | 460 |
459 } // namespace printing | 461 } // namespace printing |
OLD | NEW |