Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / bootstrap_sandbox_manager_mac.h
blob72233cbebb06f41f51b8a8992bb9e60eca37e0ff
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BOOTSTRAP_SANDBOX_MANAGER_MAC_H_
6 #define CONTENT_BROWSER_BOOTSTRAP_SANDBOX_MANAGER_MAC_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h"
10 #include "content/public/browser/browser_child_process_observer.h"
11 #include "content/public/browser/render_process_host_observer.h"
12 #include "content/public/common/sandbox_type.h"
14 namespace sandbox {
15 class BootstrapSandbox;
16 struct BootstrapSandboxPolicy;
19 namespace content {
21 // This class is responsible for creating the BootstrapSandbox global
22 // singleton, as well as registering all associated policies with it.
24 // This class is thread-safe.
25 class BootstrapSandboxManager : public BrowserChildProcessObserver,
26 public RenderProcessHostObserver {
27 public:
28 // Whether or not the bootstrap sandbox should be enabled globally.
29 static bool ShouldEnable();
31 // Gets the singleton instance. The first call to this function, which
32 // instantiates the object, must be on the UI thread.
33 static BootstrapSandboxManager* GetInstance();
35 // Whether or not the bootstrap sandbox applies to the given sandbox type.
36 bool EnabledForSandbox(SandboxType sandbox_type);
38 // BrowserChildProcessObserver:
39 void BrowserChildProcessHostDisconnected(
40 const ChildProcessData& data) override;
41 void BrowserChildProcessCrashed(
42 const ChildProcessData& data,
43 int exit_code) override;
45 // RenderProcessHostObserver:
46 void RenderProcessExited(RenderProcessHost* host,
47 base::TerminationStatus status,
48 int exit_code) override;
50 sandbox::BootstrapSandbox* sandbox() const { return sandbox_.get(); }
52 private:
53 friend struct base::DefaultSingletonTraits<BootstrapSandboxManager>;
54 BootstrapSandboxManager();
55 ~BootstrapSandboxManager() override;
57 void RegisterSandboxPolicies();
58 void RegisterRendererPolicy();
60 void AddBaselinePolicy(sandbox::BootstrapSandboxPolicy* policy);
62 scoped_ptr<sandbox::BootstrapSandbox> sandbox_;
64 DISALLOW_COPY_AND_ASSIGN(BootstrapSandboxManager);
67 } // namespace content
69 #endif // CONTENT_BROWSER_BOOTSTRAP_SANDBOX_MANAGER_MAC_H_