OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/policy_map.h" | 5 #include "chrome/browser/policy/policy_map.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 Set(i->first, i->second->DeepCopy()); | 45 Set(i->first, i->second->DeepCopy()); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 void PolicyMap::LoadFrom( | 49 void PolicyMap::LoadFrom( |
50 const DictionaryValue* policies, | 50 const DictionaryValue* policies, |
51 const ConfigurationPolicyProvider::PolicyDefinitionList* list) { | 51 const ConfigurationPolicyProvider::PolicyDefinitionList* list) { |
52 const ConfigurationPolicyProvider::PolicyDefinitionList::Entry* entry; | 52 const ConfigurationPolicyProvider::PolicyDefinitionList::Entry* entry; |
53 for (entry = list->begin; entry != list->end; ++entry) { | 53 for (entry = list->begin; entry != list->end; ++entry) { |
54 Value* value; | 54 Value* value; |
55 if (policies->Get(entry->name, &value) && value->IsType(entry->value_type)) | 55 if (policies->Get(entry->name, &value)) |
56 Set(entry->policy_type, value->DeepCopy()); | 56 Set(entry->policy_type, value->DeepCopy()); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 bool PolicyMap::Equals(const PolicyMap& other) const { | 60 bool PolicyMap::Equals(const PolicyMap& other) const { |
61 return other.map_.size() == map_.size() && | 61 return other.map_.size() == map_.size() && |
62 std::equal(map_.begin(), map_.end(), other.map_.begin(), MapEntryEquals); | 62 std::equal(map_.begin(), map_.end(), other.map_.begin(), MapEntryEquals); |
63 } | 63 } |
64 | 64 |
65 bool PolicyMap::empty() const { | 65 bool PolicyMap::empty() const { |
(...skipping 16 matching lines...) Expand all Loading... |
82 STLDeleteValues(&map_); | 82 STLDeleteValues(&map_); |
83 } | 83 } |
84 | 84 |
85 // static | 85 // static |
86 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, | 86 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, |
87 const PolicyMap::PolicyMapType::value_type& b) { | 87 const PolicyMap::PolicyMapType::value_type& b) { |
88 return a.first == b.first && Value::Equals(a.second, b.second); | 88 return a.first == b.first && Value::Equals(a.second, b.second); |
89 } | 89 } |
90 | 90 |
91 } // namespace policy | 91 } // namespace policy |
OLD | NEW |