OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/extension_management_test_util.h" | 5 #include "chrome/browser/extensions/extension_management_test_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
| 10 #include "base/memory/ptr_util.h" |
10 #include "components/crx_file/id_util.h" | 11 #include "components/crx_file/id_util.h" |
11 #include "components/policy/core/common/configuration_policy_provider.h" | 12 #include "components/policy/core/common/configuration_policy_provider.h" |
12 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 13 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
13 #include "components/policy/core/common/policy_bundle.h" | 14 #include "components/policy/core/common/policy_bundle.h" |
14 #include "components/policy/core/common/policy_map.h" | 15 #include "components/policy/core/common/policy_map.h" |
15 #include "components/policy/core/common/policy_namespace.h" | 16 #include "components/policy/core/common/policy_namespace.h" |
16 #include "components/policy/core/common/policy_types.h" | 17 #include "components/policy/core/common/policy_types.h" |
17 #include "components/policy/policy_constants.h" | 18 #include "components/policy/policy_constants.h" |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 226 } |
226 | 227 |
227 void ExtensionManagementPrefUpdaterBase::AddStringToList( | 228 void ExtensionManagementPrefUpdaterBase::AddStringToList( |
228 const std::string& path, | 229 const std::string& path, |
229 const std::string& str) { | 230 const std::string& str) { |
230 base::ListValue* list_value = nullptr; | 231 base::ListValue* list_value = nullptr; |
231 if (!pref_->GetList(path, &list_value)) { | 232 if (!pref_->GetList(path, &list_value)) { |
232 list_value = new base::ListValue(); | 233 list_value = new base::ListValue(); |
233 pref_->Set(path, list_value); | 234 pref_->Set(path, list_value); |
234 } | 235 } |
235 CHECK(list_value->AppendIfNotPresent(new base::StringValue(str))); | 236 CHECK( |
| 237 list_value->AppendIfNotPresent(base::MakeUnique<base::StringValue>(str))); |
236 } | 238 } |
237 | 239 |
238 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( | 240 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( |
239 const std::string& path, | 241 const std::string& path, |
240 const std::string& str) { | 242 const std::string& str) { |
241 base::ListValue* list_value = nullptr; | 243 base::ListValue* list_value = nullptr; |
242 if (pref_->GetList(path, &list_value)) | 244 if (pref_->GetList(path, &list_value)) |
243 CHECK(list_value->Remove(base::StringValue(str), nullptr)); | 245 CHECK(list_value->Remove(base::StringValue(str), nullptr)); |
244 } | 246 } |
245 | 247 |
(...skipping 18 matching lines...) Expand all Loading... |
264 policies_ | 266 policies_ |
265 ->Get( | 267 ->Get( |
266 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())) | 268 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())) |
267 .Set(policy::key::kExtensionSettings, policy::POLICY_LEVEL_MANDATORY, | 269 .Set(policy::key::kExtensionSettings, policy::POLICY_LEVEL_MANDATORY, |
268 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, TakePref(), | 270 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, TakePref(), |
269 nullptr); | 271 nullptr); |
270 provider_->UpdatePolicy(std::move(policies_)); | 272 provider_->UpdatePolicy(std::move(policies_)); |
271 } | 273 } |
272 | 274 |
273 } // namespace extensions | 275 } // namespace extensions |
OLD | NEW |