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

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

Issue 1408023003: Don't persist registrations for whitelists installed from the command line. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 2 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 cc8d4c10dda363b5df4baf78e34931630adbaea7..fe30791bab420d009ce270a55d7784f6fb6ebe61 100644
--- a/chrome/browser/component_updater/supervised_user_whitelist_installer.cc
+++ b/chrome/browser/component_updater/supervised_user_whitelist_installer.cc
@@ -386,6 +386,13 @@ void SupervisedUserWhitelistInstallerImpl::RegisterComponents() {
it.Advance()) {
const base::DictionaryValue* dict = nullptr;
it.value().GetAsDictionary(&dict);
+
+ // Skip whitelists with no clients. This can happen when a whitelist was
+ // previously registered with an empty client ID.
+ const base::ListValue* clients = nullptr;
+ if (!dict->GetList(kClients, &clients) || clients->empty())
+ continue;
+
std::string name;
bool result = dict->GetString(kName, &name);
DCHECK(result);
@@ -413,22 +420,25 @@ void SupervisedUserWhitelistInstallerImpl::RegisterWhitelist(
prefs::kRegisteredSupervisedUserWhitelists);
base::DictionaryValue* pref_dict = update.Get();
base::DictionaryValue* whitelist_dict = nullptr;
- bool newly_added = false;
- if (!pref_dict->GetDictionaryWithoutPathExpansion(crx_id, &whitelist_dict)) {
+ const bool newly_added =
+ !pref_dict->GetDictionaryWithoutPathExpansion(crx_id, &whitelist_dict);
+ if (newly_added) {
whitelist_dict = new base::DictionaryValue;
whitelist_dict->SetString(kName, name);
pref_dict->SetWithoutPathExpansion(crx_id, whitelist_dict);
- newly_added = true;
}
- base::ListValue* clients = nullptr;
- if (!whitelist_dict->GetList(kClients, &clients)) {
- DCHECK(newly_added);
- clients = new base::ListValue;
- whitelist_dict->Set(kClients, clients);
+ if (!client_id.empty()) {
+ base::ListValue* clients = nullptr;
+ if (!whitelist_dict->GetList(kClients, &clients)) {
+ DCHECK(newly_added);
+ clients = new base::ListValue;
+ whitelist_dict->Set(kClients, clients);
+ }
+ bool success =
+ clients->AppendIfNotPresent(new base::StringValue(client_id));
+ DCHECK(success);
}
- bool success = clients->AppendIfNotPresent(new base::StringValue(client_id));
- DCHECK(success);
if (!newly_added) {
// Sanity-check that the stored name is equal to the name passed in.

Powered by Google App Engine
This is Rietveld 408576698