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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 weak_ptr_factory_(this) { | 36 weak_ptr_factory_(this) { |
37 DCHECK(prefs); | 37 DCHECK(prefs); |
38 } | 38 } |
39 | 39 |
40 SupervisedUserWhitelistService::~SupervisedUserWhitelistService() { | 40 SupervisedUserWhitelistService::~SupervisedUserWhitelistService() { |
41 } | 41 } |
42 | 42 |
43 // static | 43 // static |
44 void SupervisedUserWhitelistService::RegisterProfilePrefs( | 44 void SupervisedUserWhitelistService::RegisterProfilePrefs( |
45 user_prefs::PrefRegistrySyncable* registry) { | 45 user_prefs::PrefRegistrySyncable* registry) { |
46 registry->RegisterDictionaryPref( | 46 registry->RegisterDictionaryPref(prefs::kSupervisedUserWhitelists); |
47 prefs::kSupervisedUserWhitelists, | |
48 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
49 } | 47 } |
50 | 48 |
51 void SupervisedUserWhitelistService::Init() { | 49 void SupervisedUserWhitelistService::Init() { |
52 const base::DictionaryValue* whitelists = | 50 const base::DictionaryValue* whitelists = |
53 prefs_->GetDictionary(prefs::kSupervisedUserWhitelists); | 51 prefs_->GetDictionary(prefs::kSupervisedUserWhitelists); |
54 for (base::DictionaryValue::Iterator it(*whitelists); !it.IsAtEnd(); | 52 for (base::DictionaryValue::Iterator it(*whitelists); !it.IsAtEnd(); |
55 it.Advance()) { | 53 it.Advance()) { |
56 registered_whitelists_.insert(it.key()); | 54 registered_whitelists_.insert(it.key()); |
57 } | 55 } |
58 UMA_HISTOGRAM_COUNTS_100("ManagedUsers.Whitelist.Count", whitelists->size()); | 56 UMA_HISTOGRAM_COUNTS_100("ManagedUsers.Whitelist.Count", whitelists->size()); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.TotalLoadDuration", | 312 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.TotalLoadDuration", |
315 base::TimeTicks::Now() - start_time); | 313 base::TimeTicks::Now() - start_time); |
316 | 314 |
317 // If the whitelist has been unregistered in the mean time, ignore it. | 315 // If the whitelist has been unregistered in the mean time, ignore it. |
318 if (registered_whitelists_.count(id) == 0u) | 316 if (registered_whitelists_.count(id) == 0u) |
319 return; | 317 return; |
320 | 318 |
321 loaded_whitelists_[id] = whitelist; | 319 loaded_whitelists_[id] = whitelist; |
322 NotifyWhitelistsChanged(); | 320 NotifyWhitelistsChanged(); |
323 } | 321 } |
OLD | NEW |