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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 const content::NotificationDetails& details) { | 749 const content::NotificationDetails& details) { |
750 switch (type) { | 750 switch (type) { |
751 case chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED: | 751 case chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED: |
752 if (!device_local_account_policy_service_) { | 752 if (!device_local_account_policy_service_) { |
753 device_local_account_policy_service_ = | 753 device_local_account_policy_service_ = |
754 g_browser_process->browser_policy_connector()-> | 754 g_browser_process->browser_policy_connector()-> |
755 GetDeviceLocalAccountPolicyService(); | 755 GetDeviceLocalAccountPolicyService(); |
756 if (device_local_account_policy_service_) | 756 if (device_local_account_policy_service_) |
757 device_local_account_policy_service_->AddObserver(this); | 757 device_local_account_policy_service_->AddObserver(this); |
758 } | 758 } |
759 CheckOwnership(); | |
760 RetrieveTrustedDevicePolicies(); | 759 RetrieveTrustedDevicePolicies(); |
| 760 UpdateOwnership(); |
761 break; | 761 break; |
762 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: | 762 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: |
763 if (IsUserLoggedIn() && | 763 if (IsUserLoggedIn() && |
764 !IsLoggedInAsGuest() && | 764 !IsLoggedInAsGuest() && |
765 !IsLoggedInAsKioskApp()) { | 765 !IsLoggedInAsKioskApp()) { |
766 Profile* profile = content::Details<Profile>(details).ptr(); | 766 Profile* profile = content::Details<Profile>(details).ptr(); |
767 if (!profile->IsOffTheRecord() && | 767 if (!profile->IsOffTheRecord() && |
768 profile == ProfileManager::GetDefaultProfile()) { | 768 profile == ProfileManager::GetDefaultProfile()) { |
769 // TODO(nkostylev): We should observe all logged in user's profiles. | 769 // TODO(nkostylev): We should observe all logged in user's profiles. |
770 // http://crbug.com/230860 | 770 // http://crbug.com/230860 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 content::NotificationService::current()->Notify( | 1322 content::NotificationService::current()->Notify( |
1323 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 1323 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
1324 content::Source<UserManager>(this), | 1324 content::Source<UserManager>(this), |
1325 content::Details<const User>(active_user_)); | 1325 content::Details<const User>(active_user_)); |
1326 | 1326 |
1327 // Indicate to DeviceSettingsService that the owner key may have become | 1327 // Indicate to DeviceSettingsService that the owner key may have become |
1328 // available. | 1328 // available. |
1329 DeviceSettingsService::Get()->SetUsername(active_user_->email()); | 1329 DeviceSettingsService::Get()->SetUsername(active_user_->email()); |
1330 } | 1330 } |
1331 | 1331 |
1332 void UserManagerImpl::UpdateOwnership( | 1332 void UserManagerImpl::UpdateOwnership() { |
1333 DeviceSettingsService::OwnershipStatus status, | 1333 bool is_owner = DeviceSettingsService::Get()->HasPrivateOwnerKey(); |
1334 bool is_owner) { | |
1335 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); | 1334 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); |
1336 | 1335 |
1337 SetCurrentUserIsOwner(is_owner); | 1336 SetCurrentUserIsOwner(is_owner); |
1338 } | 1337 } |
1339 | 1338 |
1340 void UserManagerImpl::CheckOwnership() { | |
1341 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | |
1342 base::Bind(&UserManagerImpl::UpdateOwnership, | |
1343 base::Unretained(this))); | |
1344 } | |
1345 | |
1346 void UserManagerImpl::RemoveNonCryptohomeData(const std::string& email) { | 1339 void UserManagerImpl::RemoveNonCryptohomeData(const std::string& email) { |
1347 WallpaperManager::Get()->RemoveUserWallpaperInfo(email); | 1340 WallpaperManager::Get()->RemoveUserWallpaperInfo(email); |
1348 user_image_manager_->DeleteUserImage(email); | 1341 user_image_manager_->DeleteUserImage(email); |
1349 | 1342 |
1350 PrefService* prefs = g_browser_process->local_state(); | 1343 PrefService* prefs = g_browser_process->local_state(); |
1351 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); | 1344 DictionaryPrefUpdate prefs_oauth_update(prefs, kUserOAuthTokenStatus); |
1352 int oauth_status; | 1345 int oauth_status; |
1353 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); | 1346 prefs_oauth_update->GetIntegerWithoutPathExpansion(email, &oauth_status); |
1354 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); | 1347 prefs_oauth_update->RemoveWithoutPathExpansion(email, NULL); |
1355 | 1348 |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 base::TimeTicks::Now() - manager_creation_time_; | 1812 base::TimeTicks::Now() - manager_creation_time_; |
1820 if (!last_email.empty() && email != last_email && | 1813 if (!last_email.empty() && email != last_email && |
1821 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { | 1814 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { |
1822 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", | 1815 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", |
1823 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); | 1816 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); |
1824 } | 1817 } |
1825 } | 1818 } |
1826 } | 1819 } |
1827 | 1820 |
1828 } // namespace chromeos | 1821 } // namespace chromeos |
OLD | NEW |