OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_test_utils.h" | 5 #include "chrome/browser/policy/test/policy_test_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" |
9 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 13 #include "base/logging.h" |
11 #include "base/values.h" | 14 #include "base/values.h" |
12 #include "chrome/browser/policy/policy_bundle.h" | 15 #include "chrome/browser/policy/policy_bundle.h" |
13 | 16 |
14 namespace policy { | 17 namespace policy { |
15 | 18 |
| 19 PolicyDetailsMap::PolicyDetailsMap() {} |
| 20 |
| 21 PolicyDetailsMap::~PolicyDetailsMap() {} |
| 22 |
| 23 GetChromePolicyDetailsCallback PolicyDetailsMap::GetCallback() const { |
| 24 return base::Bind(&PolicyDetailsMap::Lookup, base::Unretained(this)); |
| 25 } |
| 26 |
| 27 void PolicyDetailsMap::SetDetails(const std::string& policy, |
| 28 const PolicyDetails* details) { |
| 29 map_[policy] = details; |
| 30 } |
| 31 |
| 32 const PolicyDetails* PolicyDetailsMap::Lookup(const std::string& policy) const { |
| 33 PolicyDetailsMapping::const_iterator it = map_.find(policy); |
| 34 return it == map_.end() ? NULL : it->second; |
| 35 } |
| 36 |
16 bool PolicyServiceIsEmpty(const PolicyService* service) { | 37 bool PolicyServiceIsEmpty(const PolicyService* service) { |
17 const PolicyMap& map = service->GetPolicies( | 38 const PolicyMap& map = service->GetPolicies( |
18 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 39 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
19 if (!map.empty()) { | 40 if (!map.empty()) { |
20 base::DictionaryValue dict; | 41 base::DictionaryValue dict; |
21 for (PolicyMap::const_iterator it = map.begin(); it != map.end(); ++it) | 42 for (PolicyMap::const_iterator it = map.begin(); it != map.end(); ++it) |
22 dict.SetWithoutPathExpansion(it->first, it->second.value->DeepCopy()); | 43 dict.SetWithoutPathExpansion(it->first, it->second.value->DeepCopy()); |
23 LOG(WARNING) << "There are pre-existing policies in this machine: " << dict; | 44 LOG(WARNING) << "There are pre-existing policies in this machine: " << dict; |
24 } | 45 } |
25 return map.empty(); | 46 return map.empty(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 << " \"scope\": " << e.scope << "," << std::endl | 130 << " \"scope\": " << e.scope << "," << std::endl |
110 << " \"value\": " << value | 131 << " \"value\": " << value |
111 << "}"; | 132 << "}"; |
112 return os; | 133 return os; |
113 } | 134 } |
114 | 135 |
115 std::ostream& operator<<(std::ostream& os, const policy::PolicyNamespace& ns) { | 136 std::ostream& operator<<(std::ostream& os, const policy::PolicyNamespace& ns) { |
116 os << ns.domain << "/" << ns.component_id; | 137 os << ns.domain << "/" << ns.component_id; |
117 return os; | 138 return os; |
118 } | 139 } |
OLD | NEW |