| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/bootstrap_sandbox_mac.h" | 5 #include "content/browser/bootstrap_sandbox_mac.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const ChildProcessData& data) OVERRIDE; | 33 const ChildProcessData& data) OVERRIDE; |
| 34 virtual void BrowserChildProcessCrashed( | 34 virtual void BrowserChildProcessCrashed( |
| 35 const ChildProcessData& data) OVERRIDE; | 35 const ChildProcessData& data) OVERRIDE; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 friend struct DefaultSingletonTraits<BootstrapSandboxPolicy>; | 38 friend struct DefaultSingletonTraits<BootstrapSandboxPolicy>; |
| 39 BootstrapSandboxPolicy(); | 39 BootstrapSandboxPolicy(); |
| 40 virtual ~BootstrapSandboxPolicy(); | 40 virtual ~BootstrapSandboxPolicy(); |
| 41 | 41 |
| 42 void RegisterSandboxPolicies(); | 42 void RegisterSandboxPolicies(); |
| 43 void RegisterNPAPIPolicy(); | |
| 44 | 43 |
| 45 scoped_ptr<sandbox::BootstrapSandbox> sandbox_; | 44 scoped_ptr<sandbox::BootstrapSandbox> sandbox_; |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 BootstrapSandboxPolicy* BootstrapSandboxPolicy::GetInstance() { | 47 BootstrapSandboxPolicy* BootstrapSandboxPolicy::GetInstance() { |
| 49 return Singleton<BootstrapSandboxPolicy>::get(); | 48 return Singleton<BootstrapSandboxPolicy>::get(); |
| 50 } | 49 } |
| 51 | 50 |
| 52 void BootstrapSandboxPolicy::BrowserChildProcessHostDisconnected( | 51 void BootstrapSandboxPolicy::BrowserChildProcessHostDisconnected( |
| 53 const ChildProcessData& data) { | 52 const ChildProcessData& data) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 CHECK(sandbox_.get()); | 63 CHECK(sandbox_.get()); |
| 65 BrowserChildProcessObserver::Add(this); | 64 BrowserChildProcessObserver::Add(this); |
| 66 RegisterSandboxPolicies(); | 65 RegisterSandboxPolicies(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 BootstrapSandboxPolicy::~BootstrapSandboxPolicy() { | 68 BootstrapSandboxPolicy::~BootstrapSandboxPolicy() { |
| 70 BrowserChildProcessObserver::Remove(this); | 69 BrowserChildProcessObserver::Remove(this); |
| 71 } | 70 } |
| 72 | 71 |
| 73 void BootstrapSandboxPolicy::RegisterSandboxPolicies() { | 72 void BootstrapSandboxPolicy::RegisterSandboxPolicies() { |
| 74 RegisterNPAPIPolicy(); | |
| 75 } | |
| 76 | |
| 77 void BootstrapSandboxPolicy::RegisterNPAPIPolicy() { | |
| 78 sandbox::BootstrapSandboxPolicy policy; | |
| 79 policy.default_rule = sandbox::Rule(sandbox::POLICY_ALLOW); | |
| 80 policy.rules[kBootstrapPortNameForNPAPIPlugins] = | |
| 81 sandbox::Rule(sandbox_->real_bootstrap_port()); | |
| 82 sandbox_->RegisterSandboxPolicy(SANDBOX_TYPE_NPAPI, policy); | |
| 83 } | 73 } |
| 84 | 74 |
| 85 } // namespace | 75 } // namespace |
| 86 | 76 |
| 87 bool ShouldEnableBootstrapSandbox() { | 77 bool ShouldEnableBootstrapSandbox() { |
| 88 return base::mac::IsOSMountainLionOrEarlier() || | 78 return base::mac::IsOSMountainLionOrEarlier() || |
| 89 base::mac::IsOSMavericks(); | 79 base::mac::IsOSMavericks(); |
| 90 } | 80 } |
| 91 | 81 |
| 92 sandbox::BootstrapSandbox* GetBootstrapSandbox() { | 82 sandbox::BootstrapSandbox* GetBootstrapSandbox() { |
| 93 return BootstrapSandboxPolicy::GetInstance()->sandbox(); | 83 return BootstrapSandboxPolicy::GetInstance()->sandbox(); |
| 94 } | 84 } |
| 95 | 85 |
| 96 } // namespace content | 86 } // namespace content |
| OLD | NEW |