Chromium Code Reviews| 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/service/service_utility_process_host.h" | 5 #include "chrome/service/service_utility_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/chrome_utility_messages.h" | 14 #include "chrome/common/chrome_utility_messages.h" |
| 15 #include "ipc/ipc_switches.h" | 15 #include "ipc/ipc_switches.h" |
| 16 #include "printing/page_range.h" | 16 #include "printing/page_range.h" |
| 17 #include "printing/pdf_render_settings.h" | |
| 17 #include "ui/base/ui_base_switches.h" | 18 #include "ui/base/ui_base_switches.h" |
| 18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 19 | 20 |
| 20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 21 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/win/scoped_handle.h" | 23 #include "base/win/scoped_handle.h" |
| 23 #include "content/common/child_process_messages.h" | 24 #include "content/common/child_process_messages.h" |
| 24 #include "printing/emf_win.h" | 25 #include "printing/emf_win.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 ServiceUtilityProcessHost::ServiceUtilityProcessHost( | 28 ServiceUtilityProcessHost::ServiceUtilityProcessHost( |
| 28 Client* client, base::MessageLoopProxy* client_message_loop_proxy) | 29 Client* client, base::MessageLoopProxy* client_message_loop_proxy) |
| 29 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), | 30 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), |
| 30 client_(client), | 31 client_(client), |
| 31 client_message_loop_proxy_(client_message_loop_proxy), | 32 client_message_loop_proxy_(client_message_loop_proxy), |
| 32 waiting_for_reply_(false) { | 33 waiting_for_reply_(false) { |
| 33 process_id_ = ChildProcessInfo::GenerateChildProcessUniqueId(); | 34 process_id_ = ChildProcessInfo::GenerateChildProcessUniqueId(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { | 37 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( | 40 bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( |
| 40 const FilePath& pdf_path, | 41 const FilePath& pdf_path, |
| 41 const gfx::Rect& render_area, | 42 const gfx::Rect& render_area, |
|
Lei Zhang
2011/10/05 20:36:19
Why not make this a PdfRenderSettings as well?
| |
| 42 int render_dpi, | 43 int render_dpi, |
| 44 bool autorotate, | |
| 43 const std::vector<printing::PageRange>& page_ranges) { | 45 const std::vector<printing::PageRange>& page_ranges) { |
| 44 #if !defined(OS_WIN) | 46 #if !defined(OS_WIN) |
| 45 // This is only implemented on Windows (because currently it is only needed | 47 // This is only implemented on Windows (because currently it is only needed |
| 46 // on Windows). Will add implementations on other platforms when needed. | 48 // on Windows). Will add implementations on other platforms when needed. |
| 47 NOTIMPLEMENTED(); | 49 NOTIMPLEMENTED(); |
| 48 return false; | 50 return false; |
| 49 #else // !defined(OS_WIN) | 51 #else // !defined(OS_WIN) |
| 50 scratch_metafile_dir_.reset(new ScopedTempDir); | 52 scratch_metafile_dir_.reset(new ScopedTempDir); |
| 51 if (!scratch_metafile_dir_->CreateUniqueTempDir()) | 53 if (!scratch_metafile_dir_->CreateUniqueTempDir()) |
| 52 return false; | 54 return false; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 72 ::DuplicateHandle(::GetCurrentProcess(), pdf_file, handle(), | 74 ::DuplicateHandle(::GetCurrentProcess(), pdf_file, handle(), |
| 73 &pdf_file_in_utility_process, 0, false, | 75 &pdf_file_in_utility_process, 0, false, |
| 74 DUPLICATE_SAME_ACCESS); | 76 DUPLICATE_SAME_ACCESS); |
| 75 if (!pdf_file_in_utility_process) | 77 if (!pdf_file_in_utility_process) |
| 76 return false; | 78 return false; |
| 77 waiting_for_reply_ = true; | 79 waiting_for_reply_ = true; |
| 78 return Send( | 80 return Send( |
| 79 new ChromeUtilityMsg_RenderPDFPagesToMetafile( | 81 new ChromeUtilityMsg_RenderPDFPagesToMetafile( |
| 80 pdf_file_in_utility_process, | 82 pdf_file_in_utility_process, |
| 81 metafile_path_, | 83 metafile_path_, |
| 82 render_area, | 84 printing::PdfRenderSettings(render_area, render_dpi, autorotate), |
| 83 render_dpi, | |
| 84 page_ranges)); | 85 page_ranges)); |
| 85 #endif // !defined(OS_WIN) | 86 #endif // !defined(OS_WIN) |
| 86 } | 87 } |
| 87 | 88 |
| 88 bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults( | 89 bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults( |
| 89 const std::string& printer_name) { | 90 const std::string& printer_name) { |
| 90 FilePath exposed_path; | 91 FilePath exposed_path; |
| 91 if (!StartProcess(true, exposed_path)) | 92 if (!StartProcess(true, exposed_path)) |
| 92 return false; | 93 return false; |
| 93 waiting_for_reply_ = true; | 94 waiting_for_reply_ = true; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 printing::Emf metafile; | 227 printing::Emf metafile; |
| 227 if (!metafile.InitFromFile(metafile_path)) { | 228 if (!metafile.InitFromFile(metafile_path)) { |
| 228 OnRenderPDFPagesToMetafileFailed(); | 229 OnRenderPDFPagesToMetafileFailed(); |
| 229 } else { | 230 } else { |
| 230 OnRenderPDFPagesToMetafileSucceeded(metafile, | 231 OnRenderPDFPagesToMetafileSucceeded(metafile, |
| 231 highest_rendered_page_number); | 232 highest_rendered_page_number); |
| 232 } | 233 } |
| 233 #endif // defined(OS_WIN) | 234 #endif // defined(OS_WIN) |
| 234 } | 235 } |
| 235 | 236 |
| OLD | NEW |