summaryrefslogtreecommitdiff
path: root/www/chromium/files/sandbox_freebsd.cc
blob: 87db8e4a4724314992033315e7bd85668fd469dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sandbox/policy/freebsd/sandbox_freebsd.h"

#include <string>

#include "base/logging.h"
#include "base/memory/singleton.h"
#include "sandbox/policy/switches.h"

namespace sandbox {
namespace policy {

SandboxFreeBSD::SandboxFreeBSD()
    : initialize_sandbox_ran_(false) {
}

SandboxFreeBSD::~SandboxFreeBSD() {
}

// static
SandboxFreeBSD* SandboxFreeBSD::GetInstance() {
  SandboxFreeBSD* instance = base::Singleton<SandboxFreeBSD>::get();
  CHECK(instance);
  return instance;
}

// static
std::string SandboxFreeBSD::GetSandboxTypeInEnglish(SandboxType sandbox_type) {
  switch (sandbox_type) {
    case SandboxType::kNoSandbox:
      return "Unsandboxed";
    case SandboxType::kRenderer:
      return "Renderer";
    case SandboxType::kUtility:
      return "Utility";
    case SandboxType::kGpu:
      return "GPU";
    case SandboxType::kPpapi:
      return "PPAPI";
    case SandboxType::kNetwork:
      return "Network";
    case SandboxType::kCdm:
      return "CDM";
    case SandboxType::kPrintCompositor:
      return "Print Compositor";
    case SandboxType::kAudio:
      return "Audio";
    case SandboxType::kSpeechRecognition:
      return "Speech Recognition";
    case SandboxType::kService:
      return "Service";
    case SandboxType::kVideoCapture:
      return "Video Capture";
    default:
      return "Unknown";
  }
}

bool SandboxFreeBSD::InitializeSandbox(SandboxType sandbox_type) {
  DCHECK(!initialize_sandbox_ran_);
  initialize_sandbox_ran_ = true;

  base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();

  if (command_line->HasSwitch(switches::kNoSandbox))
    return true;

  const std::string process_type = command_line->GetSwitchValueASCII(switches::kProcessType);

  VLOG(1) << "SandboxFreeBSD::InitializeSandbox: process_type="
          << process_type << " sandbox_type=" << GetSandboxTypeInEnglish(sandbox_type);

  return true;
}

bool SandboxFreeBSD::IsSandboxed() {
  return false;
}

} // namespace policy
} // namespace sandbox