| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 UserManagerImpl::UserManagerImpl() | 165 UserManagerImpl::UserManagerImpl() |
| 166 : cros_settings_(CrosSettings::Get()), | 166 : cros_settings_(CrosSettings::Get()), |
| 167 device_local_account_policy_service_(NULL), | 167 device_local_account_policy_service_(NULL), |
| 168 users_loaded_(false), | 168 users_loaded_(false), |
| 169 logged_in_user_(NULL), | 169 logged_in_user_(NULL), |
| 170 session_started_(false), | 170 session_started_(false), |
| 171 is_current_user_owner_(false), | 171 is_current_user_owner_(false), |
| 172 is_current_user_new_(false), | 172 is_current_user_new_(false), |
| 173 is_current_user_ephemeral_regular_user_(false), | 173 is_current_user_ephemeral_regular_user_(false), |
| 174 ephemeral_users_enabled_(false), | 174 ephemeral_users_enabled_(false), |
| 175 merge_session_state_(MERGE_STATUS_NOT_STARTED), | |
| 176 observed_sync_service_(NULL), | 175 observed_sync_service_(NULL), |
| 177 user_image_manager_(new UserImageManagerImpl) { | 176 user_image_manager_(new UserImageManagerImpl) { |
| 178 // UserManager instance should be used only on UI thread. | 177 // UserManager instance should be used only on UI thread. |
| 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 180 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, | 179 registrar_.Add(this, chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
| 181 content::NotificationService::AllSources()); | 180 content::NotificationService::AllSources()); |
| 182 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, | 181 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, |
| 183 content::NotificationService::AllSources()); | 182 content::NotificationService::AllSources()); |
| 184 RetrieveTrustedDevicePolicies(); | 183 RetrieveTrustedDevicePolicies(); |
| 185 } | 184 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 bool UserManagerImpl::IsLoggedInAsStub() const { | 604 bool UserManagerImpl::IsLoggedInAsStub() const { |
| 606 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 605 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 607 return IsUserLoggedIn() && logged_in_user_->email() == kStubUser; | 606 return IsUserLoggedIn() && logged_in_user_->email() == kStubUser; |
| 608 } | 607 } |
| 609 | 608 |
| 610 bool UserManagerImpl::IsSessionStarted() const { | 609 bool UserManagerImpl::IsSessionStarted() const { |
| 611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 612 return session_started_; | 611 return session_started_; |
| 613 } | 612 } |
| 614 | 613 |
| 615 UserManager::MergeSessionState UserManagerImpl::GetMergeSessionState() const { | |
| 616 return merge_session_state_; | |
| 617 } | |
| 618 | |
| 619 void UserManagerImpl::SetMergeSessionState( | |
| 620 UserManager::MergeSessionState state) { | |
| 621 if (merge_session_state_ == state) | |
| 622 return; | |
| 623 | |
| 624 merge_session_state_ = state; | |
| 625 NotifyMergeSessionStateChanged(); | |
| 626 } | |
| 627 | |
| 628 bool UserManagerImpl::HasBrowserRestarted() const { | 614 bool UserManagerImpl::HasBrowserRestarted() const { |
| 629 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 615 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 630 return base::chromeos::IsRunningOnChromeOS() && | 616 return base::chromeos::IsRunningOnChromeOS() && |
| 631 command_line->HasSwitch(switches::kLoginUser) && | 617 command_line->HasSwitch(switches::kLoginUser) && |
| 632 !command_line->HasSwitch(switches::kLoginPassword); | 618 !command_line->HasSwitch(switches::kLoginPassword); |
| 633 } | 619 } |
| 634 | 620 |
| 635 bool UserManagerImpl::IsUserNonCryptohomeDataEphemeral( | 621 bool UserManagerImpl::IsUserNonCryptohomeDataEphemeral( |
| 636 const std::string& email) const { | 622 const std::string& email) const { |
| 637 // Data belonging to the guest, retail mode and stub users is always | 623 // Data belonging to the guest, retail mode and stub users is always |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); | 957 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); |
| 972 } | 958 } |
| 973 | 959 |
| 974 void UserManagerImpl::NotifyUserListChanged() { | 960 void UserManagerImpl::NotifyUserListChanged() { |
| 975 content::NotificationService::current()->Notify( | 961 content::NotificationService::current()->Notify( |
| 976 chrome::NOTIFICATION_USER_LIST_CHANGED, | 962 chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 977 content::Source<UserManager>(this), | 963 content::Source<UserManager>(this), |
| 978 content::NotificationService::NoDetails()); | 964 content::NotificationService::NoDetails()); |
| 979 } | 965 } |
| 980 | 966 |
| 981 void UserManagerImpl::NotifyMergeSessionStateChanged() { | |
| 982 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 983 FOR_EACH_OBSERVER(UserManager::Observer, observer_list_, | |
| 984 MergeSessionStateChanged(merge_session_state_)); | |
| 985 } | |
| 986 | |
| 987 } // namespace chromeos | 967 } // namespace chromeos |
| OLD | NEW |