Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(861)

Side by Side Diff: components/policy/core/common/schema_internal.h

Issue 138003003: Add additional restriction to policy schema internal (part1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_
7 7
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/policy/policy_export.h" 9 #include "components/policy/policy_export.h"
10 10
(...skipping 10 matching lines...) Expand all
21 base::Value::Type type; 21 base::Value::Type type;
22 22
23 // If |type| is TYPE_DICTIONARY then |extra| is an offset into 23 // If |type| is TYPE_DICTIONARY then |extra| is an offset into
24 // SchemaData::properties_nodes that indexes the PropertiesNode describing 24 // SchemaData::properties_nodes that indexes the PropertiesNode describing
25 // the entries of this dictionary. 25 // the entries of this dictionary.
26 // 26 //
27 // If |type| is TYPE_LIST then |extra| is an offset into 27 // If |type| is TYPE_LIST then |extra| is an offset into
28 // SchemaData::schema_nodes that indexes the SchemaNode describing the items 28 // SchemaData::schema_nodes that indexes the SchemaNode describing the items
29 // of this list. 29 // of this list.
30 // 30 //
31 // If |type| is TYPE_INTEGER or TYPE_STRING, and contains corresponding
32 // restriction (enumeration of possible values, or range for integer), then
33 // |extra| is an offset into SchemaData::restriction_nodes that indexes the
34 // RestrictionNode describing the restriction on the value.
35 //
31 // Otherwise extra is -1 and is invalid. 36 // Otherwise extra is -1 and is invalid.
32 int extra; 37 int extra;
33 }; 38 };
34 39
35 // Represents an entry of a map policy. 40 // Represents an entry of a map policy.
36 struct POLICY_EXPORT PropertyNode { 41 struct POLICY_EXPORT PropertyNode {
37 // The entry key. 42 // The entry key.
38 const char* key; 43 const char* key;
39 44
40 // An offset into SchemaData::schema_nodes that indexes the SchemaNode 45 // An offset into SchemaData::schema_nodes that indexes the SchemaNode
(...skipping 18 matching lines...) Expand all
59 int end; 64 int end;
60 65
61 // If this map policy supports keys with any value (besides the well-known 66 // If this map policy supports keys with any value (besides the well-known
62 // values described in the range [begin, end)) then |additional| is an offset 67 // values described in the range [begin, end)) then |additional| is an offset
63 // into SchemaData::schema_nodes that indexes the SchemaNode describing the 68 // into SchemaData::schema_nodes that indexes the SchemaNode describing the
64 // structure of the values for those keys. Otherwise |additional| is -1 and 69 // structure of the values for those keys. Otherwise |additional| is -1 and
65 // is invalid. 70 // is invalid.
66 int additional; 71 int additional;
67 }; 72 };
68 73
74 // Represents the restriction on TYPE_INTEGER or TYPE_STRING instance of
75 // base::Value.
76 union POLICY_EXPORT RestrictionNode {
77 // Offsets into SchemaData::int_enums or SchemaData::string_enums, the
78 // entry of which describes the enumeration of all possible values of
79 // corresponding integer or string value. |offset_begin| being strictly less
80 // than |offset_end| is assumed.
81 struct EnumerationRestriction {
82 int offset_begin;
83 int offset_end;
84 } enumeration_restriction;
85
86 // For integer type only, represents that all values between |min_value|
87 // and |max_value| can be choosen. Note that integer type in base::Value
88 // is bounded, so this can also be used if only one of |min_value| and
89 // |max_value| is stated. |max_value| being greater or equal to |min_value|
90 // is assumed.
91 struct RangedRestriction {
92 int max_value;
93 int min_value;
94 } ranged_restriction;
95 };
96
97
69 // Contains arrays of related nodes. All of the offsets in these nodes reference 98 // Contains arrays of related nodes. All of the offsets in these nodes reference
70 // other nodes in these arrays. 99 // other nodes in these arrays.
71 struct POLICY_EXPORT SchemaData { 100 struct POLICY_EXPORT SchemaData {
72 const SchemaNode* schema_nodes; 101 const SchemaNode* schema_nodes;
73 const PropertyNode* property_nodes; 102 const PropertyNode* property_nodes;
74 const PropertiesNode* properties_nodes; 103 const PropertiesNode* properties_nodes;
104 const RestrictionNode* restriction_nodes;
105
106 const int* int_enums;
107 const char** string_enums;
75 }; 108 };
76 109
77 } // namespace internal 110 } // namespace internal
78 } // namespace policy 111 } // namespace policy
79 112
80 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ 113 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698