| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 : cros_settings_(CrosSettings::Get()), | 217 : cros_settings_(CrosSettings::Get()), |
| 218 device_local_account_policy_service_(NULL), | 218 device_local_account_policy_service_(NULL), |
| 219 users_loaded_(false), | 219 users_loaded_(false), |
| 220 active_user_(NULL), | 220 active_user_(NULL), |
| 221 session_started_(false), | 221 session_started_(false), |
| 222 user_sessions_restored_(false), | 222 user_sessions_restored_(false), |
| 223 is_current_user_owner_(false), | 223 is_current_user_owner_(false), |
| 224 is_current_user_new_(false), | 224 is_current_user_new_(false), |
| 225 is_current_user_ephemeral_regular_user_(false), | 225 is_current_user_ephemeral_regular_user_(false), |
| 226 ephemeral_users_enabled_(false), | 226 ephemeral_users_enabled_(false), |
| 227 merge_session_state_(MERGE_STATUS_NOT_STARTED), | 227 merge_session_state_(MERGE_STATUS_UNINITILIZED), |
| 228 observed_sync_service_(NULL), | 228 observed_sync_service_(NULL), |
| 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(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 415 |
| 416 void UserManagerImpl::RestoreActiveSessions() { | 416 void UserManagerImpl::RestoreActiveSessions() { |
| 417 DBusThreadManager::Get()->GetSessionManagerClient()->RetrieveActiveSessions( | 417 DBusThreadManager::Get()->GetSessionManagerClient()->RetrieveActiveSessions( |
| 418 base::Bind(&UserManagerImpl::OnRestoreActiveSessions, | 418 base::Bind(&UserManagerImpl::OnRestoreActiveSessions, |
| 419 base::Unretained(this))); | 419 base::Unretained(this))); |
| 420 } | 420 } |
| 421 | 421 |
| 422 void UserManagerImpl::SessionStarted() { | 422 void UserManagerImpl::SessionStarted() { |
| 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 424 session_started_ = true; | 424 session_started_ = true; |
| 425 session_start_time_ = base::Time::Now(); |
| 425 UpdateLoginState(); | 426 UpdateLoginState(); |
| 426 content::NotificationService::current()->Notify( | 427 content::NotificationService::current()->Notify( |
| 427 chrome::NOTIFICATION_SESSION_STARTED, | 428 chrome::NOTIFICATION_SESSION_STARTED, |
| 428 content::Source<UserManager>(this), | 429 content::Source<UserManager>(this), |
| 429 content::Details<const User>(active_user_)); | 430 content::Details<const User>(active_user_)); |
| 430 if (is_current_user_new_) { | 431 if (is_current_user_new_) { |
| 431 // Make sure that the new user's data is persisted to Local State. | 432 // Make sure that the new user's data is persisted to Local State. |
| 432 g_browser_process->local_state()->CommitPendingWrite(); | 433 g_browser_process->local_state()->CommitPendingWrite(); |
| 433 } | 434 } |
| 434 } | 435 } |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 bool UserManagerImpl::IsLoggedInAsStub() const { | 898 bool UserManagerImpl::IsLoggedInAsStub() const { |
| 898 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 899 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 899 return IsUserLoggedIn() && active_user_->email() == kStubUser; | 900 return IsUserLoggedIn() && active_user_->email() == kStubUser; |
| 900 } | 901 } |
| 901 | 902 |
| 902 bool UserManagerImpl::IsSessionStarted() const { | 903 bool UserManagerImpl::IsSessionStarted() const { |
| 903 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 904 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 904 return session_started_; | 905 return session_started_; |
| 905 } | 906 } |
| 906 | 907 |
| 908 int64 UserManagerImpl::GetSessionDurationInSeconds() const { |
| 909 if (!session_started_) |
| 910 return -1; |
| 911 |
| 912 return (base::Time::Now() - session_start_time_).InSeconds(); |
| 913 } |
| 914 |
| 907 bool UserManagerImpl::UserSessionsRestored() const { | 915 bool UserManagerImpl::UserSessionsRestored() const { |
| 908 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 916 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 909 return user_sessions_restored_; | 917 return user_sessions_restored_; |
| 910 } | 918 } |
| 911 | 919 |
| 912 UserManager::MergeSessionState UserManagerImpl::GetMergeSessionState() const { | 920 UserManager::MergeSessionState UserManagerImpl::GetMergeSessionState() const { |
| 913 return merge_session_state_; | 921 return merge_session_state_; |
| 914 } | 922 } |
| 915 | 923 |
| 916 void UserManagerImpl::SetMergeSessionState( | 924 void UserManagerImpl::SetMergeSessionState( |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 base::TimeTicks::Now() - manager_creation_time_; | 1827 base::TimeTicks::Now() - manager_creation_time_; |
| 1820 if (!last_email.empty() && email != last_email && | 1828 if (!last_email.empty() && email != last_email && |
| 1821 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { | 1829 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { |
| 1822 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", | 1830 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", |
| 1823 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); | 1831 time_to_login.InSeconds(), 0, kLogoutToLoginDelayMaxSec, 50); |
| 1824 } | 1832 } |
| 1825 } | 1833 } |
| 1826 } | 1834 } |
| 1827 | 1835 |
| 1828 } // namespace chromeos | 1836 } // namespace chromeos |
| OLD | NEW |