| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/pdf_to_emf_converter.h" | 5 #include "chrome/browser/printing/pdf_to_emf_converter.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <queue> | 9 #include <queue> |
| 8 #include <utility> | 10 #include <utility> |
| 9 | 11 |
| 10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 11 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" |
| 14 #include "chrome/common/chrome_utility_messages.h" | 17 #include "chrome/common/chrome_utility_messages.h" |
| 15 #include "chrome/common/chrome_utility_printing_messages.h" | 18 #include "chrome/common/chrome_utility_printing_messages.h" |
| 16 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 17 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/child_process_data.h" | 21 #include "content/public/browser/child_process_data.h" |
| 19 #include "content/public/browser/utility_process_host.h" | 22 #include "content/public/browser/utility_process_host.h" |
| 20 #include "content/public/browser/utility_process_host_client.h" | 23 #include "content/public/browser/utility_process_host_client.h" |
| 21 #include "printing/emf_win.h" | 24 #include "printing/emf_win.h" |
| 22 #include "printing/pdf_render_settings.h" | 25 #include "printing/pdf_render_settings.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return LoadEmf(&emf) && emf.SaveTo(file); | 263 return LoadEmf(&emf) && emf.SaveTo(file); |
| 261 } | 264 } |
| 262 | 265 |
| 263 void LazyEmf::Close() const { | 266 void LazyEmf::Close() const { |
| 264 file_.reset(); | 267 file_.reset(); |
| 265 temp_dir_ = NULL; | 268 temp_dir_ = NULL; |
| 266 } | 269 } |
| 267 | 270 |
| 268 bool LazyEmf::LoadEmf(Emf* emf) const { | 271 bool LazyEmf::LoadEmf(Emf* emf) const { |
| 269 file_->Seek(base::File::FROM_BEGIN, 0); | 272 file_->Seek(base::File::FROM_BEGIN, 0); |
| 270 int64 size = file_->GetLength(); | 273 int64_t size = file_->GetLength(); |
| 271 if (size <= 0) | 274 if (size <= 0) |
| 272 return false; | 275 return false; |
| 273 std::vector<char> data(size); | 276 std::vector<char> data(size); |
| 274 if (file_->ReadAtCurrentPos(data.data(), data.size()) != size) | 277 if (file_->ReadAtCurrentPos(data.data(), data.size()) != size) |
| 275 return false; | 278 return false; |
| 276 return emf->InitFromData(data.data(), data.size()); | 279 return emf->InitFromData(data.data(), data.size()); |
| 277 } | 280 } |
| 278 | 281 |
| 279 PdfToEmfUtilityProcessHostClient::PdfToEmfUtilityProcessHostClient( | 282 PdfToEmfUtilityProcessHostClient::PdfToEmfUtilityProcessHostClient( |
| 280 base::WeakPtr<PdfToEmfConverterImpl> converter, | 283 base::WeakPtr<PdfToEmfConverterImpl> converter, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 505 |
| 503 PdfToEmfConverter::~PdfToEmfConverter() { | 506 PdfToEmfConverter::~PdfToEmfConverter() { |
| 504 } | 507 } |
| 505 | 508 |
| 506 // static | 509 // static |
| 507 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { | 510 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { |
| 508 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); | 511 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); |
| 509 } | 512 } |
| 510 | 513 |
| 511 } // namespace printing | 514 } // namespace printing |
| OLD | NEW |