| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utility/utility_thread.h" | 5 #include "chrome/utility/utility_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/scoped_ptr.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/common/child_process.h" | 14 #include "chrome/common/child_process.h" |
| 14 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/extensions/extension_unpacker.h" | 16 #include "chrome/common/extensions/extension_unpacker.h" |
| 16 #include "chrome/common/extensions/update_manifest.h" | 17 #include "chrome/common/extensions/update_manifest.h" |
| 17 #include "chrome/common/indexed_db_key.h" | 18 #include "chrome/common/indexed_db_key.h" |
| 18 #include "chrome/common/serialized_script_value.h" | 19 #include "chrome/common/serialized_script_value.h" |
| 19 #include "chrome/common/utility_messages.h" | 20 #include "chrome/common/utility_messages.h" |
| 20 #include "chrome/common/web_resource/web_resource_unpacker.h" | 21 #include "chrome/common/web_resource/web_resource_unpacker.h" |
| 21 #include "printing/native_metafile.h" | 22 #include "printing/metafile_factory.h" |
| 22 #include "printing/page_range.h" | 23 #include "printing/page_range.h" |
| 23 #include "printing/units.h" | 24 #include "printing/units.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" |
| 26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
| 27 #include "webkit/glue/idb_bindings.h" | 28 #include "webkit/glue/idb_bindings.h" |
| 28 #include "webkit/glue/image_decoder.h" | 29 #include "webkit/glue/image_decoder.h" |
| 29 | 30 |
| 30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 31 #include "app/win/iat_patch_function.h" | 32 #include "app/win/iat_patch_function.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 | 130 |
| 130 void UtilityThread::OnRenderPDFPagesToMetafile( | 131 void UtilityThread::OnRenderPDFPagesToMetafile( |
| 131 base::PlatformFile pdf_file, | 132 base::PlatformFile pdf_file, |
| 132 const FilePath& metafile_path, | 133 const FilePath& metafile_path, |
| 133 const gfx::Rect& render_area, | 134 const gfx::Rect& render_area, |
| 134 int render_dpi, | 135 int render_dpi, |
| 135 const std::vector<printing::PageRange>& page_ranges) { | 136 const std::vector<printing::PageRange>& page_ranges) { |
| 136 bool succeeded = false; | 137 bool succeeded = false; |
| 137 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
| 138 printing::NativeMetafile metafile; | 139 scoped_ptr<printing::NativeMetafile> metafile_ptr( |
| 140 printing::MetafileFactory::GetMetafile()); |
| 139 int highest_rendered_page_number = 0; | 141 int highest_rendered_page_number = 0; |
| 140 succeeded = RenderPDFToWinMetafile(pdf_file, metafile_path, render_area, | 142 succeeded = RenderPDFToWinMetafile(pdf_file, metafile_path, render_area, |
| 141 render_dpi, page_ranges, &metafile, | 143 render_dpi, page_ranges, metafile_ptr.get()
, |
| 142 &highest_rendered_page_number); | 144 &highest_rendered_page_number); |
| 143 if (succeeded) { | 145 if (succeeded) { |
| 144 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded( | 146 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded( |
| 145 highest_rendered_page_number)); | 147 highest_rendered_page_number)); |
| 146 } | 148 } |
| 147 #endif // defined(OS_WIN) | 149 #endif // defined(OS_WIN) |
| 148 if (!succeeded) { | 150 if (!succeeded) { |
| 149 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed()); | 151 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed()); |
| 150 } | 152 } |
| 151 ReleaseProcessIfNeeded(); | 153 ReleaseProcessIfNeeded(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } else { | 336 } else { |
| 335 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); | 337 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); |
| 336 } | 338 } |
| 337 ReleaseProcessIfNeeded(); | 339 ReleaseProcessIfNeeded(); |
| 338 } | 340 } |
| 339 | 341 |
| 340 void UtilityThread::ReleaseProcessIfNeeded() { | 342 void UtilityThread::ReleaseProcessIfNeeded() { |
| 341 if (!batch_mode_) | 343 if (!batch_mode_) |
| 342 ChildProcess::current()->ReleaseProcess(); | 344 ChildProcess::current()->ReleaseProcess(); |
| 343 } | 345 } |
| OLD | NEW |