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 #include "policy/policy_constants.h" | 10 #include "policy/policy_constants.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 Set(i->first, i->second->DeepCopy()); | 46 Set(i->first, i->second->DeepCopy()); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 void PolicyMap::LoadFrom( | 50 void PolicyMap::LoadFrom( |
51 const DictionaryValue* policies, | 51 const DictionaryValue* policies, |
52 const PolicyDefinitionList* list) { | 52 const PolicyDefinitionList* list) { |
53 const PolicyDefinitionList::Entry* entry; | 53 const PolicyDefinitionList::Entry* entry; |
54 for (entry = list->begin; entry != list->end; ++entry) { | 54 for (entry = list->begin; entry != list->end; ++entry) { |
55 Value* value; | 55 Value* value; |
56 if (policies->Get(entry->name, &value) && value->IsType(entry->value_type)) | 56 if (policies->Get(entry->name, &value)) |
57 Set(entry->policy_type, value->DeepCopy()); | 57 Set(entry->policy_type, value->DeepCopy()); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 bool PolicyMap::Equals(const PolicyMap& other) const { | 61 bool PolicyMap::Equals(const PolicyMap& other) const { |
62 return other.map_.size() == map_.size() && | 62 return other.map_.size() == map_.size() && |
63 std::equal(map_.begin(), map_.end(), other.map_.begin(), MapEntryEquals); | 63 std::equal(map_.begin(), map_.end(), other.map_.begin(), MapEntryEquals); |
64 } | 64 } |
65 | 65 |
66 bool PolicyMap::empty() const { | 66 bool PolicyMap::empty() const { |
(...skipping 16 matching lines...) Expand all Loading... |
83 STLDeleteValues(&map_); | 83 STLDeleteValues(&map_); |
84 } | 84 } |
85 | 85 |
86 // static | 86 // static |
87 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, | 87 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, |
88 const PolicyMap::PolicyMapType::value_type& b) { | 88 const PolicyMap::PolicyMapType::value_type& b) { |
89 return a.first == b.first && Value::Equals(a.second, b.second); | 89 return a.first == b.first && Value::Equals(a.second, b.second); |
90 } | 90 } |
91 | 91 |
92 } // namespace policy | 92 } // namespace policy |
OLD | NEW |