File: web_sandbox_flags.h

package info (click to toggle)
qtwebengine-opensource-src 5.15.18%2Bdfsg-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 2,115,048 kB
  • sloc: cpp: 13,169,354; ansic: 4,248,321; javascript: 1,917,440; python: 554,858; asm: 529,966; xml: 496,623; java: 151,702; objc: 80,776; perl: 73,361; sh: 71,244; cs: 30,383; makefile: 21,992; yacc: 9,125; tcl: 8,500; php: 5,896; sql: 5,518; pascal: 4,510; lex: 2,884; lisp: 2,727; ruby: 559; awk: 200; sed: 40
file content (72 lines) | stat: -rw-r--r-- 2,481 bytes parent folder | download | duplicates (4)
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
// Copyright 2020 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.

#ifndef SERVICES_NETWORK_PUBLIC_CPP_WEB_SANDBOX_FLAGS_H_
#define SERVICES_NETWORK_PUBLIC_CPP_WEB_SANDBOX_FLAGS_H_

#include <cstdint>
#include <string>
#include "base/component_export.h"
#include "base/strings/string_piece_forward.h"

namespace network {
namespace mojom {

enum class WebSandboxFlags : int32_t;

inline constexpr WebSandboxFlags operator&(WebSandboxFlags a,
                                           WebSandboxFlags b) {
  return static_cast<WebSandboxFlags>(static_cast<int>(a) &
                                      static_cast<int>(b));
}

inline constexpr WebSandboxFlags operator|(WebSandboxFlags a,
                                           WebSandboxFlags b) {
  return static_cast<WebSandboxFlags>(static_cast<int>(a) |
                                      static_cast<int>(b));
}

inline WebSandboxFlags& operator|=(WebSandboxFlags& a, WebSandboxFlags b) {
  return a = a | b;
}

inline WebSandboxFlags& operator&=(WebSandboxFlags& a, WebSandboxFlags b) {
  return a = a & b;
}

inline constexpr WebSandboxFlags operator~(WebSandboxFlags flags) {
  return static_cast<WebSandboxFlags>(~static_cast<int>(flags));
}

}  // namespace mojom

// The output of |ParseSandboxPolicy(input)|.
struct WebSandboxFlagsParsingResult {
  // The complement of the parsed WebSandboxFlags policy.
  // TODO(arthursonzogni): Update the caller of ParseWebSandboxPolicy(). They
  // should directly use the policy instead of its complement.
  mojom::WebSandboxFlags flags;

  // The console error message to be displayed for invalid input. Empty when
  // there are no errors.
  std::string error_message;
};

// Parses a WebSandboxPolicy. The input is an unordered set of unique
// space-separated sandbox tokens.
// See: http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox
//
// |ignored_flags| is used by experimental features to ignore some tokens when
// the corresponding feature is off.
//
// Supposed to be called only from a (semi-)sandboxed processes, i.e. from blink
// or from the network process. See: docs/security/rule-of-2.md.
COMPONENT_EXPORT(NETWORK_CPP)
WebSandboxFlagsParsingResult ParseWebSandboxPolicy(
    const base::StringPiece& input,
    mojom::WebSandboxFlags ignored_flags);

}  // namespace network

#endif  // SERVICES_NETWORK_PUBLIC_CPP_SANDBOX_FLAGS_H_