OLD | NEW |
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 #include "components/policy/core/common/schema.h" | 5 #include "components/policy/core/common/schema.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <climits> | 8 #include <climits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 // Checks for invalid attributes at the top-level. | 968 // Checks for invalid attributes at the top-level. |
969 if (dict->HasKey(schema::kAdditionalProperties) || | 969 if (dict->HasKey(schema::kAdditionalProperties) || |
970 dict->HasKey(schema::kPatternProperties)) { | 970 dict->HasKey(schema::kPatternProperties)) { |
971 *error = "\"additionalProperties\" and \"patternProperties\" are not " | 971 *error = "\"additionalProperties\" and \"patternProperties\" are not " |
972 "supported at the main schema."; | 972 "supported at the main schema."; |
973 return Schema(); | 973 return Schema(); |
974 } | 974 } |
975 | 975 |
976 scoped_refptr<const InternalStorage> storage = | 976 scoped_refptr<const InternalStorage> storage = |
977 InternalStorage::ParseSchema(*dict, error); | 977 InternalStorage::ParseSchema(*dict, error); |
978 if (!storage) | 978 if (!storage.get()) |
979 return Schema(); | 979 return Schema(); |
980 return Schema(storage, storage->root_node()); | 980 return Schema(storage, storage->root_node()); |
981 } | 981 } |
982 | 982 |
983 base::Value::Type Schema::type() const { | 983 base::Value::Type Schema::type() const { |
984 CHECK(valid()); | 984 CHECK(valid()); |
985 return node_->type; | 985 return node_->type; |
986 } | 986 } |
987 | 987 |
988 Schema::Iterator Schema::GetPropertiesIterator() const { | 988 Schema::Iterator Schema::GetPropertiesIterator() const { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 return false; | 1099 return false; |
1100 } else { | 1100 } else { |
1101 int index = rnode->string_pattern_restriction.pattern_index; | 1101 int index = rnode->string_pattern_restriction.pattern_index; |
1102 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup); | 1102 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup); |
1103 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index)); | 1103 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index)); |
1104 return re2::RE2::PartialMatch(str, *regex); | 1104 return re2::RE2::PartialMatch(str, *regex); |
1105 } | 1105 } |
1106 } | 1106 } |
1107 | 1107 |
1108 } // namespace policy | 1108 } // namespace policy |
OLD | NEW |