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 13 matching lines...) Expand all Loading... |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/chrome_utility_printing_messages.h" | 26 #include "chrome/common/chrome_utility_printing_messages.h" |
27 #include "content/public/common/child_process_host.h" | 27 #include "content/public/common/child_process_host.h" |
28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/result_codes.h" | 29 #include "content/public/common/result_codes.h" |
30 #include "content/public/common/sandbox_init.h" | 30 #include "content/public/common/sandbox_init.h" |
31 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 31 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
32 #include "ipc/ipc_switches.h" | 32 #include "ipc/ipc_switches.h" |
33 #include "printing/emf_win.h" | 33 #include "printing/emf_win.h" |
34 #include "sandbox/win/src/sandbox_policy.h" | |
35 #include "sandbox/win/src/sandbox_types.h" | |
36 #include "ui/base/ui_base_switches.h" | 34 #include "ui/base/ui_base_switches.h" |
37 | 35 |
38 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
39 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" | 37 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" |
40 #endif // defined(OS_WIN) | 38 #endif // defined(OS_WIN) |
41 | 39 |
42 namespace { | 40 namespace { |
43 | 41 |
44 using content::ChildProcessHost; | 42 using content::ChildProcessHost; |
45 | 43 |
(...skipping 19 matching lines...) Expand all Loading... |
65 SERVICE_UTILITY_EVENT_MAX); | 63 SERVICE_UTILITY_EVENT_MAX); |
66 } | 64 } |
67 | 65 |
68 // NOTE: changes to this class need to be reviewed by the security team. | 66 // NOTE: changes to this class need to be reviewed by the security team. |
69 class ServiceSandboxedProcessLauncherDelegate | 67 class ServiceSandboxedProcessLauncherDelegate |
70 : public content::SandboxedProcessLauncherDelegate { | 68 : public content::SandboxedProcessLauncherDelegate { |
71 public: | 69 public: |
72 ServiceSandboxedProcessLauncherDelegate() {} | 70 ServiceSandboxedProcessLauncherDelegate() {} |
73 | 71 |
74 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { | 72 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { |
75 // Ignore result of SetAlternateDesktop. Service process may run as windows | |
76 // service and it fails to create a window station. | |
77 base::IgnoreResult(policy->SetAlternateDesktop(false)); | |
78 return true; | 73 return true; |
79 } | 74 } |
80 | 75 |
81 private: | 76 private: |
82 DISALLOW_COPY_AND_ASSIGN(ServiceSandboxedProcessLauncherDelegate); | 77 DISALLOW_COPY_AND_ASSIGN(ServiceSandboxedProcessLauncherDelegate); |
83 }; | 78 }; |
84 | 79 |
85 } // namespace | 80 } // namespace |
86 | 81 |
87 class ServiceUtilityProcessHost::PdfToEmfState { | 82 class ServiceUtilityProcessHost::PdfToEmfState { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (Launch(&cmd_line, no_sandbox)) { | 233 if (Launch(&cmd_line, no_sandbox)) { |
239 ReportUmaEvent(SERVICE_UTILITY_STARTED); | 234 ReportUmaEvent(SERVICE_UTILITY_STARTED); |
240 return true; | 235 return true; |
241 } | 236 } |
242 ReportUmaEvent(SERVICE_UTILITY_FAILED_TO_START); | 237 ReportUmaEvent(SERVICE_UTILITY_FAILED_TO_START); |
243 return false; | 238 return false; |
244 } | 239 } |
245 | 240 |
246 bool ServiceUtilityProcessHost::Launch(base::CommandLine* cmd_line, | 241 bool ServiceUtilityProcessHost::Launch(base::CommandLine* cmd_line, |
247 bool no_sandbox) { | 242 bool no_sandbox) { |
248 if (no_sandbox) { | 243 cmd_line->AppendSwitch(switches::kNoSandbox); |
249 cmd_line->AppendSwitch(switches::kNoSandbox); | 244 process_ = base::LaunchProcess(*cmd_line, base::LaunchOptions()); |
250 process_ = base::LaunchProcess(*cmd_line, base::LaunchOptions()); | 245 |
251 } else { | |
252 ServiceSandboxedProcessLauncherDelegate delegate; | |
253 process_ = content::StartSandboxedProcess( | |
254 &delegate, cmd_line, base::HandlesToInheritVector()); | |
255 } | |
256 return process_.IsValid(); | 246 return process_.IsValid(); |
257 } | 247 } |
258 | 248 |
259 bool ServiceUtilityProcessHost::Send(IPC::Message* msg) { | 249 bool ServiceUtilityProcessHost::Send(IPC::Message* msg) { |
260 if (child_process_host_) | 250 if (child_process_host_) |
261 return child_process_host_->Send(msg); | 251 return child_process_host_->Send(msg); |
262 delete msg; | 252 delete msg; |
263 return false; | 253 return false; |
264 } | 254 } |
265 | 255 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 return false; | 420 return false; |
431 } | 421 } |
432 printing::Emf emf; | 422 printing::Emf emf; |
433 if (!emf.InitFromData(data.data(), data.size())) { | 423 if (!emf.InitFromData(data.data(), data.size())) { |
434 OnRenderPDFPagesToMetafileDone(false); | 424 OnRenderPDFPagesToMetafileDone(false); |
435 return false; | 425 return false; |
436 } | 426 } |
437 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); | 427 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); |
438 return true; | 428 return true; |
439 } | 429 } |
OLD | NEW |