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_map.h" | 5 #include "components/policy/core/common/schema_map.h" |
6 | 6 |
| 7 #include "base/logging.h" |
7 #include "base/values.h" | 8 #include "base/values.h" |
8 #include "components/policy/core/common/policy_bundle.h" | 9 #include "components/policy/core/common/policy_bundle.h" |
9 #include "components/policy/core/common/policy_map.h" | 10 #include "components/policy/core/common/policy_map.h" |
10 | 11 |
11 namespace policy { | 12 namespace policy { |
12 | 13 |
13 SchemaMap::SchemaMap() {} | 14 SchemaMap::SchemaMap() {} |
14 | 15 |
15 SchemaMap::SchemaMap(DomainMap& map) { | 16 SchemaMap::SchemaMap(DomainMap& map) { |
16 map_.swap(map); | 17 map_.swap(map); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (!schema->valid()) | 57 if (!schema->valid()) |
57 continue; | 58 continue; |
58 | 59 |
59 PolicyMap* map = it->second; | 60 PolicyMap* map = it->second; |
60 for (PolicyMap::const_iterator it_map = map->begin(); | 61 for (PolicyMap::const_iterator it_map = map->begin(); |
61 it_map != map->end();) { | 62 it_map != map->end();) { |
62 const std::string& policy_name = it_map->first; | 63 const std::string& policy_name = it_map->first; |
63 const base::Value* policy_value = it_map->second.value; | 64 const base::Value* policy_value = it_map->second.value; |
64 Schema policy_schema = schema->GetProperty(policy_name); | 65 Schema policy_schema = schema->GetProperty(policy_name); |
65 ++it_map; | 66 ++it_map; |
66 if (!policy_value || !policy_schema.Validate(*policy_value)) | 67 std::string error; |
| 68 if (!policy_value || |
| 69 !policy_schema.Validate(*policy_value, SCHEMA_STRICT, &error)) { |
| 70 LOG(ERROR) << "Dropping policy " << policy_name << " for " |
| 71 << it->first.component_id |
| 72 << " because it's not valid: " << error; |
67 map->Erase(policy_name); | 73 map->Erase(policy_name); |
| 74 } |
68 } | 75 } |
69 } | 76 } |
70 } | 77 } |
71 | 78 |
72 bool SchemaMap::HasComponents() const { | 79 bool SchemaMap::HasComponents() const { |
73 for (DomainMap::const_iterator domain = map_.begin(); | 80 for (DomainMap::const_iterator domain = map_.begin(); |
74 domain != map_.end(); ++domain) { | 81 domain != map_.end(); ++domain) { |
75 if (domain->first == POLICY_DOMAIN_CHROME) | 82 if (domain->first == POLICY_DOMAIN_CHROME) |
76 continue; | 83 continue; |
77 if (!domain->second.empty()) | 84 if (!domain->second.empty()) |
(...skipping 18 matching lines...) Expand all Loading... |
96 for (ComponentMap::const_iterator comp = components.begin(); | 103 for (ComponentMap::const_iterator comp = components.begin(); |
97 comp != components.end(); ++comp) { | 104 comp != components.end(); ++comp) { |
98 PolicyNamespace ns(domain->first, comp->first); | 105 PolicyNamespace ns(domain->first, comp->first); |
99 if (!other->GetSchema(ns)) | 106 if (!other->GetSchema(ns)) |
100 list->push_back(ns); | 107 list->push_back(ns); |
101 } | 108 } |
102 } | 109 } |
103 } | 110 } |
104 | 111 |
105 } // namespace policy | 112 } // namespace policy |
OLD | NEW |