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

Side by Side Diff: chrome/browser/chromeos/login/user_manager_impl.cc

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/login/user_manager_impl.h" 5 #include "chrome/browser/chromeos/login/user_manager_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ephemeral_users_enabled_(false), 228 ephemeral_users_enabled_(false),
229 user_image_manager_(new UserImageManagerImpl), 229 user_image_manager_(new UserImageManagerImpl),
230 manager_creation_time_(base::TimeTicks::Now()) { 230 manager_creation_time_(base::TimeTicks::Now()) {
231 // UserManager instance should be used only on UI thread. 231 // UserManager instance should be used only on UI thread.
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
233 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, 233 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED,
234 content::NotificationService::AllSources()); 234 content::NotificationService::AllSources());
235 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 235 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
236 content::NotificationService::AllSources()); 236 content::NotificationService::AllSources());
237 RetrieveTrustedDevicePolicies(); 237 RetrieveTrustedDevicePolicies();
238 cros_settings_->AddSettingsObserver(kAccountsPrefDeviceLocalAccounts, 238 local_accounts_subscription_ = cros_settings_->AddSettingsObserver(
239 this); 239 kAccountsPrefDeviceLocalAccounts,
240 cros_settings_->AddSettingsObserver(kAccountsPrefSupervisedUsersEnabled, 240 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies,
241 this); 241 base::Unretained(this)));
242 supervised_users_subscription_ = cros_settings_->AddSettingsObserver(
243 kAccountsPrefSupervisedUsersEnabled,
244 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies,
245 base::Unretained(this)));
242 UpdateLoginState(); 246 UpdateLoginState();
243 } 247 }
244 248
245 UserManagerImpl::~UserManagerImpl() { 249 UserManagerImpl::~UserManagerImpl() {
246 // Can't use STLDeleteElements because of the private destructor of User. 250 // Can't use STLDeleteElements because of the private destructor of User.
247 for (UserList::iterator it = users_.begin(); it != users_.end(); 251 for (UserList::iterator it = users_.begin(); it != users_.end();
248 it = users_.erase(it)) { 252 it = users_.erase(it)) {
249 if (active_user_ == *it) 253 if (active_user_ == *it)
250 active_user_ = NULL; 254 active_user_ = NULL;
251 delete *it; 255 delete *it;
252 } 256 }
253 // These are pointers to the same User instances that were in users_ list. 257 // These are pointers to the same User instances that were in users_ list.
254 logged_in_users_.clear(); 258 logged_in_users_.clear();
255 lru_logged_in_users_.clear(); 259 lru_logged_in_users_.clear();
256 260
257 delete active_user_; 261 delete active_user_;
258 } 262 }
259 263
260 void UserManagerImpl::Shutdown() { 264 void UserManagerImpl::Shutdown() {
261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
262 cros_settings_->RemoveSettingsObserver(kAccountsPrefDeviceLocalAccounts, 266 local_accounts_subscription_.reset();
263 this); 267 supervised_users_subscription_.reset();
264 cros_settings_->RemoveSettingsObserver(
265 kAccountsPrefSupervisedUsersEnabled,
266 this);
267 // Stop the session length limiter. 268 // Stop the session length limiter.
268 session_length_limiter_.reset(); 269 session_length_limiter_.reset();
269 270
270 if (device_local_account_policy_service_) 271 if (device_local_account_policy_service_)
271 device_local_account_policy_service_->RemoveObserver(this); 272 device_local_account_policy_service_->RemoveObserver(this);
272 273
273 user_image_manager_->Shutdown(); 274 user_image_manager_->Shutdown();
274 } 275 }
275 276
276 UserImageManager* UserManagerImpl::GetUserImageManager() { 277 UserImageManager* UserManagerImpl::GetUserImageManager() {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 !IsLoggedInAsGuest() && 770 !IsLoggedInAsGuest() &&
770 !IsLoggedInAsKioskApp()) { 771 !IsLoggedInAsKioskApp()) {
771 Profile* profile = content::Details<Profile>(details).ptr(); 772 Profile* profile = content::Details<Profile>(details).ptr();
772 if (!profile->IsOffTheRecord()) { 773 if (!profile->IsOffTheRecord()) {
773 AuthSyncObserver* sync_observer = 774 AuthSyncObserver* sync_observer =
774 AuthSyncObserverFactory::GetInstance()->GetForProfile(profile); 775 AuthSyncObserverFactory::GetInstance()->GetForProfile(profile);
775 sync_observer->StartObserving(); 776 sync_observer->StartObserving();
776 } 777 }
777 } 778 }
778 break; 779 break;
779 case chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED: {
780 std::string changed_setting =
781 *content::Details<const std::string>(details).ptr();
782 DCHECK(changed_setting == kAccountsPrefDeviceLocalAccounts ||
783 changed_setting == kAccountsPrefSupervisedUsersEnabled);
784 RetrieveTrustedDevicePolicies();
785 break;
786 }
787 default: 780 default:
788 NOTREACHED(); 781 NOTREACHED();
789 } 782 }
790 } 783 }
791 784
792 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) { 785 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) {
793 UpdatePublicAccountDisplayName(user_id); 786 UpdatePublicAccountDisplayName(user_id);
794 NotifyUserListChanged(); 787 NotifyUserListChanged();
795 } 788 }
796 789
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 base::TimeTicks::Now() - manager_creation_time_; 1795 base::TimeTicks::Now() - manager_creation_time_;
1803 if (!last_email.empty() && email != last_email && 1796 if (!last_email.empty() && email != last_email &&
1804 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { 1797 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) {
1805 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", 1798 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay",
1806 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); 1799 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50);
1807 } 1800 }
1808 } 1801 }
1809 } 1802 }
1810 1803
1811 } // namespace chromeos 1804 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698