Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / renderer / renderer_main_platform_delegate_android.cc
blob8ef130375a7f62d9e6a790ef23f415e84985d6df
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
3 // found in the LICENSE file.
5 #include "content/renderer/renderer_main_platform_delegate.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "content/public/common/content_switches.h"
11 #ifdef USE_SECCOMP_BPF
12 #include "content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.h"
13 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
14 #endif
16 namespace content {
18 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
19 const MainFunctionParams& parameters)
20 : parameters_(parameters) {
23 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
26 void RendererMainPlatformDelegate::PlatformInitialize() {
29 void RendererMainPlatformDelegate::PlatformUninitialize() {
32 bool RendererMainPlatformDelegate::EnableSandbox() {
33 #ifdef USE_SECCOMP_BPF
34 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
35 switches::kEnableSeccompFilterSandbox)) {
36 return true;
38 if (!sandbox::SandboxBPF::SupportsSeccompSandbox(
39 sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED)) {
40 LOG(WARNING) << "Seccomp-BPF sandbox enabled without kernel support. "
41 << "Ignoring flag and proceeding without seccomp sandbox.";
42 return true;
45 sandbox::SandboxBPF sandbox(new SandboxBPFBasePolicyAndroid());
46 CHECK(
47 sandbox.StartSandbox(sandbox::SandboxBPF::SeccompLevel::MULTI_THREADED));
48 #endif
49 return true;
52 } // namespace content