| 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 "base/memory/ptr_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 void ExtensionManagementPrefUpdaterBase::UnsetPerExtensionSettings( | 43 void ExtensionManagementPrefUpdaterBase::UnsetPerExtensionSettings( |
| 44 const ExtensionId& id) { | 44 const ExtensionId& id) { |
| 45 DCHECK(crx_file::id_util::IdIsValid(id)); | 45 DCHECK(crx_file::id_util::IdIsValid(id)); |
| 46 pref_->RemoveWithoutPathExpansion(id, nullptr); | 46 pref_->RemoveWithoutPathExpansion(id, nullptr); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ExtensionManagementPrefUpdaterBase::ClearPerExtensionSettings( | 49 void ExtensionManagementPrefUpdaterBase::ClearPerExtensionSettings( |
| 50 const ExtensionId& id) { | 50 const ExtensionId& id) { |
| 51 DCHECK(crx_file::id_util::IdIsValid(id)); | 51 DCHECK(crx_file::id_util::IdIsValid(id)); |
| 52 pref_->SetWithoutPathExpansion(id, new base::DictionaryValue()); | 52 pref_->SetWithoutPathExpansion(id, base::MakeUnique<base::DictionaryValue>()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Helper functions for 'installation_mode' manipulation ----------------------- | 55 // Helper functions for 'installation_mode' manipulation ----------------------- |
| 56 | 56 |
| 57 void ExtensionManagementPrefUpdaterBase::SetBlacklistedByDefault(bool value) { | 57 void ExtensionManagementPrefUpdaterBase::SetBlacklistedByDefault(bool value) { |
| 58 pref_->SetString(make_path(schema::kWildcard, schema::kInstallationMode), | 58 pref_->SetString(make_path(schema::kWildcard, schema::kInstallationMode), |
| 59 value ? schema::kBlocked : schema::kAllowed); | 59 value ? schema::kBlocked : schema::kAllowed); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ExtensionManagementPrefUpdaterBase:: | 62 void ExtensionManagementPrefUpdaterBase:: |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void ExtensionManagementPrefUpdaterBase::SetPref(base::DictionaryValue* pref) { | 215 void ExtensionManagementPrefUpdaterBase::SetPref(base::DictionaryValue* pref) { |
| 216 pref_.reset(pref); | 216 pref_.reset(pref); |
| 217 } | 217 } |
| 218 | 218 |
| 219 std::unique_ptr<base::DictionaryValue> | 219 std::unique_ptr<base::DictionaryValue> |
| 220 ExtensionManagementPrefUpdaterBase::TakePref() { | 220 ExtensionManagementPrefUpdaterBase::TakePref() { |
| 221 return std::move(pref_); | 221 return std::move(pref_); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void ExtensionManagementPrefUpdaterBase::ClearList(const std::string& path) { | 224 void ExtensionManagementPrefUpdaterBase::ClearList(const std::string& path) { |
| 225 pref_->Set(path, new base::ListValue()); | 225 pref_->Set(path, base::MakeUnique<base::ListValue>()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void ExtensionManagementPrefUpdaterBase::AddStringToList( | 228 void ExtensionManagementPrefUpdaterBase::AddStringToList( |
| 229 const std::string& path, | 229 const std::string& path, |
| 230 const std::string& str) { | 230 const std::string& str) { |
| 231 base::ListValue* list_value = nullptr; | 231 base::ListValue* list_value_weak = nullptr; |
| 232 if (!pref_->GetList(path, &list_value)) { | 232 if (!pref_->GetList(path, &list_value_weak)) { |
| 233 list_value = new base::ListValue(); | 233 auto list_value = base::MakeUnique<base::ListValue>(); |
| 234 pref_->Set(path, list_value); | 234 list_value_weak = list_value.get(); |
| 235 pref_->Set(path, std::move(list_value)); |
| 235 } | 236 } |
| 236 CHECK(list_value->AppendIfNotPresent(base::MakeUnique<base::Value>(str))); | 237 CHECK( |
| 238 list_value_weak->AppendIfNotPresent(base::MakeUnique<base::Value>(str))); |
| 237 } | 239 } |
| 238 | 240 |
| 239 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( | 241 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( |
| 240 const std::string& path, | 242 const std::string& path, |
| 241 const std::string& str) { | 243 const std::string& str) { |
| 242 base::ListValue* list_value = nullptr; | 244 base::ListValue* list_value = nullptr; |
| 243 if (pref_->GetList(path, &list_value)) | 245 if (pref_->GetList(path, &list_value)) |
| 244 CHECK(list_value->Remove(base::Value(str), nullptr)); | 246 CHECK(list_value->Remove(base::Value(str), nullptr)); |
| 245 } | 247 } |
| 246 | 248 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 265 policies_ | 267 policies_ |
| 266 ->Get( | 268 ->Get( |
| 267 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())) | 269 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())) |
| 268 .Set(policy::key::kExtensionSettings, policy::POLICY_LEVEL_MANDATORY, | 270 .Set(policy::key::kExtensionSettings, policy::POLICY_LEVEL_MANDATORY, |
| 269 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, TakePref(), | 271 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, TakePref(), |
| 270 nullptr); | 272 nullptr); |
| 271 provider_->UpdatePolicy(std::move(policies_)); | 273 provider_->UpdatePolicy(std::move(policies_)); |
| 272 } | 274 } |
| 273 | 275 |
| 274 } // namespace extensions | 276 } // namespace extensions |
| OLD | NEW |