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/cloud_print/print_system.h" | 5 #include "chrome/service/cloud_print/print_system.h" |
6 | 6 |
7 #include <objidl.h> | 7 #include <objidl.h> |
8 #include <winspool.h> | 8 #include <winspool.h> |
9 #include <xpsprint.h> | 9 #include <xpsprint.h> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/win/object_watcher.h" | 15 #include "base/win/object_watcher.h" |
16 #include "base/win/scoped_bstr.h" | 16 #include "base/win/scoped_bstr.h" |
17 #include "base/win/scoped_comptr.h" | 17 #include "base/win/scoped_comptr.h" |
18 #include "base/win/scoped_hdc.h" | 18 #include "base/win/scoped_hdc.h" |
19 #include "chrome/service/service_process.h" | 19 #include "chrome/service/service_process.h" |
20 #include "chrome/service/service_utility_process_host.h" | 20 #include "chrome/service/service_utility_process_host.h" |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
22 #include "printing/backend/print_backend.h" | 22 #include "printing/backend/print_backend.h" |
23 #include "printing/backend/print_backend_consts.h" | 23 #include "printing/backend/print_backend_consts.h" |
24 #include "printing/backend/win_helper.h" | 24 #include "printing/backend/win_helper.h" |
25 #include "printing/emf_win.h" | 25 #include "printing/emf_win.h" |
26 #include "printing/page_range.h" | 26 #include "printing/page_range.h" |
| 27 #include "printing/pdf_render_settings.h" |
27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
29 | 30 |
30 #pragma comment(lib, "rpcrt4.lib") // for UuidToString & Co. | 31 #pragma comment(lib, "rpcrt4.lib") // for UuidToString & Co. |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 class DevMode { | 35 class DevMode { |
35 public: | 36 public: |
36 DevMode() : dm_(NULL) {} | 37 DevMode() : dm_(NULL) {} |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // Called on the service process IO thread. | 542 // Called on the service process IO thread. |
542 void RenderPDFPagesInSandbox( | 543 void RenderPDFPagesInSandbox( |
543 const FilePath& pdf_path, const gfx::Rect& render_area, | 544 const FilePath& pdf_path, const gfx::Rect& render_area, |
544 int render_dpi, const std::vector<printing::PageRange>& page_ranges, | 545 int render_dpi, const std::vector<printing::PageRange>& page_ranges, |
545 const scoped_refptr<base::MessageLoopProxy>& | 546 const scoped_refptr<base::MessageLoopProxy>& |
546 client_message_loop_proxy) { | 547 client_message_loop_proxy) { |
547 DCHECK(g_service_process->io_thread()->message_loop_proxy()-> | 548 DCHECK(g_service_process->io_thread()->message_loop_proxy()-> |
548 BelongsToCurrentThread()); | 549 BelongsToCurrentThread()); |
549 scoped_ptr<ServiceUtilityProcessHost> utility_host( | 550 scoped_ptr<ServiceUtilityProcessHost> utility_host( |
550 new ServiceUtilityProcessHost(this, client_message_loop_proxy)); | 551 new ServiceUtilityProcessHost(this, client_message_loop_proxy)); |
551 if (utility_host->StartRenderPDFPagesToMetafile(pdf_path, | 552 // TODO(gene): For now we disabling autorotation for CloudPrinting. |
552 render_area, | 553 // Landscape/Portrait setting is passed in the print ticket and |
553 render_dpi, | 554 // server is generating portrait PDF always. |
554 page_ranges)) { | 555 // We should enable autorotation once server will be able to generate |
| 556 // PDF that matches paper size and orientation. |
| 557 if (utility_host->StartRenderPDFPagesToMetafile( |
| 558 pdf_path, |
| 559 printing::PdfRenderSettings(render_area, render_dpi, false), |
| 560 page_ranges)) { |
555 // The object will self-destruct when the child process dies. | 561 // The object will self-destruct when the child process dies. |
556 utility_host.release(); | 562 utility_host.release(); |
557 } | 563 } |
558 } | 564 } |
559 bool PrintXPSDocument(const std::string& printer_name, | 565 bool PrintXPSDocument(const std::string& printer_name, |
560 const std::string& job_title, | 566 const std::string& job_title, |
561 const FilePath& print_data_file_path, | 567 const FilePath& print_data_file_path, |
562 const std::string& print_ticket) { | 568 const std::string& print_ticket) { |
563 if (!printing::XPSPrintModule::Init()) | 569 if (!printing::XPSPrintModule::Init()) |
564 return false; | 570 return false; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); | 873 RpcStringFree(reinterpret_cast<RPC_WSTR *>(&proxy_id_as_string)); |
868 return ret; | 874 return ret; |
869 } | 875 } |
870 | 876 |
871 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 877 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
872 const base::DictionaryValue* print_system_settings) { | 878 const base::DictionaryValue* print_system_settings) { |
873 return new PrintSystemWin; | 879 return new PrintSystemWin; |
874 } | 880 } |
875 | 881 |
876 } // namespace cloud_print | 882 } // namespace cloud_print |
OLD | NEW |