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/values.h" | 7 #include "base/values.h" |
8 #include "components/policy/core/common/policy_bundle.h" | 8 #include "components/policy/core/common/policy_bundle.h" |
9 #include "components/policy/core/common/policy_map.h" | 9 #include "components/policy/core/common/policy_map.h" |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 if (!schema->valid()) | 56 if (!schema->valid()) |
57 continue; | 57 continue; |
58 | 58 |
59 PolicyMap* map = it->second; | 59 PolicyMap* map = it->second; |
60 for (PolicyMap::const_iterator it_map = map->begin(); | 60 for (PolicyMap::const_iterator it_map = map->begin(); |
61 it_map != map->end();) { | 61 it_map != map->end();) { |
62 const std::string& policy_name = it_map->first; | 62 const std::string& policy_name = it_map->first; |
63 const base::Value* policy_value = it_map->second.value; | 63 const base::Value* policy_value = it_map->second.value; |
64 Schema policy_schema = schema->GetProperty(policy_name); | 64 Schema policy_schema = schema->GetProperty(policy_name); |
65 ++it_map; | 65 ++it_map; |
66 if (!policy_value || !policy_schema.Validate(*policy_value)) | 66 std::string error; |
67 if (!policy_value || !policy_schema.Validate(*policy_value, | |
68 SCHEMA_VERY_STRICT, &error)) | |
67 map->Erase(policy_name); | 69 map->Erase(policy_name); |
Joao da Silva
2014/01/22 10:49:53
You can log the error here, to assist extension de
binjin
2014/01/23 12:01:31
Done.
| |
68 } | 70 } |
69 } | 71 } |
70 } | 72 } |
71 | 73 |
72 bool SchemaMap::HasComponents() const { | 74 bool SchemaMap::HasComponents() const { |
73 for (DomainMap::const_iterator domain = map_.begin(); | 75 for (DomainMap::const_iterator domain = map_.begin(); |
74 domain != map_.end(); ++domain) { | 76 domain != map_.end(); ++domain) { |
75 if (domain->first == POLICY_DOMAIN_CHROME) | 77 if (domain->first == POLICY_DOMAIN_CHROME) |
76 continue; | 78 continue; |
77 if (!domain->second.empty()) | 79 if (!domain->second.empty()) |
(...skipping 18 matching lines...) Expand all Loading... | |
96 for (ComponentMap::const_iterator comp = components.begin(); | 98 for (ComponentMap::const_iterator comp = components.begin(); |
97 comp != components.end(); ++comp) { | 99 comp != components.end(); ++comp) { |
98 PolicyNamespace ns(domain->first, comp->first); | 100 PolicyNamespace ns(domain->first, comp->first); |
99 if (!other->GetSchema(ns)) | 101 if (!other->GetSchema(ns)) |
100 list->push_back(ns); | 102 list->push_back(ns); |
101 } | 103 } |
102 } | 104 } |
103 } | 105 } |
104 | 106 |
105 } // namespace policy | 107 } // namespace policy |
OLD | NEW |