| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_STORE_H_ |
| 6 #define CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_STORE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
| 13 #include "chrome/browser/policy/configuration_policy_store.h" | 13 #include "chrome/browser/policy/configuration_policy_store_interface.h" |
| 14 | 14 |
| 15 namespace policy { | 15 namespace policy { |
| 16 | 16 |
| 17 // Mock ConfigurationPolicyStore implementation that records values for policy | 17 // Mock ConfigurationPolicyStore implementation that records values for policy |
| 18 // settings as they get set. | 18 // settings as they get set. |
| 19 class MockConfigurationPolicyStore : public ConfigurationPolicyStore { | 19 class MockConfigurationPolicyStore : public ConfigurationPolicyStoreInterface { |
| 20 public: | 20 public: |
| 21 typedef std::map<ConfigurationPolicyType, Value*> PolicyMap; |
| 22 |
| 21 MockConfigurationPolicyStore() {} | 23 MockConfigurationPolicyStore() {} |
| 22 ~MockConfigurationPolicyStore() { | 24 ~MockConfigurationPolicyStore() { |
| 23 STLDeleteValues(&policy_map_); | 25 STLDeleteValues(&policy_map_); |
| 24 } | 26 } |
| 25 | 27 |
| 26 typedef std::map<ConfigurationPolicyStore::PolicyType, Value*> PolicyMap; | 28 const PolicyMap& policy_map() const { return policy_map_; } |
| 27 const PolicyMap& policy_map() { return policy_map_; } | |
| 28 | 29 |
| 29 // Get a value for the given policy. Returns NULL if that key doesn't exist. | 30 // Get a value for the given policy. Returns NULL if that key doesn't exist. |
| 30 const Value* Get(ConfigurationPolicyStore::PolicyType type) const { | 31 const Value* Get(ConfigurationPolicyType type) const { |
| 31 PolicyMap::const_iterator entry(policy_map_.find(type)); | 32 PolicyMap::const_iterator entry(policy_map_.find(type)); |
| 32 return entry == policy_map_.end() ? NULL : entry->second; | 33 return entry == policy_map_.end() ? NULL : entry->second; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // ConfigurationPolicyStore implementation. | 36 // ConfigurationPolicyStore implementation. |
| 36 virtual void Apply(PolicyType policy, Value* value) { | 37 virtual void Apply(ConfigurationPolicyType policy, Value* value) { |
| 37 std::swap(policy_map_[policy], value); | 38 std::swap(policy_map_[policy], value); |
| 38 delete value; | 39 delete value; |
| 39 } | 40 } |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 PolicyMap policy_map_; | 43 PolicyMap policy_map_; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 } // namespace policy | 46 } // namespace policy |
| 46 | 47 |
| 47 #endif // CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_STORE_H_ | 48 #endif // CHROME_BROWSER_POLICY_MOCK_CONFIGURATION_POLICY_STORE_H_ |
| OLD | NEW |