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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_
#define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_
#include <stdint.h>
#include "base/memory/raw_ptr.h"
#include "base/values.h"
#include "components/policy/policy_export.h"
namespace policy {
namespace internal {
// These types are used internally by the SchemaOwner parser, and by the
// compile-time code generator. They shouldn't be used directly.
// Represents the type of one policy, or an item of a list policy, or a
// property of a map policy.
struct POLICY_EXPORT SchemaNode {
// The policy type.
base::Value::Type type;
// If |type| is Type::DICT then |extra| is an offset into
// SchemaData::properties_nodes that indexes the PropertiesNode describing
// the entries of this dictionary.
//
// If |type| is Type::LIST then |extra| is an offset into
// SchemaData::schema_nodes that indexes the SchemaNode describing the items
// of this list.
//
// If |type| is Type::INTEGER or Type::STRING, and contains corresponding
// restriction (enumeration of possible values, or range for integer), then
// |extra| is an offset into SchemaData::restriction_nodes that indexes the
// RestrictionNode describing the restriction on the value.
//
// Otherwise extra is -1 and is invalid.
int16_t extra;
// True if this value is sensitive and should be masked before displaying it
// to the user.
bool is_sensitive_value;
// True if any of its children has |is_sensitive_value|==true.
bool has_sensitive_children;
};
// Represents an entry of a map policy.
struct POLICY_EXPORT PropertyNode {
// The entry key.
const char* key;
// An offset into SchemaData::schema_nodes that indexes the SchemaNode
// describing the structure of this key.
int16_t schema;
};
// Represents the list of keys of a map policy.
struct POLICY_EXPORT PropertiesNode {
// An offset into SchemaData::property_nodes that indexes the PropertyNode
// describing the first known property of this map policy.
int16_t begin;
// An offset into SchemaData::property_nodes that indexes the PropertyNode
// right beyond the last known property of this map policy.
//
// If |begin == end| then the map policy that this PropertiesNode corresponds
// to does not have known properties.
//
// Note that the range [begin, end) is sorted by PropertyNode::key, so that
// properties can be looked up by binary searching in the range.
int16_t end;
// An offset into SchemaData::property_nodes that indexes the PropertyNode
// right beyond the last known pattern property.
//
// [end, pattern_end) is the range that covers all pattern properties
// defined. It's not required to be sorted.
int16_t pattern_end;
// An offset into SchemaData::required_properties that indexes the first
// required property of this map policy.
int16_t required_begin;
// An offset into SchemaData::required_properties that indexes the property
// right beyond the last required property.
//
// If |required_begin == required_end|, then the map policy that this
// PropertiesNode corresponds to does not have any required properties.
//
// Note that the range [required_begin, required_end) is not sorted.
int16_t required_end;
// If this map policy supports keys with any value (besides the well-known
// values described in the range [begin, end)) then |additional| is an offset
// into SchemaData::schema_nodes that indexes the SchemaNode describing the
// structure of the values for those keys. Otherwise |additional| is -1 and
// is invalid.
int16_t additional;
};
// Represents the restriction on Type::INTEGER or Type::STRING instance of
// base::Value.
union POLICY_EXPORT RestrictionNode {
// Offsets into SchemaData::int_enums or SchemaData::string_enums, the
// entry of which describes the enumeration of all possible values of
// corresponding integer or string value. |offset_begin| being strictly less
// than |offset_end| is assumed.
struct EnumerationRestriction {
int offset_begin;
int offset_end;
} enumeration_restriction;
// For integer type only, represents that all values between |min_value|
// and |max_value| can be choosen. Note that integer type in base::Value
// is bounded, so this can also be used if only one of |min_value| and
// |max_value| is stated. |max_value| being greater or equal to |min_value|
// is assumed.
struct RangedRestriction {
int max_value;
int min_value;
} ranged_restriction;
// For string type only, requires |pattern_index| and |pattern_index_backup|
// to be exactly the same. And it's an offset into SchemaData::string_enums
// which contains the regular expression that the target string must follow.
struct StringPatternRestriction {
int pattern_index;
int pattern_index_backup;
} string_pattern_restriction;
};
// Contains arrays of related nodes. All of the offsets in these nodes reference
// other nodes in these arrays.
struct POLICY_EXPORT SchemaData {
raw_ptr<const SchemaNode, DanglingUntriaged | AllowPtrArithmetic>
schema_nodes;
raw_ptr<const PropertyNode, DanglingUntriaged | AllowPtrArithmetic>
property_nodes;
raw_ptr<const PropertiesNode, DanglingUntriaged | AllowPtrArithmetic>
properties_nodes;
raw_ptr<const RestrictionNode, DanglingUntriaged | AllowPtrArithmetic>
restriction_nodes;
raw_ptr<const char* const, DanglingUntriaged | AllowPtrArithmetic>
required_properties;
raw_ptr<const int, DanglingUntriaged | AllowPtrArithmetic> int_enums;
raw_ptr<const char* const, DanglingUntriaged | AllowPtrArithmetic>
string_enums;
int validation_schema_root_index;
};
} // namespace internal
} // namespace policy
#endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_
|