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 3// found in the LICENSE file. 4 5#include "chrome/browser/policy/mock_configuration_policy_provider.h" 6 7#include "base/stl_util-inl.h" 8#include "chrome/browser/policy/configuration_policy_pref_store.h" 9 10namespace policy { 11 12MockConfigurationPolicyProvider::MockConfigurationPolicyProvider() 13 : ConfigurationPolicyProvider( 14 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList()), 15 initialization_complete_(false) { 16} 17 18MockConfigurationPolicyProvider::~MockConfigurationPolicyProvider() {} 19 20void MockConfigurationPolicyProvider::AddPolicy(ConfigurationPolicyType policy, 21 Value* value) { 22 policy_map_.Set(policy, value); 23} 24 25void MockConfigurationPolicyProvider::RemovePolicy( 26 ConfigurationPolicyType policy) { 27 policy_map_.Erase(policy); 28} 29 30void MockConfigurationPolicyProvider::SetInitializationComplete( 31 bool initialization_complete) { 32 initialization_complete_ = initialization_complete; 33} 34 35bool MockConfigurationPolicyProvider::Provide( 36 ConfigurationPolicyStoreInterface* store) { 37 for (PolicyMap::const_iterator current = policy_map_.begin(); 38 current != policy_map_.end(); ++current) { 39 store->Apply(current->first, current->second->DeepCopy()); 40 } 41 return true; 42} 43 44bool MockConfigurationPolicyProvider::IsInitializationComplete() const { 45 return initialization_complete_; 46} 47 48} // namespace policy 49