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_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 ProfileSyncServiceFactory::GetForProfile(profile_); | 188 ProfileSyncServiceFactory::GetForProfile(profile_); |
189 // Can be null in tests. | 189 // Can be null in tests. |
190 if (sync_service) | 190 if (sync_service) |
191 sync_service->RemovePreferenceProvider(this); | 191 sync_service->RemovePreferenceProvider(this); |
192 } | 192 } |
193 | 193 |
194 bool SupervisedUserService::ProfileIsSupervised() const { | 194 bool SupervisedUserService::ProfileIsSupervised() const { |
195 return profile_->IsSupervised(); | 195 return profile_->IsSupervised(); |
196 } | 196 } |
197 | 197 |
| 198 void SupervisedUserService::OnCustodianInfoChanged() { |
| 199 FOR_EACH_OBSERVER( |
| 200 SupervisedUserServiceObserver, observer_list_, OnCustodianInfoChanged()); |
| 201 } |
| 202 |
198 // static | 203 // static |
199 void SupervisedUserService::RegisterProfilePrefs( | 204 void SupervisedUserService::RegisterProfilePrefs( |
200 user_prefs::PrefRegistrySyncable* registry) { | 205 user_prefs::PrefRegistrySyncable* registry) { |
201 registry->RegisterDictionaryPref( | 206 registry->RegisterDictionaryPref( |
202 prefs::kSupervisedUserManualHosts, | 207 prefs::kSupervisedUserManualHosts, |
203 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 208 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
204 registry->RegisterDictionaryPref( | 209 registry->RegisterDictionaryPref( |
205 prefs::kSupervisedUserManualURLs, | 210 prefs::kSupervisedUserManualURLs, |
206 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 211 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
207 registry->RegisterIntegerPref( | 212 registry->RegisterIntegerPref( |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 pref_change_registrar_.Add( | 748 pref_change_registrar_.Add( |
744 prefs::kDefaultSupervisedUserFilteringBehavior, | 749 prefs::kDefaultSupervisedUserFilteringBehavior, |
745 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged, | 750 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged, |
746 base::Unretained(this))); | 751 base::Unretained(this))); |
747 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts, | 752 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts, |
748 base::Bind(&SupervisedUserService::UpdateManualHosts, | 753 base::Bind(&SupervisedUserService::UpdateManualHosts, |
749 base::Unretained(this))); | 754 base::Unretained(this))); |
750 pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs, | 755 pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs, |
751 base::Bind(&SupervisedUserService::UpdateManualURLs, | 756 base::Bind(&SupervisedUserService::UpdateManualURLs, |
752 base::Unretained(this))); | 757 base::Unretained(this))); |
| 758 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianName, |
| 759 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 760 base::Unretained(this))); |
| 761 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianEmail, |
| 762 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 763 base::Unretained(this))); |
| 764 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianProfileImageURL, |
| 765 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 766 base::Unretained(this))); |
| 767 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianProfileURL, |
| 768 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 769 base::Unretained(this))); |
| 770 pref_change_registrar_.Add(prefs::kSupervisedUserSecondCustodianName, |
| 771 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 772 base::Unretained(this))); |
| 773 pref_change_registrar_.Add(prefs::kSupervisedUserSecondCustodianEmail, |
| 774 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 775 base::Unretained(this))); |
| 776 pref_change_registrar_.Add( |
| 777 prefs::kSupervisedUserSecondCustodianProfileImageURL, |
| 778 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 779 base::Unretained(this))); |
| 780 pref_change_registrar_.Add(prefs::kSupervisedUserSecondCustodianProfileURL, |
| 781 base::Bind(&SupervisedUserService::OnCustodianInfoChanged, |
| 782 base::Unretained(this))); |
753 | 783 |
754 // Initialize the filter. | 784 // Initialize the filter. |
755 OnDefaultFilteringBehaviorChanged(); | 785 OnDefaultFilteringBehaviorChanged(); |
756 UpdateSiteLists(); | 786 UpdateSiteLists(); |
757 UpdateManualHosts(); | 787 UpdateManualHosts(); |
758 UpdateManualURLs(); | 788 UpdateManualURLs(); |
759 bool use_blacklist = | 789 bool use_blacklist = |
760 CommandLine::ForCurrentProcess()->HasSwitch( | 790 CommandLine::ForCurrentProcess()->HasSwitch( |
761 switches::kEnableSupervisedUserBlacklist); | 791 switches::kEnableSupervisedUserBlacklist); |
762 if (delegate_ && use_blacklist) { | 792 if (delegate_ && use_blacklist) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 // The active user can be NULL in unit tests. | 927 // The active user can be NULL in unit tests. |
898 if (user_manager::UserManager::Get()->GetActiveUser()) { | 928 if (user_manager::UserManager::Get()->GetActiveUser()) { |
899 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 929 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
900 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 930 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
901 } | 931 } |
902 return std::string(); | 932 return std::string(); |
903 #else | 933 #else |
904 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 934 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
905 #endif | 935 #endif |
906 } | 936 } |
OLD | NEW |