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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_service.cc

Issue 597783003: Update the AvatarMenu when a supervised user's custodian info changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScopedObserver Created 6 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 unified diff | Download patch
OLDNEW
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ProfileSyncServiceFactory::GetForProfile(profile_); 187 ProfileSyncServiceFactory::GetForProfile(profile_);
188 // Can be null in tests. 188 // Can be null in tests.
189 if (sync_service) 189 if (sync_service)
190 sync_service->RemovePreferenceProvider(this); 190 sync_service->RemovePreferenceProvider(this);
191 } 191 }
192 192
193 bool SupervisedUserService::ProfileIsSupervised() const { 193 bool SupervisedUserService::ProfileIsSupervised() const {
194 return profile_->IsSupervised(); 194 return profile_->IsSupervised();
195 } 195 }
196 196
197 void SupervisedUserService::OnCustodianInfoChanged() {
198 FOR_EACH_OBSERVER(
199 SupervisedUserServiceObserver, observer_list_, OnCustodianInfoChanged());
200 }
201
197 // static 202 // static
198 void SupervisedUserService::RegisterProfilePrefs( 203 void SupervisedUserService::RegisterProfilePrefs(
199 user_prefs::PrefRegistrySyncable* registry) { 204 user_prefs::PrefRegistrySyncable* registry) {
200 registry->RegisterDictionaryPref( 205 registry->RegisterDictionaryPref(
201 prefs::kSupervisedUserManualHosts, 206 prefs::kSupervisedUserManualHosts,
202 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 207 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
203 registry->RegisterDictionaryPref( 208 registry->RegisterDictionaryPref(
204 prefs::kSupervisedUserManualURLs, 209 prefs::kSupervisedUserManualURLs,
205 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 210 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
206 registry->RegisterIntegerPref( 211 registry->RegisterIntegerPref(
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 pref_change_registrar_.Add( 721 pref_change_registrar_.Add(
717 prefs::kDefaultSupervisedUserFilteringBehavior, 722 prefs::kDefaultSupervisedUserFilteringBehavior,
718 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged, 723 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged,
719 base::Unretained(this))); 724 base::Unretained(this)));
720 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts, 725 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts,
721 base::Bind(&SupervisedUserService::UpdateManualHosts, 726 base::Bind(&SupervisedUserService::UpdateManualHosts,
722 base::Unretained(this))); 727 base::Unretained(this)));
723 pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs, 728 pref_change_registrar_.Add(prefs::kSupervisedUserManualURLs,
724 base::Bind(&SupervisedUserService::UpdateManualURLs, 729 base::Bind(&SupervisedUserService::UpdateManualURLs,
725 base::Unretained(this))); 730 base::Unretained(this)));
731 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianName,
732 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
733 base::Unretained(this)));
734 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianEmail,
735 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
736 base::Unretained(this)));
737 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianProfileImageURL,
738 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
739 base::Unretained(this)));
740 pref_change_registrar_.Add(prefs::kSupervisedUserCustodianProfileURL,
741 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
742 base::Unretained(this)));
743 pref_change_registrar_.Add(prefs::kSupervisedUserSecondCustodianName,
744 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
745 base::Unretained(this)));
746 pref_change_registrar_.Add(prefs::kSupervisedUserSecondCustodianEmail,
747 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
748 base::Unretained(this)));
749 pref_change_registrar_.Add(
750 prefs::kSupervisedUserSecondCustodianProfileImageURL,
751 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
752 base::Unretained(this)));
753 pref_change_registrar_.Add(prefs::kSupervisedUserSecondCustodianProfileURL,
754 base::Bind(&SupervisedUserService::OnCustodianInfoChanged,
755 base::Unretained(this)));
726 756
727 // Initialize the filter. 757 // Initialize the filter.
728 OnDefaultFilteringBehaviorChanged(); 758 OnDefaultFilteringBehaviorChanged();
729 UpdateSiteLists(); 759 UpdateSiteLists();
730 UpdateManualHosts(); 760 UpdateManualHosts();
731 UpdateManualURLs(); 761 UpdateManualURLs();
732 bool use_blacklist = 762 bool use_blacklist =
733 CommandLine::ForCurrentProcess()->HasSwitch( 763 CommandLine::ForCurrentProcess()->HasSwitch(
734 switches::kEnableSupervisedUserBlacklist); 764 switches::kEnableSupervisedUserBlacklist);
735 if (delegate_ && use_blacklist) { 765 if (delegate_ && use_blacklist) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // The active user can be NULL in unit tests. 900 // The active user can be NULL in unit tests.
871 if (user_manager::UserManager::Get()->GetActiveUser()) { 901 if (user_manager::UserManager::Get()->GetActiveUser()) {
872 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( 902 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName(
873 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); 903 user_manager::UserManager::Get()->GetActiveUser()->GetUserID()));
874 } 904 }
875 return std::string(); 905 return std::string();
876 #else 906 #else
877 return profile_->GetPrefs()->GetString(prefs::kProfileName); 907 return profile_->GetPrefs()->GetString(prefs::kProfileName);
878 #endif 908 #endif
879 } 909 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698