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

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

Issue 6532019: New policy protobuf protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix one more leak Created 9 years, 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/mock_configuration_policy_provider.h" 5 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "chrome/browser/policy/configuration_policy_pref_store.h" 8 #include "chrome/browser/policy/configuration_policy_pref_store.h"
9 9
10 namespace policy { 10 namespace policy {
11 11
12 MockConfigurationPolicyProvider::MockConfigurationPolicyProvider() 12 MockConfigurationPolicyProvider::MockConfigurationPolicyProvider()
13 : ConfigurationPolicyProvider( 13 : ConfigurationPolicyProvider(
14 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList()), 14 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList()),
15 initialization_complete_(false) { 15 initialization_complete_(false) {
16 } 16 }
17 17
18 MockConfigurationPolicyProvider::~MockConfigurationPolicyProvider() { 18 MockConfigurationPolicyProvider::~MockConfigurationPolicyProvider() {}
19 STLDeleteValues(&policy_map_);
20 }
21 19
22 void MockConfigurationPolicyProvider::AddPolicy(ConfigurationPolicyType policy, 20 void MockConfigurationPolicyProvider::AddPolicy(ConfigurationPolicyType policy,
23 Value* value) { 21 Value* value) {
24 std::swap(policy_map_[policy], value); 22 policy_map_.Set(policy, value);
25 delete value;
26 } 23 }
27 24
28 void MockConfigurationPolicyProvider::RemovePolicy( 25 void MockConfigurationPolicyProvider::RemovePolicy(
29 ConfigurationPolicyType policy) { 26 ConfigurationPolicyType policy) {
30 const PolicyMap::iterator entry = policy_map_.find(policy); 27 policy_map_.Erase(policy);
31 if (entry != policy_map_.end()) {
32 delete entry->second;
33 policy_map_.erase(entry);
34 }
35 } 28 }
36 29
37 void MockConfigurationPolicyProvider::SetInitializationComplete( 30 void MockConfigurationPolicyProvider::SetInitializationComplete(
38 bool initialization_complete) { 31 bool initialization_complete) {
39 initialization_complete_ = initialization_complete; 32 initialization_complete_ = initialization_complete;
40 } 33 }
41 34
42 bool MockConfigurationPolicyProvider::Provide( 35 bool MockConfigurationPolicyProvider::Provide(
43 ConfigurationPolicyStoreInterface* store) { 36 ConfigurationPolicyStoreInterface* store) {
44 for (PolicyMap::const_iterator current = policy_map_.begin(); 37 for (PolicyMap::const_iterator current = policy_map_.begin();
45 current != policy_map_.end(); ++current) { 38 current != policy_map_.end(); ++current) {
46 store->Apply(current->first, current->second->DeepCopy()); 39 store->Apply(current->first, current->second->DeepCopy());
47 } 40 }
48 return true; 41 return true;
49 } 42 }
50 43
51 bool MockConfigurationPolicyProvider::IsInitializationComplete() const { 44 bool MockConfigurationPolicyProvider::IsInitializationComplete() const {
52 return initialization_complete_; 45 return initialization_complete_;
53 } 46 }
54 47
55 } 48 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698