| OLD | NEW |
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ephemeral_users_enabled_(false), | 229 ephemeral_users_enabled_(false), |
| 230 user_image_manager_(new UserImageManagerImpl), | 230 user_image_manager_(new UserImageManagerImpl), |
| 231 manager_creation_time_(base::TimeTicks::Now()) { | 231 manager_creation_time_(base::TimeTicks::Now()) { |
| 232 // UserManager instance should be used only on UI thread. | 232 // UserManager instance should be used only on UI thread. |
| 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 234 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, | 234 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
| 235 content::NotificationService::AllSources()); | 235 content::NotificationService::AllSources()); |
| 236 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 236 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 237 content::NotificationService::AllSources()); | 237 content::NotificationService::AllSources()); |
| 238 RetrieveTrustedDevicePolicies(); | 238 RetrieveTrustedDevicePolicies(); |
| 239 cros_settings_->AddSettingsObserver(kAccountsPrefDeviceLocalAccounts, | 239 local_accounts_subscription_ = cros_settings_->AddSettingsObserver( |
| 240 this); | 240 kAccountsPrefDeviceLocalAccounts, |
| 241 cros_settings_->AddSettingsObserver(kAccountsPrefSupervisedUsersEnabled, | 241 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, |
| 242 this); | 242 base::Unretained(this))); |
| 243 supervised_users_subscription_ = cros_settings_->AddSettingsObserver( |
| 244 kAccountsPrefSupervisedUsersEnabled, |
| 245 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, |
| 246 base::Unretained(this))); |
| 243 UpdateLoginState(); | 247 UpdateLoginState(); |
| 244 } | 248 } |
| 245 | 249 |
| 246 UserManagerImpl::~UserManagerImpl() { | 250 UserManagerImpl::~UserManagerImpl() { |
| 247 // Can't use STLDeleteElements because of the private destructor of User. | 251 // Can't use STLDeleteElements because of the private destructor of User. |
| 248 for (UserList::iterator it = users_.begin(); it != users_.end(); | 252 for (UserList::iterator it = users_.begin(); it != users_.end(); |
| 249 it = users_.erase(it)) { | 253 it = users_.erase(it)) { |
| 250 if (active_user_ == *it) | 254 if (active_user_ == *it) |
| 251 active_user_ = NULL; | 255 active_user_ = NULL; |
| 252 delete *it; | 256 delete *it; |
| 253 } | 257 } |
| 254 // These are pointers to the same User instances that were in users_ list. | 258 // These are pointers to the same User instances that were in users_ list. |
| 255 logged_in_users_.clear(); | 259 logged_in_users_.clear(); |
| 256 lru_logged_in_users_.clear(); | 260 lru_logged_in_users_.clear(); |
| 257 | 261 |
| 258 delete active_user_; | 262 delete active_user_; |
| 259 } | 263 } |
| 260 | 264 |
| 261 void UserManagerImpl::Shutdown() { | 265 void UserManagerImpl::Shutdown() { |
| 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 263 cros_settings_->RemoveSettingsObserver(kAccountsPrefDeviceLocalAccounts, | 267 local_accounts_subscription_.reset(); |
| 264 this); | 268 supervised_users_subscription_.reset(); |
| 265 cros_settings_->RemoveSettingsObserver( | |
| 266 kAccountsPrefSupervisedUsersEnabled, | |
| 267 this); | |
| 268 // Stop the session length limiter. | 269 // Stop the session length limiter. |
| 269 session_length_limiter_.reset(); | 270 session_length_limiter_.reset(); |
| 270 | 271 |
| 271 if (device_local_account_policy_service_) | 272 if (device_local_account_policy_service_) |
| 272 device_local_account_policy_service_->RemoveObserver(this); | 273 device_local_account_policy_service_->RemoveObserver(this); |
| 273 | 274 |
| 274 user_image_manager_->Shutdown(); | 275 user_image_manager_->Shutdown(); |
| 275 } | 276 } |
| 276 | 277 |
| 277 UserImageManager* UserManagerImpl::GetUserImageManager() { | 278 UserImageManager* UserManagerImpl::GetUserImageManager() { |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 !IsLoggedInAsGuest() && | 786 !IsLoggedInAsGuest() && |
| 786 !IsLoggedInAsKioskApp()) { | 787 !IsLoggedInAsKioskApp()) { |
| 787 Profile* profile = content::Details<Profile>(details).ptr(); | 788 Profile* profile = content::Details<Profile>(details).ptr(); |
| 788 if (!profile->IsOffTheRecord()) { | 789 if (!profile->IsOffTheRecord()) { |
| 789 AuthSyncObserver* sync_observer = | 790 AuthSyncObserver* sync_observer = |
| 790 AuthSyncObserverFactory::GetInstance()->GetForProfile(profile); | 791 AuthSyncObserverFactory::GetInstance()->GetForProfile(profile); |
| 791 sync_observer->StartObserving(); | 792 sync_observer->StartObserving(); |
| 792 } | 793 } |
| 793 } | 794 } |
| 794 break; | 795 break; |
| 795 case chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED: { | |
| 796 std::string changed_setting = | |
| 797 *content::Details<const std::string>(details).ptr(); | |
| 798 DCHECK(changed_setting == kAccountsPrefDeviceLocalAccounts || | |
| 799 changed_setting == kAccountsPrefSupervisedUsersEnabled); | |
| 800 RetrieveTrustedDevicePolicies(); | |
| 801 break; | |
| 802 } | |
| 803 default: | 796 default: |
| 804 NOTREACHED(); | 797 NOTREACHED(); |
| 805 } | 798 } |
| 806 } | 799 } |
| 807 | 800 |
| 808 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) { | 801 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) { |
| 809 UpdatePublicAccountDisplayName(user_id); | 802 UpdatePublicAccountDisplayName(user_id); |
| 810 NotifyUserListChanged(); | 803 NotifyUserListChanged(); |
| 811 } | 804 } |
| 812 | 805 |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 base::TimeTicks::Now() - manager_creation_time_; | 1811 base::TimeTicks::Now() - manager_creation_time_; |
| 1819 if (!last_email.empty() && email != last_email && | 1812 if (!last_email.empty() && email != last_email && |
| 1820 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { | 1813 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { |
| 1821 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", | 1814 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", |
| 1822 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); | 1815 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); |
| 1823 } | 1816 } |
| 1824 } | 1817 } |
| 1825 } | 1818 } |
| 1826 | 1819 |
| 1827 } // namespace chromeos | 1820 } // namespace chromeos |
| OLD | NEW |