summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/mock_configuration_policy_provider.cc
blob: 4f11497ac5a97f81df6f3d0a25d349581dd80701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/policy/mock_configuration_policy_provider.h"

#include "chrome/browser/policy/configuration_policy_pref_store.h"

namespace policy {

MockConfigurationPolicyProvider::MockConfigurationPolicyProvider()
    : ConfigurationPolicyProvider(
        ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList()) {
}

MockConfigurationPolicyProvider::~MockConfigurationPolicyProvider() {
  STLDeleteValues(&policy_map_);
}

void MockConfigurationPolicyProvider::AddPolicy(ConfigurationPolicyType policy,
                                                Value* value) {
  std::swap(policy_map_[policy], value);
  delete value;
}

bool MockConfigurationPolicyProvider::Provide(
    ConfigurationPolicyStoreInterface* store) {
  for (PolicyMap::const_iterator current = policy_map_.begin();
       current != policy_map_.end(); ++current) {
    store->Apply(current->first, current->second->DeepCopy());
  }
  return true;
}

}