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 "components/policy/core/common/policy_test_utils.h" | 5 #include "components/policy/core/common/policy_test_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "components/policy/core/common/policy_bundle.h" | 18 #include "components/policy/core/common/policy_bundle.h" |
18 | 19 |
19 #if defined(OS_IOS) || defined(OS_MACOSX) | 20 #if defined(OS_IOS) || defined(OS_MACOSX) |
20 #include <CoreFoundation/CoreFoundation.h> | 21 #include <CoreFoundation/CoreFoundation.h> |
21 | 22 |
22 #include "base/mac/scoped_cftyperef.h" | 23 #include "base/mac/scoped_cftyperef.h" |
23 #endif | 24 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
41 PolicyDetailsMapping::const_iterator it = map_.find(policy); | 42 PolicyDetailsMapping::const_iterator it = map_.find(policy); |
42 return it == map_.end() ? NULL : it->second; | 43 return it == map_.end() ? NULL : it->second; |
43 } | 44 } |
44 | 45 |
45 bool PolicyServiceIsEmpty(const PolicyService* service) { | 46 bool PolicyServiceIsEmpty(const PolicyService* service) { |
46 const PolicyMap& map = service->GetPolicies( | 47 const PolicyMap& map = service->GetPolicies( |
47 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 48 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
48 if (!map.empty()) { | 49 if (!map.empty()) { |
49 base::DictionaryValue dict; | 50 base::DictionaryValue dict; |
50 for (PolicyMap::const_iterator it = map.begin(); it != map.end(); ++it) | 51 for (PolicyMap::const_iterator it = map.begin(); it != map.end(); ++it) |
51 dict.SetWithoutPathExpansion(it->first, it->second.value->DeepCopy()); | 52 dict.SetWithoutPathExpansion( |
| 53 it->first, base::MakeUnique<base::Value>(*it->second.value)); |
52 LOG(WARNING) << "There are pre-existing policies in this machine: " << dict; | 54 LOG(WARNING) << "There are pre-existing policies in this machine: " << dict; |
53 } | 55 } |
54 return map.empty(); | 56 return map.empty(); |
55 } | 57 } |
56 | 58 |
57 #if defined(OS_IOS) || defined(OS_MACOSX) | 59 #if defined(OS_IOS) || defined(OS_MACOSX) |
58 CFPropertyListRef ValueToProperty(const base::Value& value) { | 60 CFPropertyListRef ValueToProperty(const base::Value& value) { |
59 switch (value.GetType()) { | 61 switch (value.GetType()) { |
60 case base::Value::Type::NONE: | 62 case base::Value::Type::NONE: |
61 return kCFNull; | 63 return kCFNull; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 << " \"scope\": " << e.scope << "," << std::endl | 235 << " \"scope\": " << e.scope << "," << std::endl |
234 << " \"value\": " << value | 236 << " \"value\": " << value |
235 << "}"; | 237 << "}"; |
236 return os; | 238 return os; |
237 } | 239 } |
238 | 240 |
239 std::ostream& operator<<(std::ostream& os, const policy::PolicyNamespace& ns) { | 241 std::ostream& operator<<(std::ostream& os, const policy::PolicyNamespace& ns) { |
240 os << ns.domain << "/" << ns.component_id; | 242 os << ns.domain << "/" << ns.component_id; |
241 return os; | 243 return os; |
242 } | 244 } |
OLD | NEW |