Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Unified Diff: content/browser/ppapi_plugin_process_host.cc

Issue 177863002: Refactor configuration of sandboxes - first steps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix remaining nits and rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/plugin_process_host.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/ppapi_plugin_process_host.cc
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index f1a3171d0d0251f382fa25dcf61a6c347f8c208d..39c6bc30205244703b847bb2f21fa11dcab55373 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -21,6 +21,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/pepper_plugin_info.h"
#include "content/public/common/process_type.h"
+#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "ipc/ipc_switches.h"
#include "net/base/network_change_notifier.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -28,24 +29,30 @@
#if defined(OS_WIN)
#include "content/common/sandbox_win.h"
-#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "sandbox/win/src/sandbox_policy.h"
#endif
namespace content {
-#if defined(OS_WIN)
// NOTE: changes to this class need to be reviewed by the security team.
class PpapiPluginSandboxedProcessLauncherDelegate
: public content::SandboxedProcessLauncherDelegate {
public:
- explicit PpapiPluginSandboxedProcessLauncherDelegate(bool is_broker)
- : is_broker_(is_broker) {}
+ PpapiPluginSandboxedProcessLauncherDelegate(bool is_broker,
+ const PepperPluginInfo& info,
+ ChildProcessHost* host)
+ :
+#if defined(OS_POSIX)
+ info_(info),
+ ipc_fd_(host->TakeClientFileDescriptor()),
+#endif // OS_POSIX
+ is_broker_(is_broker) {}
+
virtual ~PpapiPluginSandboxedProcessLauncherDelegate() {}
- virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE {
- if (is_broker_)
- *in_sandbox = false;
+#if defined(OS_WIN)
+ virtual bool ShouldSandbox() OVERRIDE {
+ return !is_broker_;
}
virtual void PreSpawnTarget(sandbox::TargetPolicy* policy,
@@ -61,12 +68,27 @@ class PpapiPluginSandboxedProcessLauncherDelegate
*success = (result == sandbox::SBOX_ALL_OK);
}
+#elif defined(OS_POSIX)
+ virtual bool ShouldUseZygote() OVERRIDE {
+ const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
+ CommandLine::StringType plugin_launcher = browser_command_line
+ .GetSwitchValueNative(switches::kPpapiPluginLauncher);
+ return !is_broker_ && plugin_launcher.empty() && info_.is_sandboxed;
+ }
+ virtual int GetIpcFd() OVERRIDE {
+ return ipc_fd_;
+ }
+#endif // OS_WIN
+
private:
+#if defined(OS_POSIX)
+ const PepperPluginInfo& info_;
+ int ipc_fd_;
+#endif // OS_POSIX
bool is_broker_;
DISALLOW_COPY_AND_ASSIGN(PpapiPluginSandboxedProcessLauncherDelegate);
};
-#endif // OS_WIN
class PpapiPluginProcessHost::PluginNetworkObserver
: public net::NetworkChangeNotifier::IPAddressObserver,
@@ -333,18 +355,13 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
// plugin launcher means we need to use another process instead of just
// forking the zygote.
#if defined(OS_POSIX)
- bool use_zygote = !is_broker_ && plugin_launcher.empty() && info.is_sandboxed;
if (!info.is_sandboxed)
cmd_line->AppendSwitchASCII(switches::kNoSandbox, std::string());
#endif // OS_POSIX
process_->Launch(
-#if defined(OS_WIN)
- new PpapiPluginSandboxedProcessLauncherDelegate(is_broker_),
- false,
-#elif defined(OS_POSIX)
- use_zygote,
- base::EnvironmentMap(),
-#endif
+ new PpapiPluginSandboxedProcessLauncherDelegate(is_broker_,
+ info,
+ process_->GetHost()),
cmd_line);
return true;
}
« no previous file with comments | « content/browser/plugin_process_host.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698