OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/policy/policy_domain_descriptor.h" | |
6 | |
7 #include "base/stl_util.h" | |
8 #include "chrome/browser/policy/policy_bundle.h" | |
9 #include "chrome/browser/policy/policy_map.h" | |
10 #include "chrome/browser/policy/policy_schema.h" | |
11 | |
12 namespace policy { | |
13 | |
14 PolicyDomainDescriptor::PolicyDomainDescriptor(PolicyDomain domain) | |
15 : domain_(domain) {} | |
16 | |
17 void PolicyDomainDescriptor::AddComponent(const std::string& component_id, | |
18 scoped_ptr<PolicySchema> schema) { | |
19 const PolicySchema*& previous = schema_map_[component_id]; | |
20 delete previous; | |
21 previous = schema.release(); | |
22 } | |
23 | |
24 void PolicyDomainDescriptor::FilterBundle(PolicyBundle* bundle) const { | |
25 for (PolicyBundle::const_iterator it_bundle = bundle->begin(); | |
26 it_bundle != bundle->end(); ++it_bundle) { | |
27 const PolicyNamespace& ns = it_bundle->first; | |
28 if (ns.domain != domain_) | |
29 continue; | |
30 | |
31 SchemaMap::const_iterator it_schema = schema_map_.find(ns.component_id); | |
32 if (it_schema == schema_map_.end()) { | |
33 // Component ID not found. | |
34 bundle->Get(ns).Clear(); | |
35 continue; | |
36 } | |
37 | |
38 // TODO(joaodasilva): if a component is registered but doesn't have a schema | |
39 // then its policies aren't filtered. This behavior is enabled for M29 to | |
40 // allow a graceful update of the Legacy Browser Support extension; it'll | |
41 // be removed for M30. http://crbug.com/240704 | |
Mattias Nissler (ping if slow)
2013/05/15 10:24:06
Have you made sure that the extension gets updated
Joao da Silva
2013/05/19 13:17:55
Yes, I'm in sync with Julian here.
| |
42 if (!it_schema->second) | |
43 continue; | |
44 | |
45 const PolicySchema::TypeMap& type_map = it_schema->second->type_map(); | |
46 PolicyMap& map = bundle->Get(ns); | |
47 PolicyMap::const_iterator it_map = map.begin(); | |
48 while (it_map != map.end()) { | |
49 PolicySchema::TypeMap::const_iterator it_type = | |
50 type_map.find(it_map->first); | |
Mattias Nissler (ping if slow)
2013/05/15 10:24:06
Given these are both indexed by name, we might be
Joao da Silva
2013/05/19 13:17:55
This has changed after the PolicySchema changes.
| |
51 if (it_type == type_map.end() || | |
52 !it_map->second.value || | |
53 !it_map->second.value->IsType(it_type->second)) { | |
54 const std::string& name = it_map->first; | |
55 ++it_map; | |
56 map.Erase(name); | |
57 } else { | |
58 ++it_map; | |
59 } | |
60 } | |
61 } | |
62 } | |
63 | |
64 PolicyDomainDescriptor::~PolicyDomainDescriptor() { | |
65 STLDeleteValues(&schema_map_); | |
66 } | |
67 | |
68 } // namespace policy | |
OLD | NEW |