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

Unified Diff: chrome/browser/component_updater/supervised_user_whitelist_installer.cc

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Just rebased 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/component_updater/supervised_user_whitelist_installer.cc
diff --git a/chrome/browser/component_updater/supervised_user_whitelist_installer.cc b/chrome/browser/component_updater/supervised_user_whitelist_installer.cc
index 73e0a94e43e3dfa36f5ae86b4377ab7f79cd9359..dcb569fe862ef7e82e56b19c573e4f13b64aa3e3 100644
--- a/chrome/browser/component_updater/supervised_user_whitelist_installer.cc
+++ b/chrome/browser/component_updater/supervised_user_whitelist_installer.cc
@@ -533,24 +533,26 @@ void SupervisedUserWhitelistInstallerImpl::RegisterWhitelist(
DictionaryPrefUpdate update(local_state_,
prefs::kRegisteredSupervisedUserWhitelists);
base::DictionaryValue* pref_dict = update.Get();
- base::DictionaryValue* whitelist_dict = nullptr;
- const bool newly_added =
- !pref_dict->GetDictionaryWithoutPathExpansion(crx_id, &whitelist_dict);
+ base::DictionaryValue* whitelist_dict_weak = nullptr;
+ const bool newly_added = !pref_dict->GetDictionaryWithoutPathExpansion(
+ crx_id, &whitelist_dict_weak);
if (newly_added) {
- whitelist_dict = new base::DictionaryValue;
+ auto whitelist_dict = base::MakeUnique<base::DictionaryValue>();
+ whitelist_dict_weak = whitelist_dict.get();
whitelist_dict->SetString(kName, name);
- pref_dict->SetWithoutPathExpansion(crx_id, whitelist_dict);
+ pref_dict->SetWithoutPathExpansion(crx_id, std::move(whitelist_dict));
}
if (!client_id.empty()) {
- base::ListValue* clients = nullptr;
- if (!whitelist_dict->GetList(kClients, &clients)) {
+ base::ListValue* clients_weak = nullptr;
+ if (!whitelist_dict_weak->GetList(kClients, &clients_weak)) {
DCHECK(newly_added);
- clients = new base::ListValue;
- whitelist_dict->Set(kClients, clients);
+ auto clients = base::MakeUnique<base::ListValue>();
+ clients_weak = clients.get();
+ whitelist_dict_weak->Set(kClients, std::move(clients));
}
- bool success =
- clients->AppendIfNotPresent(base::MakeUnique<base::Value>(client_id));
+ bool success = clients_weak->AppendIfNotPresent(
+ base::MakeUnique<base::Value>(client_id));
DCHECK(success);
}
@@ -558,7 +560,7 @@ void SupervisedUserWhitelistInstallerImpl::RegisterWhitelist(
// Sanity-check that the stored name is equal to the name passed in.
// In release builds this is a no-op.
std::string stored_name;
- DCHECK(whitelist_dict->GetString(kName, &stored_name));
+ DCHECK(whitelist_dict_weak->GetString(kName, &stored_name));
DCHECK_EQ(stored_name, name);
return;
}

Powered by Google App Engine
This is Rietveld 408576698