| 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/service/service_utility_process_host.h" | 5 #include "chrome/service/service_utility_process_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "content/public/common/child_process_host.h" | 30 #include "content/public/common/child_process_host.h" |
| 31 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 32 #include "content/public/common/mojo_channel_switches.h" | 32 #include "content/public/common/mojo_channel_switches.h" |
| 33 #include "content/public/common/result_codes.h" | 33 #include "content/public/common/result_codes.h" |
| 34 #include "content/public/common/sandbox_init.h" | 34 #include "content/public/common/sandbox_init.h" |
| 35 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 35 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 36 #include "mojo/edk/embedder/embedder.h" | 36 #include "mojo/edk/embedder/embedder.h" |
| 37 #include "mojo/edk/embedder/named_platform_channel_pair.h" | 37 #include "mojo/edk/embedder/named_platform_channel_pair.h" |
| 38 #include "mojo/edk/embedder/platform_channel_pair.h" | 38 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 39 #include "mojo/edk/embedder/scoped_platform_handle.h" | 39 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 40 #include "printing/emf_win.h" |
| 40 #include "sandbox/win/src/sandbox_policy.h" | 41 #include "sandbox/win/src/sandbox_policy.h" |
| 41 #include "sandbox/win/src/sandbox_types.h" | 42 #include "sandbox/win/src/sandbox_types.h" |
| 42 #include "ui/base/ui_base_switches.h" | 43 #include "ui/base/ui_base_switches.h" |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 using content::ChildProcessHost; | 47 using content::ChildProcessHost; |
| 47 | 48 |
| 48 enum ServiceUtilityProcessHostEvent { | 49 enum ServiceUtilityProcessHostEvent { |
| 49 SERVICE_UTILITY_STARTED, | 50 SERVICE_UTILITY_STARTED, |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 const std::string& printer_name) { | 422 const std::string& printer_name) { |
| 422 DCHECK(waiting_for_reply_); | 423 DCHECK(waiting_for_reply_); |
| 423 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_FAILED); | 424 ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_FAILED); |
| 424 waiting_for_reply_ = false; | 425 waiting_for_reply_ = false; |
| 425 client_task_runner_->PostTask( | 426 client_task_runner_->PostTask( |
| 426 FROM_HERE, base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, | 427 FROM_HERE, base::Bind(&Client::OnGetPrinterSemanticCapsAndDefaults, |
| 427 client_.get(), false, printer_name, | 428 client_.get(), false, printer_name, |
| 428 printing::PrinterSemanticCapsAndDefaults())); | 429 printing::PrinterSemanticCapsAndDefaults())); |
| 429 } | 430 } |
| 430 | 431 |
| 431 bool ServiceUtilityProcessHost::Client::OnRenderPDFPagesToMetafilePageDone( | |
| 432 const std::vector<char>&, | |
| 433 float) { | |
| 434 return false; | |
| 435 } | |
| 436 | |
| 437 bool ServiceUtilityProcessHost::Client::MetafileAvailable(float scale_factor, | 432 bool ServiceUtilityProcessHost::Client::MetafileAvailable(float scale_factor, |
| 438 base::File file) { | 433 base::File file) { |
| 439 file.Seek(base::File::FROM_BEGIN, 0); | 434 file.Seek(base::File::FROM_BEGIN, 0); |
| 440 int64_t size = file.GetLength(); | 435 int64_t size = file.GetLength(); |
| 441 if (size <= 0) { | 436 if (size <= 0) { |
| 442 OnRenderPDFPagesToMetafileDone(false); | 437 OnRenderPDFPagesToMetafileDone(false); |
| 443 return false; | 438 return false; |
| 444 } | 439 } |
| 445 std::vector<char> data(size); | 440 std::vector<char> data(size); |
| 446 if (file.ReadAtCurrentPos(data.data(), data.size()) != size) { | 441 if (file.ReadAtCurrentPos(data.data(), data.size()) != size) { |
| 447 OnRenderPDFPagesToMetafileDone(false); | 442 OnRenderPDFPagesToMetafileDone(false); |
| 448 return false; | 443 return false; |
| 449 } | 444 } |
| 450 if (!OnRenderPDFPagesToMetafilePageDone(data, scale_factor)) { | 445 printing::Emf emf; |
| 446 if (!emf.InitFromData(data.data(), data.size())) { |
| 451 OnRenderPDFPagesToMetafileDone(false); | 447 OnRenderPDFPagesToMetafileDone(false); |
| 452 return false; | 448 return false; |
| 453 } | 449 } |
| 450 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); |
| 454 return true; | 451 return true; |
| 455 } | 452 } |
| OLD | NEW |