Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: chrome/browser/extensions/extension_management_test_util.cc

Issue 2806283002: Revert of Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, base::MakeUnique<base::DictionaryValue>()); 52 pref_->SetWithoutPathExpansion(id, new 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
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, base::MakeUnique<base::ListValue>()); 225 pref_->Set(path, new 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_weak = nullptr; 231 base::ListValue* list_value = nullptr;
232 if (!pref_->GetList(path, &list_value_weak)) { 232 if (!pref_->GetList(path, &list_value)) {
233 auto list_value = base::MakeUnique<base::ListValue>(); 233 list_value = new base::ListValue();
234 list_value_weak = list_value.get(); 234 pref_->Set(path, list_value);
235 pref_->Set(path, std::move(list_value));
236 } 235 }
237 CHECK( 236 CHECK(list_value->AppendIfNotPresent(base::MakeUnique<base::Value>(str)));
238 list_value_weak->AppendIfNotPresent(base::MakeUnique<base::Value>(str)));
239 } 237 }
240 238
241 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( 239 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList(
242 const std::string& path, 240 const std::string& path,
243 const std::string& str) { 241 const std::string& str) {
244 base::ListValue* list_value = nullptr; 242 base::ListValue* list_value = nullptr;
245 if (pref_->GetList(path, &list_value)) 243 if (pref_->GetList(path, &list_value))
246 CHECK(list_value->Remove(base::Value(str), nullptr)); 244 CHECK(list_value->Remove(base::Value(str), nullptr));
247 } 245 }
248 246
(...skipping 18 matching lines...) Expand all
267 policies_ 265 policies_
268 ->Get( 266 ->Get(
269 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())) 267 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()))
270 .Set(policy::key::kExtensionSettings, policy::POLICY_LEVEL_MANDATORY, 268 .Set(policy::key::kExtensionSettings, policy::POLICY_LEVEL_MANDATORY,
271 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, TakePref(), 269 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, TakePref(),
272 nullptr); 270 nullptr);
273 provider_->UpdatePolicy(std::move(policies_)); 271 provider_->UpdatePolicy(std::move(policies_));
274 } 272 }
275 273
276 } // namespace extensions 274 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698