| 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 "content/browser/utility_process_host_impl.h" | 5 #include "content/browser/utility_process_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 public: | 69 public: |
| 70 UtilitySandboxedProcessLauncherDelegate(const base::FilePath& exposed_dir, | 70 UtilitySandboxedProcessLauncherDelegate(const base::FilePath& exposed_dir, |
| 71 bool launch_elevated, | 71 bool launch_elevated, |
| 72 bool no_sandbox, | 72 bool no_sandbox, |
| 73 const base::EnvironmentMap& env, | 73 const base::EnvironmentMap& env, |
| 74 ChildProcessHost* host) | 74 ChildProcessHost* host) |
| 75 : exposed_dir_(exposed_dir), | 75 : exposed_dir_(exposed_dir), |
| 76 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 77 launch_elevated_(launch_elevated) | 77 launch_elevated_(launch_elevated) |
| 78 #elif defined(OS_POSIX) | 78 #elif defined(OS_POSIX) |
| 79 env_(env), | 79 env_(env) |
| 80 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 80 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 81 no_sandbox_(no_sandbox), | 81 , no_sandbox_(no_sandbox) |
| 82 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) | 82 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 83 ipc_fd_(host->TakeClientFileDescriptor()) | |
| 84 #endif // OS_WIN | 83 #endif // OS_WIN |
| 85 {} | 84 {} |
| 86 | 85 |
| 87 ~UtilitySandboxedProcessLauncherDelegate() override {} | 86 ~UtilitySandboxedProcessLauncherDelegate() override {} |
| 88 | 87 |
| 89 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
| 90 bool ShouldLaunchElevated() override { return launch_elevated_; } | 89 bool ShouldLaunchElevated() override { return launch_elevated_; } |
| 91 | 90 |
| 92 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { | 91 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { |
| 93 if (exposed_dir_.empty()) | 92 if (exposed_dir_.empty()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 110 #elif defined(OS_POSIX) | 109 #elif defined(OS_POSIX) |
| 111 | 110 |
| 112 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 111 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 113 ZygoteHandle* GetZygote() override { | 112 ZygoteHandle* GetZygote() override { |
| 114 if (no_sandbox_ || !exposed_dir_.empty()) | 113 if (no_sandbox_ || !exposed_dir_.empty()) |
| 115 return nullptr; | 114 return nullptr; |
| 116 return GetGenericZygote(); | 115 return GetGenericZygote(); |
| 117 } | 116 } |
| 118 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) | 117 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 119 base::EnvironmentMap GetEnvironment() override { return env_; } | 118 base::EnvironmentMap GetEnvironment() override { return env_; } |
| 120 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | |
| 121 #endif // OS_WIN | 119 #endif // OS_WIN |
| 122 | 120 |
| 123 SandboxType GetSandboxType() override { | 121 SandboxType GetSandboxType() override { |
| 124 return SANDBOX_TYPE_UTILITY; | 122 return SANDBOX_TYPE_UTILITY; |
| 125 } | 123 } |
| 126 | 124 |
| 127 private: | 125 private: |
| 128 base::FilePath exposed_dir_; | 126 base::FilePath exposed_dir_; |
| 129 | 127 |
| 130 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 131 bool launch_elevated_; | 129 bool launch_elevated_; |
| 132 #elif defined(OS_POSIX) | 130 #elif defined(OS_POSIX) |
| 133 base::EnvironmentMap env_; | 131 base::EnvironmentMap env_; |
| 134 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 132 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 135 bool no_sandbox_; | 133 bool no_sandbox_; |
| 136 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) | 134 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 137 base::ScopedFD ipc_fd_; | |
| 138 #endif // OS_WIN | 135 #endif // OS_WIN |
| 139 }; | 136 }; |
| 140 | 137 |
| 141 UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL; | 138 UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL; |
| 142 | 139 |
| 143 UtilityProcessHost* UtilityProcessHost::Create( | 140 UtilityProcessHost* UtilityProcessHost::Create( |
| 144 const scoped_refptr<UtilityProcessHostClient>& client, | 141 const scoped_refptr<UtilityProcessHostClient>& client, |
| 145 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner) { | 142 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner) { |
| 146 return new UtilityProcessHostImpl(client, client_task_runner); | 143 return new UtilityProcessHostImpl(client, client_task_runner); |
| 147 } | 144 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 base::WeakPtr<UtilityProcessHostImpl> host, | 421 base::WeakPtr<UtilityProcessHostImpl> host, |
| 425 int error_code) { | 422 int error_code) { |
| 426 if (!host) | 423 if (!host) |
| 427 return; | 424 return; |
| 428 | 425 |
| 429 host->OnProcessLaunchFailed(error_code); | 426 host->OnProcessLaunchFailed(error_code); |
| 430 delete host.get(); | 427 delete host.get(); |
| 431 } | 428 } |
| 432 | 429 |
| 433 } // namespace content | 430 } // namespace content |
| OLD | NEW |