OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/policy/user_policy_test_helper.h" | 5 #include "chrome/browser/chromeos/policy/user_policy_test_helper.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
10 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
11 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
12 #include "base/values.h" | 14 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 16 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
15 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 17 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
16 #include "chrome/browser/policy/profile_policy_connector.h" | 18 #include "chrome/browser/policy/profile_policy_connector.h" |
(...skipping 21 matching lines...) Expand all Loading... |
38 scoped_ptr<base::DictionaryValue> policy_type_dict(new base::DictionaryValue); | 40 scoped_ptr<base::DictionaryValue> policy_type_dict(new base::DictionaryValue); |
39 policy_type_dict->SetWithoutPathExpansion("mandatory", | 41 policy_type_dict->SetWithoutPathExpansion("mandatory", |
40 mandatory.CreateDeepCopy()); | 42 mandatory.CreateDeepCopy()); |
41 policy_type_dict->SetWithoutPathExpansion("recommended", | 43 policy_type_dict->SetWithoutPathExpansion("recommended", |
42 recommended.CreateDeepCopy()); | 44 recommended.CreateDeepCopy()); |
43 | 45 |
44 scoped_ptr<base::ListValue> managed_users_list(new base::ListValue); | 46 scoped_ptr<base::ListValue> managed_users_list(new base::ListValue); |
45 managed_users_list->AppendString("*"); | 47 managed_users_list->AppendString("*"); |
46 | 48 |
47 base::DictionaryValue root_dict; | 49 base::DictionaryValue root_dict; |
48 root_dict.SetWithoutPathExpansion(policyType, policy_type_dict.Pass()); | 50 root_dict.SetWithoutPathExpansion(policyType, std::move(policy_type_dict)); |
49 root_dict.SetWithoutPathExpansion("managed_users", managed_users_list.Pass()); | 51 root_dict.SetWithoutPathExpansion("managed_users", |
| 52 std::move(managed_users_list)); |
50 root_dict.SetStringWithoutPathExpansion("policy_user", account_id); | 53 root_dict.SetStringWithoutPathExpansion("policy_user", account_id); |
51 root_dict.SetIntegerWithoutPathExpansion("current_key_index", 0); | 54 root_dict.SetIntegerWithoutPathExpansion("current_key_index", 0); |
52 | 55 |
53 std::string json_policy; | 56 std::string json_policy; |
54 base::JSONWriter::WriteWithOptions( | 57 base::JSONWriter::WriteWithOptions( |
55 root_dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_policy); | 58 root_dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_policy); |
56 return json_policy; | 59 return json_policy; |
57 } | 60 } |
58 | 61 |
59 } // namespace | 62 } // namespace |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const int bytes_written = | 136 const int bytes_written = |
134 base::WriteFile(PolicyFilePath(), policy.data(), policy.size()); | 137 base::WriteFile(PolicyFilePath(), policy.data(), policy.size()); |
135 ASSERT_EQ(static_cast<int>(policy.size()), bytes_written); | 138 ASSERT_EQ(static_cast<int>(policy.size()), bytes_written); |
136 } | 139 } |
137 | 140 |
138 base::FilePath UserPolicyTestHelper::PolicyFilePath() const { | 141 base::FilePath UserPolicyTestHelper::PolicyFilePath() const { |
139 return temp_dir_.path().AppendASCII("policy.json"); | 142 return temp_dir_.path().AppendASCII("policy.json"); |
140 } | 143 } |
141 | 144 |
142 } // namespace policy | 145 } // namespace policy |
OLD | NEW |