Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/policy/policy_map.cc

Issue 8258018: Generate Chrome policy definition list from policy_templates.json. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the unittest fix Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/policy/policy_map.h ('k') | chrome/browser/policy/user_policy_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11
11 namespace policy { 12 namespace policy {
12 13
13 PolicyMap::PolicyMap() { 14 PolicyMap::PolicyMap() {
14 } 15 }
15 16
16 PolicyMap::~PolicyMap() { 17 PolicyMap::~PolicyMap() {
17 Clear(); 18 Clear();
18 } 19 }
19 20
(...skipping 21 matching lines...) Expand all
41 42
42 void PolicyMap::CopyFrom(const PolicyMap& other) { 43 void PolicyMap::CopyFrom(const PolicyMap& other) {
43 Clear(); 44 Clear();
44 for (const_iterator i = other.begin(); i != other.end(); ++i) { 45 for (const_iterator i = other.begin(); i != other.end(); ++i) {
45 Set(i->first, i->second->DeepCopy()); 46 Set(i->first, i->second->DeepCopy());
46 } 47 }
47 } 48 }
48 49
49 void PolicyMap::LoadFrom( 50 void PolicyMap::LoadFrom(
50 const DictionaryValue* policies, 51 const DictionaryValue* policies,
51 const ConfigurationPolicyProvider::PolicyDefinitionList* list) { 52 const PolicyDefinitionList* list) {
52 const ConfigurationPolicyProvider::PolicyDefinitionList::Entry* entry; 53 const PolicyDefinitionList::Entry* entry;
53 for (entry = list->begin; entry != list->end; ++entry) { 54 for (entry = list->begin; entry != list->end; ++entry) {
54 Value* value; 55 Value* value;
55 if (policies->Get(entry->name, &value) && value->IsType(entry->value_type)) 56 if (policies->Get(entry->name, &value) && value->IsType(entry->value_type))
56 Set(entry->policy_type, value->DeepCopy()); 57 Set(entry->policy_type, value->DeepCopy());
57 } 58 }
58 } 59 }
59 60
60 bool PolicyMap::Equals(const PolicyMap& other) const { 61 bool PolicyMap::Equals(const PolicyMap& other) const {
61 return other.map_.size() == map_.size() && 62 return other.map_.size() == map_.size() &&
62 std::equal(map_.begin(), map_.end(), other.map_.begin(), MapEntryEquals); 63 std::equal(map_.begin(), map_.end(), other.map_.begin(), MapEntryEquals);
(...skipping 19 matching lines...) Expand all
82 STLDeleteValues(&map_); 83 STLDeleteValues(&map_);
83 } 84 }
84 85
85 // static 86 // static
86 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, 87 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a,
87 const PolicyMap::PolicyMapType::value_type& b) { 88 const PolicyMap::PolicyMapType::value_type& b) {
88 return a.first == b.first && Value::Equals(a.second, b.second); 89 return a.first == b.first && Value::Equals(a.second, b.second);
89 } 90 }
90 91
91 } // namespace policy 92 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_map.h ('k') | chrome/browser/policy/user_policy_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698