| 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/supervised_user/supervised_user_whitelist_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/metrics/user_metrics.h" | 16 #include "base/metrics/user_metrics.h" |
| 15 #include "base/metrics/user_metrics_action.h" | 17 #include "base/metrics/user_metrics_action.h" |
| 16 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 17 #include "base/values.h" | 19 #include "base/values.h" |
| 18 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" | 20 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
| 19 #include "chrome/browser/supervised_user/supervised_user_site_list.h" | 21 #include "chrome/browser/supervised_user/supervised_user_site_list.h" |
| 20 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 22 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 277 } |
| 276 | 278 |
| 277 void SupervisedUserWhitelistService::AddNewWhitelist( | 279 void SupervisedUserWhitelistService::AddNewWhitelist( |
| 278 base::DictionaryValue* pref_dict, | 280 base::DictionaryValue* pref_dict, |
| 279 const sync_pb::ManagedUserWhitelistSpecifics& whitelist) { | 281 const sync_pb::ManagedUserWhitelistSpecifics& whitelist) { |
| 280 base::RecordAction(base::UserMetricsAction("ManagedUsers_Whitelist_Added")); | 282 base::RecordAction(base::UserMetricsAction("ManagedUsers_Whitelist_Added")); |
| 281 | 283 |
| 282 RegisterWhitelist(whitelist.id(), whitelist.name(), FROM_SYNC); | 284 RegisterWhitelist(whitelist.id(), whitelist.name(), FROM_SYNC); |
| 283 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 285 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 284 SetWhitelistProperties(dict.get(), whitelist); | 286 SetWhitelistProperties(dict.get(), whitelist); |
| 285 pref_dict->SetWithoutPathExpansion(whitelist.id(), dict.release()); | 287 pref_dict->SetWithoutPathExpansion(whitelist.id(), std::move(dict)); |
| 286 } | 288 } |
| 287 | 289 |
| 288 void SupervisedUserWhitelistService::SetWhitelistProperties( | 290 void SupervisedUserWhitelistService::SetWhitelistProperties( |
| 289 base::DictionaryValue* dict, | 291 base::DictionaryValue* dict, |
| 290 const sync_pb::ManagedUserWhitelistSpecifics& whitelist) { | 292 const sync_pb::ManagedUserWhitelistSpecifics& whitelist) { |
| 291 dict->SetString(kName, whitelist.name()); | 293 dict->SetString(kName, whitelist.name()); |
| 292 } | 294 } |
| 293 | 295 |
| 294 void SupervisedUserWhitelistService::RemoveWhitelist( | 296 void SupervisedUserWhitelistService::RemoveWhitelist( |
| 295 base::DictionaryValue* pref_dict, | 297 base::DictionaryValue* pref_dict, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.TotalLoadDuration", | 359 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.TotalLoadDuration", |
| 358 base::TimeTicks::Now() - start_time); | 360 base::TimeTicks::Now() - start_time); |
| 359 | 361 |
| 360 // If the whitelist has been unregistered in the mean time, ignore it. | 362 // If the whitelist has been unregistered in the mean time, ignore it. |
| 361 if (registered_whitelists_.count(id) == 0u) | 363 if (registered_whitelists_.count(id) == 0u) |
| 362 return; | 364 return; |
| 363 | 365 |
| 364 loaded_whitelists_[id] = whitelist; | 366 loaded_whitelists_[id] = whitelist; |
| 365 NotifyWhitelistsChanged(); | 367 NotifyWhitelistsChanged(); |
| 366 } | 368 } |
| OLD | NEW |