| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/users/chrome_user_manager.h" | 5 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
| 19 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
| 20 #include "base/prefs/scoped_user_pref_update.h" | 20 #include "base/prefs/scoped_user_pref_update.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/thread_task_runner_handle.h" |
| 24 #include "base/values.h" | 25 #include "base/values.h" |
| 25 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 28 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
| 28 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 29 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 29 #include "chrome/browser/chromeos/login/signin/auth_sync_observer.h" | 30 #include "chrome/browser/chromeos/login/signin/auth_sync_observer.h" |
| 30 #include "chrome/browser/chromeos/login/signin/auth_sync_observer_factory.h" | 31 #include "chrome/browser/chromeos/login/signin/auth_sync_observer_factory.h" |
| 31 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" | 32 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" |
| 32 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 33 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 33 #include "chrome/browser/chromeos/login/users/remove_user_delegate.h" | |
| 34 #include "chrome/browser/chromeos/login/users/supervised_user_manager_impl.h" | 34 #include "chrome/browser/chromeos/login/users/supervised_user_manager_impl.h" |
| 35 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 35 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 36 #include "chrome/browser/chromeos/policy/device_local_account.h" | 36 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 37 #include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.
h" | 37 #include "chrome/browser/chromeos/profiles/multiprofiles_session_aborted_dialog.
h" |
| 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 39 #include "chrome/browser/chromeos/session_length_limiter.h" | 39 #include "chrome/browser/chromeos/session_length_limiter.h" |
| 40 #include "chrome/browser/profiles/profile.h" | 40 #include "chrome/browser/profiles/profile.h" |
| 41 #include "chrome/browser/supervised_user/chromeos/manager_password_service_facto
ry.h" | 41 #include "chrome/browser/supervised_user/chromeos/manager_password_service_facto
ry.h" |
| 42 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_servi
ce_factory.h" | 42 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_servi
ce_factory.h" |
| 43 #include "chrome/common/chrome_constants.h" | 43 #include "chrome/common/chrome_constants.h" |
| 44 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/crash_keys.h" | 45 #include "chrome/common/crash_keys.h" |
| 46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/grit/theme_resources.h" | 47 #include "chrome/grit/theme_resources.h" |
| 48 #include "chromeos/chromeos_switches.h" | 48 #include "chromeos/chromeos_switches.h" |
| 49 #include "chromeos/login/user_names.h" | 49 #include "chromeos/login/user_names.h" |
| 50 #include "chromeos/settings/cros_settings_names.h" | 50 #include "chromeos/settings/cros_settings_names.h" |
| 51 #include "components/session_manager/core/session_manager.h" | 51 #include "components/session_manager/core/session_manager.h" |
| 52 #include "components/user_manager/remove_user_delegate.h" |
| 52 #include "components/user_manager/user_image/user_image.h" | 53 #include "components/user_manager/user_image/user_image.h" |
| 53 #include "components/user_manager/user_type.h" | 54 #include "components/user_manager/user_type.h" |
| 54 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
| 55 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
| 56 #include "policy/policy_constants.h" | 57 #include "policy/policy_constants.h" |
| 57 #include "ui/base/resource/resource_bundle.h" | 58 #include "ui/base/resource/resource_bundle.h" |
| 58 #include "ui/wm/core/wm_core_switches.h" | 59 #include "ui/wm/core/wm_core_switches.h" |
| 59 | 60 |
| 60 using content::BrowserThread; | 61 using content::BrowserThread; |
| 61 | 62 |
| 62 namespace chromeos { | 63 namespace chromeos { |
| 63 namespace { | 64 namespace { |
| 64 | 65 |
| 65 // A vector pref of the the regular users known on this device, arranged in LRU | 66 // A vector pref of the the regular users known on this device, arranged in LRU |
| 66 // order. | 67 // order. |
| 67 const char kRegularUsers[] = "LoggedInUsers"; | 68 const char kRegularUsers[] = "LoggedInUsers"; |
| 68 | 69 |
| 69 // A vector pref of the public accounts defined on this device. | 70 // A vector pref of the public accounts defined on this device. |
| 70 const char kPublicAccounts[] = "PublicAccounts"; | 71 const char kPublicAccounts[] = "PublicAccounts"; |
| 71 | 72 |
| 72 // A string pref that gets set when a public account is removed but a user is | 73 // A string pref that gets set when a public account is removed but a user is |
| 73 // currently logged into that account, requiring the account's data to be | 74 // currently logged into that account, requiring the account's data to be |
| 74 // removed after logout. | 75 // removed after logout. |
| 75 const char kPublicAccountPendingDataRemoval[] = | 76 const char kPublicAccountPendingDataRemoval[] = |
| 76 "PublicAccountPendingDataRemoval"; | 77 "PublicAccountPendingDataRemoval"; |
| 77 | 78 |
| 78 } // namespace | 79 } // namespace |
| 79 | 80 |
| 80 // static | 81 // static |
| 81 void UserManager::RegisterPrefs(PrefRegistrySimple* registry) { | 82 void ChromeUserManagerImpl::RegisterPrefs(PrefRegistrySimple* registry) { |
| 82 UserManagerBase::RegisterPrefs(registry); | 83 ChromeUserManager::RegisterPrefs(registry); |
| 83 | 84 |
| 84 registry->RegisterListPref(kPublicAccounts); | 85 registry->RegisterListPref(kPublicAccounts); |
| 85 registry->RegisterStringPref(kPublicAccountPendingDataRemoval, std::string()); | 86 registry->RegisterStringPref(kPublicAccountPendingDataRemoval, std::string()); |
| 86 SupervisedUserManager::RegisterPrefs(registry); | 87 SupervisedUserManager::RegisterPrefs(registry); |
| 87 SessionLengthLimiter::RegisterPrefs(registry); | 88 SessionLengthLimiter::RegisterPrefs(registry); |
| 88 } | 89 } |
| 89 | 90 |
| 90 ChromeUserManager::ChromeUserManager() | 91 // static |
| 91 : cros_settings_(CrosSettings::Get()), | 92 scoped_ptr<ChromeUserManager> ChromeUserManagerImpl::CreateChromeUserManager() { |
| 93 return scoped_ptr<ChromeUserManager>(new ChromeUserManagerImpl()); |
| 94 } |
| 95 |
| 96 ChromeUserManagerImpl::ChromeUserManagerImpl() |
| 97 : ChromeUserManager(base::ThreadTaskRunnerHandle::Get(), |
| 98 BrowserThread::GetBlockingPool()), |
| 99 cros_settings_(CrosSettings::Get()), |
| 92 device_local_account_policy_service_(NULL), | 100 device_local_account_policy_service_(NULL), |
| 93 supervised_user_manager_(new SupervisedUserManagerImpl(this)), | 101 supervised_user_manager_(new SupervisedUserManagerImpl(this)), |
| 94 weak_factory_(this) { | 102 weak_factory_(this) { |
| 95 UpdateNumberOfUsers(); | 103 UpdateNumberOfUsers(); |
| 96 | 104 |
| 97 // UserManager instance should be used only on UI thread. | 105 // UserManager instance should be used only on UI thread. |
| 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 99 registrar_.Add(this, | 107 registrar_.Add(this, |
| 100 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, | 108 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
| 101 content::NotificationService::AllSources()); | 109 content::NotificationService::AllSources()); |
| 102 registrar_.Add(this, | 110 registrar_.Add(this, |
| 103 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 111 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 104 content::NotificationService::AllSources()); | 112 content::NotificationService::AllSources()); |
| 105 registrar_.Add(this, | 113 registrar_.Add(this, |
| 106 chrome::NOTIFICATION_PROFILE_CREATED, | 114 chrome::NOTIFICATION_PROFILE_CREATED, |
| 107 content::NotificationService::AllSources()); | 115 content::NotificationService::AllSources()); |
| 108 | 116 |
| 109 // Since we're in ctor postpone any actions till this is fully created. | 117 // Since we're in ctor postpone any actions till this is fully created. |
| 110 if (base::MessageLoop::current()) { | 118 if (base::MessageLoop::current()) { |
| 111 base::MessageLoop::current()->PostTask( | 119 base::MessageLoop::current()->PostTask( |
| 112 FROM_HERE, | 120 FROM_HERE, |
| 113 base::Bind(&ChromeUserManager::RetrieveTrustedDevicePolicies, | 121 base::Bind(&ChromeUserManagerImpl::RetrieveTrustedDevicePolicies, |
| 114 weak_factory_.GetWeakPtr())); | 122 weak_factory_.GetWeakPtr())); |
| 115 } | 123 } |
| 116 | 124 |
| 117 local_accounts_subscription_ = cros_settings_->AddSettingsObserver( | 125 local_accounts_subscription_ = cros_settings_->AddSettingsObserver( |
| 118 kAccountsPrefDeviceLocalAccounts, | 126 kAccountsPrefDeviceLocalAccounts, |
| 119 base::Bind(&ChromeUserManager::RetrieveTrustedDevicePolicies, | 127 base::Bind(&ChromeUserManagerImpl::RetrieveTrustedDevicePolicies, |
| 120 weak_factory_.GetWeakPtr())); | 128 weak_factory_.GetWeakPtr())); |
| 121 multi_profile_user_controller_.reset( | 129 multi_profile_user_controller_.reset( |
| 122 new MultiProfileUserController(this, GetLocalState())); | 130 new MultiProfileUserController(this, GetLocalState())); |
| 123 | 131 |
| 124 policy::BrowserPolicyConnectorChromeOS* connector = | 132 policy::BrowserPolicyConnectorChromeOS* connector = |
| 125 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 133 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 126 avatar_policy_observer_.reset(new policy::CloudExternalDataPolicyObserver( | 134 avatar_policy_observer_.reset(new policy::CloudExternalDataPolicyObserver( |
| 127 cros_settings_, | 135 cros_settings_, |
| 128 connector->GetDeviceLocalAccountPolicyService(), | 136 connector->GetDeviceLocalAccountPolicyService(), |
| 129 policy::key::kUserAvatarImage, | 137 policy::key::kUserAvatarImage, |
| 130 this)); | 138 this)); |
| 131 avatar_policy_observer_->Init(); | 139 avatar_policy_observer_->Init(); |
| 132 | 140 |
| 133 wallpaper_policy_observer_.reset(new policy::CloudExternalDataPolicyObserver( | 141 wallpaper_policy_observer_.reset(new policy::CloudExternalDataPolicyObserver( |
| 134 cros_settings_, | 142 cros_settings_, |
| 135 connector->GetDeviceLocalAccountPolicyService(), | 143 connector->GetDeviceLocalAccountPolicyService(), |
| 136 policy::key::kWallpaperImage, | 144 policy::key::kWallpaperImage, |
| 137 this)); | 145 this)); |
| 138 wallpaper_policy_observer_->Init(); | 146 wallpaper_policy_observer_->Init(); |
| 139 } | 147 } |
| 140 | 148 |
| 141 ChromeUserManager::~ChromeUserManager() { | 149 ChromeUserManagerImpl::~ChromeUserManagerImpl() { |
| 142 } | 150 } |
| 143 | 151 |
| 144 void ChromeUserManager::Shutdown() { | 152 void ChromeUserManagerImpl::Shutdown() { |
| 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 146 UserManagerBase::Shutdown(); | 154 ChromeUserManager::Shutdown(); |
| 147 | 155 |
| 148 local_accounts_subscription_.reset(); | 156 local_accounts_subscription_.reset(); |
| 149 | 157 |
| 150 // Stop the session length limiter. | 158 // Stop the session length limiter. |
| 151 session_length_limiter_.reset(); | 159 session_length_limiter_.reset(); |
| 152 | 160 |
| 153 if (device_local_account_policy_service_) | 161 if (device_local_account_policy_service_) |
| 154 device_local_account_policy_service_->RemoveObserver(this); | 162 device_local_account_policy_service_->RemoveObserver(this); |
| 155 | 163 |
| 156 for (UserImageManagerMap::iterator it = user_image_managers_.begin(), | 164 for (UserImageManagerMap::iterator it = user_image_managers_.begin(), |
| 157 ie = user_image_managers_.end(); | 165 ie = user_image_managers_.end(); |
| 158 it != ie; | 166 it != ie; |
| 159 ++it) { | 167 ++it) { |
| 160 it->second->Shutdown(); | 168 it->second->Shutdown(); |
| 161 } | 169 } |
| 162 multi_profile_user_controller_.reset(); | 170 multi_profile_user_controller_.reset(); |
| 163 avatar_policy_observer_.reset(); | 171 avatar_policy_observer_.reset(); |
| 164 wallpaper_policy_observer_.reset(); | 172 wallpaper_policy_observer_.reset(); |
| 165 registrar_.RemoveAll(); | 173 registrar_.RemoveAll(); |
| 166 } | 174 } |
| 167 | 175 |
| 168 MultiProfileUserController* ChromeUserManager::GetMultiProfileUserController() { | 176 MultiProfileUserController* |
| 177 ChromeUserManagerImpl::GetMultiProfileUserController() { |
| 169 return multi_profile_user_controller_.get(); | 178 return multi_profile_user_controller_.get(); |
| 170 } | 179 } |
| 171 | 180 |
| 172 UserImageManager* ChromeUserManager::GetUserImageManager( | 181 UserImageManager* ChromeUserManagerImpl::GetUserImageManager( |
| 173 const std::string& user_id) { | 182 const std::string& user_id) { |
| 174 UserImageManagerMap::iterator ui = user_image_managers_.find(user_id); | 183 UserImageManagerMap::iterator ui = user_image_managers_.find(user_id); |
| 175 if (ui != user_image_managers_.end()) | 184 if (ui != user_image_managers_.end()) |
| 176 return ui->second.get(); | 185 return ui->second.get(); |
| 177 linked_ptr<UserImageManagerImpl> mgr(new UserImageManagerImpl(user_id, this)); | 186 linked_ptr<UserImageManagerImpl> mgr(new UserImageManagerImpl(user_id, this)); |
| 178 user_image_managers_[user_id] = mgr; | 187 user_image_managers_[user_id] = mgr; |
| 179 return mgr.get(); | 188 return mgr.get(); |
| 180 } | 189 } |
| 181 | 190 |
| 182 SupervisedUserManager* ChromeUserManager::GetSupervisedUserManager() { | 191 SupervisedUserManager* ChromeUserManagerImpl::GetSupervisedUserManager() { |
| 183 return supervised_user_manager_.get(); | 192 return supervised_user_manager_.get(); |
| 184 } | 193 } |
| 185 | 194 |
| 186 user_manager::UserList ChromeUserManager::GetUsersAdmittedForMultiProfile() | 195 user_manager::UserList ChromeUserManagerImpl::GetUsersAdmittedForMultiProfile() |
| 187 const { | 196 const { |
| 188 // Supervised users are not allowed to use multi-profiles. | 197 // Supervised users are not allowed to use multi-profiles. |
| 189 if (GetLoggedInUsers().size() == 1 && | 198 if (GetLoggedInUsers().size() == 1 && |
| 190 GetPrimaryUser()->GetType() != user_manager::USER_TYPE_REGULAR) { | 199 GetPrimaryUser()->GetType() != user_manager::USER_TYPE_REGULAR) { |
| 191 return user_manager::UserList(); | 200 return user_manager::UserList(); |
| 192 } | 201 } |
| 193 | 202 |
| 194 user_manager::UserList result; | 203 user_manager::UserList result; |
| 195 const user_manager::UserList& users = GetUsers(); | 204 const user_manager::UserList& users = GetUsers(); |
| 196 for (user_manager::UserList::const_iterator it = users.begin(); | 205 for (user_manager::UserList::const_iterator it = users.begin(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 215 check == | 224 check == |
| 216 MultiProfileUserController::NOT_ALLOWED_POLICY_CERT_TAINTED) { | 225 MultiProfileUserController::NOT_ALLOWED_POLICY_CERT_TAINTED) { |
| 217 result.push_back(*it); | 226 result.push_back(*it); |
| 218 } | 227 } |
| 219 } | 228 } |
| 220 } | 229 } |
| 221 | 230 |
| 222 return result; | 231 return result; |
| 223 } | 232 } |
| 224 | 233 |
| 225 user_manager::UserList ChromeUserManager::GetUnlockUsers() const { | 234 user_manager::UserList ChromeUserManagerImpl::GetUnlockUsers() const { |
| 226 const user_manager::UserList& logged_in_users = GetLoggedInUsers(); | 235 const user_manager::UserList& logged_in_users = GetLoggedInUsers(); |
| 227 if (logged_in_users.empty()) | 236 if (logged_in_users.empty()) |
| 228 return user_manager::UserList(); | 237 return user_manager::UserList(); |
| 229 | 238 |
| 230 user_manager::UserList unlock_users; | 239 user_manager::UserList unlock_users; |
| 231 Profile* profile = | 240 Profile* profile = |
| 232 ProfileHelper::Get()->GetProfileByUserUnsafe(GetPrimaryUser()); | 241 ProfileHelper::Get()->GetProfileByUserUnsafe(GetPrimaryUser()); |
| 233 std::string primary_behavior = | 242 std::string primary_behavior = |
| 234 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); | 243 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); |
| 235 | 244 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 254 } else if (behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { | 263 } else if (behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { |
| 255 NOTREACHED() | 264 NOTREACHED() |
| 256 << "Spotted primary-only multi-profile policy for non-primary user"; | 265 << "Spotted primary-only multi-profile policy for non-primary user"; |
| 257 } | 266 } |
| 258 } | 267 } |
| 259 } | 268 } |
| 260 | 269 |
| 261 return unlock_users; | 270 return unlock_users; |
| 262 } | 271 } |
| 263 | 272 |
| 264 void ChromeUserManager::SessionStarted() { | 273 void ChromeUserManagerImpl::SessionStarted() { |
| 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 266 UserManagerBase::SessionStarted(); | 275 ChromeUserManager::SessionStarted(); |
| 267 | 276 |
| 268 content::NotificationService::current()->Notify( | 277 content::NotificationService::current()->Notify( |
| 269 chrome::NOTIFICATION_SESSION_STARTED, | 278 chrome::NOTIFICATION_SESSION_STARTED, |
| 270 content::Source<UserManager>(this), | 279 content::Source<UserManager>(this), |
| 271 content::Details<const user_manager::User>(GetActiveUser())); | 280 content::Details<const user_manager::User>(GetActiveUser())); |
| 272 } | 281 } |
| 273 | 282 |
| 274 void ChromeUserManager::RemoveUserInternal(const std::string& user_email, | 283 void ChromeUserManagerImpl::RemoveUserInternal( |
| 275 RemoveUserDelegate* delegate) { | 284 const std::string& user_email, |
| 285 user_manager::RemoveUserDelegate* delegate) { |
| 276 CrosSettings* cros_settings = CrosSettings::Get(); | 286 CrosSettings* cros_settings = CrosSettings::Get(); |
| 277 | 287 |
| 278 const base::Closure& callback = | 288 const base::Closure& callback = |
| 279 base::Bind(&ChromeUserManager::RemoveUserInternal, | 289 base::Bind(&ChromeUserManagerImpl::RemoveUserInternal, |
| 280 weak_factory_.GetWeakPtr(), | 290 weak_factory_.GetWeakPtr(), |
| 281 user_email, | 291 user_email, |
| 282 delegate); | 292 delegate); |
| 283 | 293 |
| 284 // Ensure the value of owner email has been fetched. | 294 // Ensure the value of owner email has been fetched. |
| 285 if (CrosSettingsProvider::TRUSTED != | 295 if (CrosSettingsProvider::TRUSTED != |
| 286 cros_settings->PrepareTrustedValues(callback)) { | 296 cros_settings->PrepareTrustedValues(callback)) { |
| 287 // Value of owner email is not fetched yet. RemoveUserInternal will be | 297 // Value of owner email is not fetched yet. RemoveUserInternal will be |
| 288 // called again after fetch completion. | 298 // called again after fetch completion. |
| 289 return; | 299 return; |
| 290 } | 300 } |
| 291 std::string owner; | 301 std::string owner; |
| 292 cros_settings->GetString(kDeviceOwner, &owner); | 302 cros_settings->GetString(kDeviceOwner, &owner); |
| 293 if (user_email == owner) { | 303 if (user_email == owner) { |
| 294 // Owner is not allowed to be removed from the device. | 304 // Owner is not allowed to be removed from the device. |
| 295 return; | 305 return; |
| 296 } | 306 } |
| 297 RemoveNonOwnerUserInternal(user_email, delegate); | 307 RemoveNonOwnerUserInternal(user_email, delegate); |
| 298 } | 308 } |
| 299 | 309 |
| 300 void ChromeUserManager::SaveUserOAuthStatus( | 310 void ChromeUserManagerImpl::SaveUserOAuthStatus( |
| 301 const std::string& user_id, | 311 const std::string& user_id, |
| 302 user_manager::User::OAuthTokenStatus oauth_token_status) { | 312 user_manager::User::OAuthTokenStatus oauth_token_status) { |
| 303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 304 UserManagerBase::SaveUserOAuthStatus(user_id, oauth_token_status); | 314 ChromeUserManager::SaveUserOAuthStatus(user_id, oauth_token_status); |
| 305 | 315 |
| 306 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(oauth_token_status); | 316 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(oauth_token_status); |
| 307 } | 317 } |
| 308 | 318 |
| 309 void ChromeUserManager::SaveUserDisplayName( | 319 void ChromeUserManagerImpl::SaveUserDisplayName( |
| 310 const std::string& user_id, | 320 const std::string& user_id, |
| 311 const base::string16& display_name) { | 321 const base::string16& display_name) { |
| 312 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 322 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 313 UserManagerBase::SaveUserDisplayName(user_id, display_name); | 323 ChromeUserManager::SaveUserDisplayName(user_id, display_name); |
| 314 | 324 |
| 315 // Do not update local state if data stored or cached outside the user's | 325 // Do not update local state if data stored or cached outside the user's |
| 316 // cryptohome is to be treated as ephemeral. | 326 // cryptohome is to be treated as ephemeral. |
| 317 if (!IsUserNonCryptohomeDataEphemeral(user_id)) | 327 if (!IsUserNonCryptohomeDataEphemeral(user_id)) |
| 318 supervised_user_manager_->UpdateManagerName(user_id, display_name); | 328 supervised_user_manager_->UpdateManagerName(user_id, display_name); |
| 319 } | 329 } |
| 320 | 330 |
| 321 void ChromeUserManager::StopPolicyObserverForTesting() { | 331 void ChromeUserManagerImpl::StopPolicyObserverForTesting() { |
| 322 avatar_policy_observer_.reset(); | 332 avatar_policy_observer_.reset(); |
| 323 wallpaper_policy_observer_.reset(); | 333 wallpaper_policy_observer_.reset(); |
| 324 } | 334 } |
| 325 | 335 |
| 326 void ChromeUserManager::Observe(int type, | 336 void ChromeUserManagerImpl::Observe( |
| 327 const content::NotificationSource& source, | 337 int type, |
| 328 const content::NotificationDetails& details) { | 338 const content::NotificationSource& source, |
| 339 const content::NotificationDetails& details) { |
| 329 switch (type) { | 340 switch (type) { |
| 330 case chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED: | 341 case chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED: |
| 331 if (!device_local_account_policy_service_) { | 342 if (!device_local_account_policy_service_) { |
| 332 policy::BrowserPolicyConnectorChromeOS* connector = | 343 policy::BrowserPolicyConnectorChromeOS* connector = |
| 333 g_browser_process->platform_part() | 344 g_browser_process->platform_part() |
| 334 ->browser_policy_connector_chromeos(); | 345 ->browser_policy_connector_chromeos(); |
| 335 device_local_account_policy_service_ = | 346 device_local_account_policy_service_ = |
| 336 connector->GetDeviceLocalAccountPolicyService(); | 347 connector->GetDeviceLocalAccountPolicyService(); |
| 337 if (device_local_account_policy_service_) | 348 if (device_local_account_policy_service_) |
| 338 device_local_account_policy_service_->AddObserver(this); | 349 device_local_account_policy_service_->AddObserver(this); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 365 user->set_profile_is_created(); | 376 user->set_profile_is_created(); |
| 366 | 377 |
| 367 // If there is pending user switch, do it now. | 378 // If there is pending user switch, do it now. |
| 368 if (!GetPendingUserSwitchID().empty()) { | 379 if (!GetPendingUserSwitchID().empty()) { |
| 369 // Call SwitchActiveUser async because otherwise it may cause | 380 // Call SwitchActiveUser async because otherwise it may cause |
| 370 // ProfileManager::GetProfile before the profile gets registered | 381 // ProfileManager::GetProfile before the profile gets registered |
| 371 // in ProfileManager. It happens in case of sync profile load when | 382 // in ProfileManager. It happens in case of sync profile load when |
| 372 // NOTIFICATION_PROFILE_CREATED is called synchronously. | 383 // NOTIFICATION_PROFILE_CREATED is called synchronously. |
| 373 base::MessageLoop::current()->PostTask( | 384 base::MessageLoop::current()->PostTask( |
| 374 FROM_HERE, | 385 FROM_HERE, |
| 375 base::Bind(&ChromeUserManager::SwitchActiveUser, | 386 base::Bind(&ChromeUserManagerImpl::SwitchActiveUser, |
| 376 weak_factory_.GetWeakPtr(), | 387 weak_factory_.GetWeakPtr(), |
| 377 GetPendingUserSwitchID())); | 388 GetPendingUserSwitchID())); |
| 378 SetPendingUserSwitchID(std::string()); | 389 SetPendingUserSwitchID(std::string()); |
| 379 } | 390 } |
| 380 break; | 391 break; |
| 381 } | 392 } |
| 382 default: | 393 default: |
| 383 NOTREACHED(); | 394 NOTREACHED(); |
| 384 } | 395 } |
| 385 } | 396 } |
| 386 | 397 |
| 387 void ChromeUserManager::OnExternalDataSet(const std::string& policy, | 398 void ChromeUserManagerImpl::OnExternalDataSet(const std::string& policy, |
| 388 const std::string& user_id) { | 399 const std::string& user_id) { |
| 389 if (policy == policy::key::kUserAvatarImage) | 400 if (policy == policy::key::kUserAvatarImage) |
| 390 GetUserImageManager(user_id)->OnExternalDataSet(policy); | 401 GetUserImageManager(user_id)->OnExternalDataSet(policy); |
| 391 else if (policy == policy::key::kWallpaperImage) | 402 else if (policy == policy::key::kWallpaperImage) |
| 392 WallpaperManager::Get()->OnPolicySet(policy, user_id); | 403 WallpaperManager::Get()->OnPolicySet(policy, user_id); |
| 393 else | 404 else |
| 394 NOTREACHED(); | 405 NOTREACHED(); |
| 395 } | 406 } |
| 396 | 407 |
| 397 void ChromeUserManager::OnExternalDataCleared(const std::string& policy, | 408 void ChromeUserManagerImpl::OnExternalDataCleared(const std::string& policy, |
| 398 const std::string& user_id) { | 409 const std::string& user_id) { |
| 399 if (policy == policy::key::kUserAvatarImage) | 410 if (policy == policy::key::kUserAvatarImage) |
| 400 GetUserImageManager(user_id)->OnExternalDataCleared(policy); | 411 GetUserImageManager(user_id)->OnExternalDataCleared(policy); |
| 401 else if (policy == policy::key::kWallpaperImage) | 412 else if (policy == policy::key::kWallpaperImage) |
| 402 WallpaperManager::Get()->OnPolicyCleared(policy, user_id); | 413 WallpaperManager::Get()->OnPolicyCleared(policy, user_id); |
| 403 else | 414 else |
| 404 NOTREACHED(); | 415 NOTREACHED(); |
| 405 } | 416 } |
| 406 | 417 |
| 407 void ChromeUserManager::OnExternalDataFetched(const std::string& policy, | 418 void ChromeUserManagerImpl::OnExternalDataFetched( |
| 408 const std::string& user_id, | 419 const std::string& policy, |
| 409 scoped_ptr<std::string> data) { | 420 const std::string& user_id, |
| 421 scoped_ptr<std::string> data) { |
| 410 if (policy == policy::key::kUserAvatarImage) | 422 if (policy == policy::key::kUserAvatarImage) |
| 411 GetUserImageManager(user_id)->OnExternalDataFetched(policy, data.Pass()); | 423 GetUserImageManager(user_id)->OnExternalDataFetched(policy, data.Pass()); |
| 412 else if (policy == policy::key::kWallpaperImage) | 424 else if (policy == policy::key::kWallpaperImage) |
| 413 WallpaperManager::Get()->OnPolicyFetched(policy, user_id, data.Pass()); | 425 WallpaperManager::Get()->OnPolicyFetched(policy, user_id, data.Pass()); |
| 414 else | 426 else |
| 415 NOTREACHED(); | 427 NOTREACHED(); |
| 416 } | 428 } |
| 417 | 429 |
| 418 void ChromeUserManager::OnPolicyUpdated(const std::string& user_id) { | 430 void ChromeUserManagerImpl::OnPolicyUpdated(const std::string& user_id) { |
| 419 const user_manager::User* user = FindUser(user_id); | 431 const user_manager::User* user = FindUser(user_id); |
| 420 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 432 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
| 421 return; | 433 return; |
| 422 UpdatePublicAccountDisplayName(user_id); | 434 UpdatePublicAccountDisplayName(user_id); |
| 423 } | 435 } |
| 424 | 436 |
| 425 void ChromeUserManager::OnDeviceLocalAccountsChanged() { | 437 void ChromeUserManagerImpl::OnDeviceLocalAccountsChanged() { |
| 426 // No action needed here, changes to the list of device-local accounts get | 438 // No action needed here, changes to the list of device-local accounts get |
| 427 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. | 439 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. |
| 428 } | 440 } |
| 429 | 441 |
| 430 bool ChromeUserManager::CanCurrentUserLock() const { | 442 bool ChromeUserManagerImpl::CanCurrentUserLock() const { |
| 431 return UserManagerBase::CanCurrentUserLock() && | 443 return ChromeUserManager::CanCurrentUserLock() && |
| 432 GetCurrentUserFlow()->CanLockScreen(); | 444 GetCurrentUserFlow()->CanLockScreen(); |
| 433 } | 445 } |
| 434 | 446 |
| 435 bool ChromeUserManager::IsUserNonCryptohomeDataEphemeral( | 447 bool ChromeUserManagerImpl::IsUserNonCryptohomeDataEphemeral( |
| 436 const std::string& user_id) const { | 448 const std::string& user_id) const { |
| 437 // Data belonging to the obsolete public accounts whose data has not been | 449 // Data belonging to the obsolete public accounts whose data has not been |
| 438 // removed yet is not ephemeral. | 450 // removed yet is not ephemeral. |
| 439 bool is_obsolete_public_account = IsPublicAccountMarkedForRemoval(user_id); | 451 bool is_obsolete_public_account = IsPublicAccountMarkedForRemoval(user_id); |
| 440 | 452 |
| 441 return !is_obsolete_public_account && | 453 return !is_obsolete_public_account && |
| 442 UserManagerBase::IsUserNonCryptohomeDataEphemeral(user_id); | 454 ChromeUserManager::IsUserNonCryptohomeDataEphemeral(user_id); |
| 443 } | 455 } |
| 444 | 456 |
| 445 bool ChromeUserManager::AreEphemeralUsersEnabled() const { | 457 bool ChromeUserManagerImpl::AreEphemeralUsersEnabled() const { |
| 446 policy::BrowserPolicyConnectorChromeOS* connector = | 458 policy::BrowserPolicyConnectorChromeOS* connector = |
| 447 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 459 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 448 return GetEphemeralUsersEnabled() && | 460 return GetEphemeralUsersEnabled() && |
| 449 (connector->IsEnterpriseManaged() || !GetOwnerEmail().empty()); | 461 (connector->IsEnterpriseManaged() || !GetOwnerEmail().empty()); |
| 450 } | 462 } |
| 451 | 463 |
| 452 const std::string& ChromeUserManager::GetApplicationLocale() const { | 464 const std::string& ChromeUserManagerImpl::GetApplicationLocale() const { |
| 453 return g_browser_process->GetApplicationLocale(); | 465 return g_browser_process->GetApplicationLocale(); |
| 454 } | 466 } |
| 455 | 467 |
| 456 PrefService* ChromeUserManager::GetLocalState() const { | 468 PrefService* ChromeUserManagerImpl::GetLocalState() const { |
| 457 return g_browser_process ? g_browser_process->local_state() : NULL; | 469 return g_browser_process ? g_browser_process->local_state() : NULL; |
| 458 } | 470 } |
| 459 | 471 |
| 460 bool ChromeUserManager::IsEnterpriseManaged() const { | 472 void ChromeUserManagerImpl::HandleUserOAuthTokenStatusChange( |
| 473 const std::string& user_id, |
| 474 user_manager::User::OAuthTokenStatus status) const { |
| 475 GetUserFlow(user_id)->HandleOAuthTokenStatusChange(status); |
| 476 } |
| 477 |
| 478 bool ChromeUserManagerImpl::IsEnterpriseManaged() const { |
| 461 policy::BrowserPolicyConnectorChromeOS* connector = | 479 policy::BrowserPolicyConnectorChromeOS* connector = |
| 462 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 480 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 463 return connector->IsEnterpriseManaged(); | 481 return connector->IsEnterpriseManaged(); |
| 464 } | 482 } |
| 465 | 483 |
| 466 void ChromeUserManager::LoadPublicAccounts( | 484 void ChromeUserManagerImpl::LoadPublicAccounts( |
| 467 std::set<std::string>* public_sessions_set) { | 485 std::set<std::string>* public_sessions_set) { |
| 468 const base::ListValue* prefs_public_sessions = | 486 const base::ListValue* prefs_public_sessions = |
| 469 GetLocalState()->GetList(kPublicAccounts); | 487 GetLocalState()->GetList(kPublicAccounts); |
| 470 std::vector<std::string> public_sessions; | 488 std::vector<std::string> public_sessions; |
| 471 ParseUserList(*prefs_public_sessions, | 489 ParseUserList(*prefs_public_sessions, |
| 472 std::set<std::string>(), | 490 std::set<std::string>(), |
| 473 &public_sessions, | 491 &public_sessions, |
| 474 public_sessions_set); | 492 public_sessions_set); |
| 475 for (std::vector<std::string>::const_iterator it = public_sessions.begin(); | 493 for (std::vector<std::string>::const_iterator it = public_sessions.begin(); |
| 476 it != public_sessions.end(); | 494 it != public_sessions.end(); |
| 477 ++it) { | 495 ++it) { |
| 478 users_.push_back(user_manager::User::CreatePublicAccountUser(*it)); | 496 users_.push_back(user_manager::User::CreatePublicAccountUser(*it)); |
| 479 UpdatePublicAccountDisplayName(*it); | 497 UpdatePublicAccountDisplayName(*it); |
| 480 } | 498 } |
| 481 } | 499 } |
| 482 | 500 |
| 483 void ChromeUserManager::PerformPreUserListLoadingActions() { | 501 void ChromeUserManagerImpl::PerformPreUserListLoadingActions() { |
| 484 // Clean up user list first. All code down the path should be synchronous, | 502 // Clean up user list first. All code down the path should be synchronous, |
| 485 // so that local state after transaction rollback is in consistent state. | 503 // so that local state after transaction rollback is in consistent state. |
| 486 // This process also should not trigger EnsureUsersLoaded again. | 504 // This process also should not trigger EnsureUsersLoaded again. |
| 487 if (supervised_user_manager_->HasFailedUserCreationTransaction()) | 505 if (supervised_user_manager_->HasFailedUserCreationTransaction()) |
| 488 supervised_user_manager_->RollbackUserCreationTransaction(); | 506 supervised_user_manager_->RollbackUserCreationTransaction(); |
| 489 } | 507 } |
| 490 | 508 |
| 491 void ChromeUserManager::PerformPostUserListLoadingActions() { | 509 void ChromeUserManagerImpl::PerformPostUserListLoadingActions() { |
| 492 for (user_manager::UserList::iterator ui = users_.begin(), ue = users_.end(); | 510 for (user_manager::UserList::iterator ui = users_.begin(), ue = users_.end(); |
| 493 ui != ue; | 511 ui != ue; |
| 494 ++ui) { | 512 ++ui) { |
| 495 GetUserImageManager((*ui)->email())->LoadUserImage(); | 513 GetUserImageManager((*ui)->email())->LoadUserImage(); |
| 496 } | 514 } |
| 497 } | 515 } |
| 498 | 516 |
| 499 void ChromeUserManager::PerformPostUserLoggedInActions(bool browser_restart) { | 517 void ChromeUserManagerImpl::PerformPostUserLoggedInActions( |
| 518 bool browser_restart) { |
| 500 // Initialize the session length limiter and start it only if | 519 // Initialize the session length limiter and start it only if |
| 501 // session limit is defined by the policy. | 520 // session limit is defined by the policy. |
| 502 session_length_limiter_.reset( | 521 session_length_limiter_.reset( |
| 503 new SessionLengthLimiter(NULL, browser_restart)); | 522 new SessionLengthLimiter(NULL, browser_restart)); |
| 504 } | 523 } |
| 505 | 524 |
| 506 bool ChromeUserManager::IsDemoApp(const std::string& user_id) const { | 525 bool ChromeUserManagerImpl::IsDemoApp(const std::string& user_id) const { |
| 507 return DemoAppLauncher::IsDemoAppSession(user_id); | 526 return DemoAppLauncher::IsDemoAppSession(user_id); |
| 508 } | 527 } |
| 509 | 528 |
| 510 bool ChromeUserManager::IsKioskApp(const std::string& user_id) const { | 529 bool ChromeUserManagerImpl::IsKioskApp(const std::string& user_id) const { |
| 511 policy::DeviceLocalAccount::Type device_local_account_type; | 530 policy::DeviceLocalAccount::Type device_local_account_type; |
| 512 return policy::IsDeviceLocalAccountUser(user_id, | 531 return policy::IsDeviceLocalAccountUser(user_id, |
| 513 &device_local_account_type) && | 532 &device_local_account_type) && |
| 514 device_local_account_type == | 533 device_local_account_type == |
| 515 policy::DeviceLocalAccount::TYPE_KIOSK_APP; | 534 policy::DeviceLocalAccount::TYPE_KIOSK_APP; |
| 516 } | 535 } |
| 517 | 536 |
| 518 bool ChromeUserManager::IsPublicAccountMarkedForRemoval( | 537 bool ChromeUserManagerImpl::IsPublicAccountMarkedForRemoval( |
| 519 const std::string& user_id) const { | 538 const std::string& user_id) const { |
| 520 return user_id == | 539 return user_id == |
| 521 GetLocalState()->GetString(kPublicAccountPendingDataRemoval); | 540 GetLocalState()->GetString(kPublicAccountPendingDataRemoval); |
| 522 } | 541 } |
| 523 | 542 |
| 524 void ChromeUserManager::RetrieveTrustedDevicePolicies() { | 543 void ChromeUserManagerImpl::RetrieveTrustedDevicePolicies() { |
| 525 // Local state may not be initialized in unit_tests. | 544 // Local state may not be initialized in unit_tests. |
| 526 if (!GetLocalState()) | 545 if (!GetLocalState()) |
| 527 return; | 546 return; |
| 528 | 547 |
| 529 SetEphemeralUsersEnabled(false); | 548 SetEphemeralUsersEnabled(false); |
| 530 SetOwnerEmail(std::string()); | 549 SetOwnerEmail(std::string()); |
| 531 | 550 |
| 532 // Schedule a callback if device policy has not yet been verified. | 551 // Schedule a callback if device policy has not yet been verified. |
| 533 if (CrosSettingsProvider::TRUSTED != | 552 if (CrosSettingsProvider::TRUSTED != |
| 534 cros_settings_->PrepareTrustedValues( | 553 cros_settings_->PrepareTrustedValues( |
| 535 base::Bind(&ChromeUserManager::RetrieveTrustedDevicePolicies, | 554 base::Bind(&ChromeUserManagerImpl::RetrieveTrustedDevicePolicies, |
| 536 weak_factory_.GetWeakPtr()))) { | 555 weak_factory_.GetWeakPtr()))) { |
| 537 return; | 556 return; |
| 538 } | 557 } |
| 539 | 558 |
| 540 bool ephemeral_users_enabled = false; | 559 bool ephemeral_users_enabled = false; |
| 541 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled, | 560 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled, |
| 542 &ephemeral_users_enabled); | 561 &ephemeral_users_enabled); |
| 543 SetEphemeralUsersEnabled(ephemeral_users_enabled); | 562 SetEphemeralUsersEnabled(ephemeral_users_enabled); |
| 544 | 563 |
| 545 std::string owner_email; | 564 std::string owner_email; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 570 prefs_users_update->Append(new base::StringValue(user_email)); | 589 prefs_users_update->Append(new base::StringValue(user_email)); |
| 571 ++it; | 590 ++it; |
| 572 } | 591 } |
| 573 } | 592 } |
| 574 } | 593 } |
| 575 | 594 |
| 576 if (changed) | 595 if (changed) |
| 577 NotifyUserListChanged(); | 596 NotifyUserListChanged(); |
| 578 } | 597 } |
| 579 | 598 |
| 580 void ChromeUserManager::GuestUserLoggedIn() { | 599 void ChromeUserManagerImpl::GuestUserLoggedIn() { |
| 581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 600 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 582 UserManagerBase::GuestUserLoggedIn(); | 601 ChromeUserManager::GuestUserLoggedIn(); |
| 583 | 602 |
| 584 // TODO(nkostylev): Add support for passing guest session cryptohome | 603 // TODO(nkostylev): Add support for passing guest session cryptohome |
| 585 // mount point. Legacy (--login-profile) value will be used for now. | 604 // mount point. Legacy (--login-profile) value will be used for now. |
| 586 // http://crosbug.com/230859 | 605 // http://crosbug.com/230859 |
| 587 active_user_->SetStubImage( | 606 active_user_->SetStubImage( |
| 588 user_manager::UserImage( | 607 user_manager::UserImage( |
| 589 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 608 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 590 IDR_PROFILE_PICTURE_LOADING)), | 609 IDR_PROFILE_PICTURE_LOADING)), |
| 591 user_manager::User::USER_IMAGE_INVALID, | 610 user_manager::User::USER_IMAGE_INVALID, |
| 592 false); | 611 false); |
| 593 | 612 |
| 594 // Initializes wallpaper after active_user_ is set. | 613 // Initializes wallpaper after active_user_ is set. |
| 595 WallpaperManager::Get()->SetUserWallpaperNow(chromeos::login::kGuestUserName); | 614 WallpaperManager::Get()->SetUserWallpaperNow(chromeos::login::kGuestUserName); |
| 596 } | 615 } |
| 597 | 616 |
| 598 void ChromeUserManager::RegularUserLoggedIn(const std::string& user_id) { | 617 void ChromeUserManagerImpl::RegularUserLoggedIn(const std::string& user_id) { |
| 599 UserManagerBase::RegularUserLoggedIn(user_id); | 618 ChromeUserManager::RegularUserLoggedIn(user_id); |
| 600 | 619 |
| 601 if (IsCurrentUserNew()) | 620 if (IsCurrentUserNew()) |
| 602 WallpaperManager::Get()->SetUserWallpaperNow(user_id); | 621 WallpaperManager::Get()->SetUserWallpaperNow(user_id); |
| 603 | 622 |
| 604 GetUserImageManager(user_id)->UserLoggedIn(IsCurrentUserNew(), false); | 623 GetUserImageManager(user_id)->UserLoggedIn(IsCurrentUserNew(), false); |
| 605 | 624 |
| 606 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 625 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
| 607 | 626 |
| 608 // Make sure that new data is persisted to Local State. | 627 // Make sure that new data is persisted to Local State. |
| 609 GetLocalState()->CommitPendingWrite(); | 628 GetLocalState()->CommitPendingWrite(); |
| 610 } | 629 } |
| 611 | 630 |
| 612 void ChromeUserManager::RegularUserLoggedInAsEphemeral( | 631 void ChromeUserManagerImpl::RegularUserLoggedInAsEphemeral( |
| 613 const std::string& user_id) { | 632 const std::string& user_id) { |
| 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 633 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 615 UserManagerBase::RegularUserLoggedInAsEphemeral(user_id); | 634 ChromeUserManager::RegularUserLoggedInAsEphemeral(user_id); |
| 616 | 635 |
| 617 GetUserImageManager(user_id)->UserLoggedIn(IsCurrentUserNew(), false); | 636 GetUserImageManager(user_id)->UserLoggedIn(IsCurrentUserNew(), false); |
| 618 WallpaperManager::Get()->SetUserWallpaperNow(user_id); | 637 WallpaperManager::Get()->SetUserWallpaperNow(user_id); |
| 619 } | 638 } |
| 620 | 639 |
| 621 void ChromeUserManager::SupervisedUserLoggedIn(const std::string& user_id) { | 640 void ChromeUserManagerImpl::SupervisedUserLoggedIn(const std::string& user_id) { |
| 622 // TODO(nkostylev): Refactor, share code with RegularUserLoggedIn(). | 641 // TODO(nkostylev): Refactor, share code with RegularUserLoggedIn(). |
| 623 | 642 |
| 624 // Remove the user from the user list. | 643 // Remove the user from the user list. |
| 625 active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); | 644 active_user_ = RemoveRegularOrSupervisedUserFromList(user_id); |
| 626 | 645 |
| 627 // If the user was not found on the user list, create a new user. | 646 // If the user was not found on the user list, create a new user. |
| 628 if (!GetActiveUser()) { | 647 if (!GetActiveUser()) { |
| 629 SetIsCurrentUserNew(true); | 648 SetIsCurrentUserNew(true); |
| 630 active_user_ = user_manager::User::CreateSupervisedUser(user_id); | 649 active_user_ = user_manager::User::CreateSupervisedUser(user_id); |
| 631 // Leaving OAuth token status at the default state = unknown. | 650 // Leaving OAuth token status at the default state = unknown. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 650 GetActiveUser()->GetDisplayName()); | 669 GetActiveUser()->GetDisplayName()); |
| 651 } | 670 } |
| 652 | 671 |
| 653 GetUserImageManager(user_id)->UserLoggedIn(IsCurrentUserNew(), true); | 672 GetUserImageManager(user_id)->UserLoggedIn(IsCurrentUserNew(), true); |
| 654 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 673 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
| 655 | 674 |
| 656 // Make sure that new data is persisted to Local State. | 675 // Make sure that new data is persisted to Local State. |
| 657 GetLocalState()->CommitPendingWrite(); | 676 GetLocalState()->CommitPendingWrite(); |
| 658 } | 677 } |
| 659 | 678 |
| 660 void ChromeUserManager::PublicAccountUserLoggedIn(user_manager::User* user) { | 679 void ChromeUserManagerImpl::PublicAccountUserLoggedIn( |
| 680 user_manager::User* user) { |
| 661 SetIsCurrentUserNew(true); | 681 SetIsCurrentUserNew(true); |
| 662 active_user_ = user; | 682 active_user_ = user; |
| 663 | 683 |
| 664 // The UserImageManager chooses a random avatar picture when a user logs in | 684 // The UserImageManager chooses a random avatar picture when a user logs in |
| 665 // for the first time. Tell the UserImageManager that this user is not new to | 685 // for the first time. Tell the UserImageManager that this user is not new to |
| 666 // prevent the avatar from getting changed. | 686 // prevent the avatar from getting changed. |
| 667 GetUserImageManager(user->email())->UserLoggedIn(false, true); | 687 GetUserImageManager(user->email())->UserLoggedIn(false, true); |
| 668 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 688 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
| 669 } | 689 } |
| 670 | 690 |
| 671 void ChromeUserManager::KioskAppLoggedIn(const std::string& app_id) { | 691 void ChromeUserManagerImpl::KioskAppLoggedIn(const std::string& app_id) { |
| 672 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 692 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 673 policy::DeviceLocalAccount::Type device_local_account_type; | 693 policy::DeviceLocalAccount::Type device_local_account_type; |
| 674 DCHECK(policy::IsDeviceLocalAccountUser(app_id, &device_local_account_type)); | 694 DCHECK(policy::IsDeviceLocalAccountUser(app_id, &device_local_account_type)); |
| 675 DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP, | 695 DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP, |
| 676 device_local_account_type); | 696 device_local_account_type); |
| 677 | 697 |
| 678 active_user_ = user_manager::User::CreateKioskAppUser(app_id); | 698 active_user_ = user_manager::User::CreateKioskAppUser(app_id); |
| 679 active_user_->SetStubImage( | 699 active_user_->SetStubImage( |
| 680 user_manager::UserImage( | 700 user_manager::UserImage( |
| 681 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 701 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 710 | 730 |
| 711 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 731 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 712 command_line->AppendSwitch(::switches::kForceAppMode); | 732 command_line->AppendSwitch(::switches::kForceAppMode); |
| 713 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); | 733 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); |
| 714 | 734 |
| 715 // Disable window animation since kiosk app runs in a single full screen | 735 // Disable window animation since kiosk app runs in a single full screen |
| 716 // window and window animation causes start-up janks. | 736 // window and window animation causes start-up janks. |
| 717 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); | 737 command_line->AppendSwitch(wm::switches::kWindowAnimationsDisabled); |
| 718 } | 738 } |
| 719 | 739 |
| 720 void ChromeUserManager::DemoAccountLoggedIn() { | 740 void ChromeUserManagerImpl::DemoAccountLoggedIn() { |
| 721 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 741 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 722 active_user_ = | 742 active_user_ = |
| 723 user_manager::User::CreateKioskAppUser(DemoAppLauncher::kDemoUserName); | 743 user_manager::User::CreateKioskAppUser(DemoAppLauncher::kDemoUserName); |
| 724 active_user_->SetStubImage( | 744 active_user_->SetStubImage( |
| 725 user_manager::UserImage( | 745 user_manager::UserImage( |
| 726 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 746 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 727 IDR_PROFILE_PICTURE_LOADING)), | 747 IDR_PROFILE_PICTURE_LOADING)), |
| 728 user_manager::User::USER_IMAGE_INVALID, | 748 user_manager::User::USER_IMAGE_INVALID, |
| 729 false); | 749 false); |
| 730 WallpaperManager::Get()->SetUserWallpaperNow(DemoAppLauncher::kDemoUserName); | 750 WallpaperManager::Get()->SetUserWallpaperNow(DemoAppLauncher::kDemoUserName); |
| 731 | 751 |
| 732 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 752 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 733 command_line->AppendSwitch(::switches::kForceAppMode); | 753 command_line->AppendSwitch(::switches::kForceAppMode); |
| 734 command_line->AppendSwitchASCII(::switches::kAppId, | 754 command_line->AppendSwitchASCII(::switches::kAppId, |
| 735 DemoAppLauncher::kDemoAppId); | 755 DemoAppLauncher::kDemoAppId); |
| 736 | 756 |
| 737 // Disable window animation since the demo app runs in a single full screen | 757 // Disable window animation since the demo app runs in a single full screen |
| 738 // window and window animation causes start-up janks. | 758 // window and window animation causes start-up janks. |
| 739 CommandLine::ForCurrentProcess()->AppendSwitch( | 759 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 740 wm::switches::kWindowAnimationsDisabled); | 760 wm::switches::kWindowAnimationsDisabled); |
| 741 } | 761 } |
| 742 | 762 |
| 743 void ChromeUserManager::RetailModeUserLoggedIn() { | 763 void ChromeUserManagerImpl::RetailModeUserLoggedIn() { |
| 744 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 764 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 745 SetIsCurrentUserNew(true); | 765 SetIsCurrentUserNew(true); |
| 746 active_user_ = user_manager::User::CreateRetailModeUser(); | 766 active_user_ = user_manager::User::CreateRetailModeUser(); |
| 747 GetUserImageManager(chromeos::login::kRetailModeUserName) | 767 GetUserImageManager(chromeos::login::kRetailModeUserName) |
| 748 ->UserLoggedIn(IsCurrentUserNew(), true); | 768 ->UserLoggedIn(IsCurrentUserNew(), true); |
| 749 WallpaperManager::Get()->SetUserWallpaperNow( | 769 WallpaperManager::Get()->SetUserWallpaperNow( |
| 750 chromeos::login::kRetailModeUserName); | 770 chromeos::login::kRetailModeUserName); |
| 751 } | 771 } |
| 752 | 772 |
| 753 void ChromeUserManager::NotifyOnLogin() { | 773 void ChromeUserManagerImpl::NotifyOnLogin() { |
| 754 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 774 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 755 | 775 |
| 756 UserSessionManager::OverrideHomedir(); | 776 UserSessionManager::OverrideHomedir(); |
| 757 UpdateNumberOfUsers(); | 777 UpdateNumberOfUsers(); |
| 758 | 778 |
| 759 UserManagerBase::NotifyOnLogin(); | 779 ChromeUserManager::NotifyOnLogin(); |
| 760 | 780 |
| 761 // TODO(nkostylev): Deprecate this notification in favor of | 781 // TODO(nkostylev): Deprecate this notification in favor of |
| 762 // ActiveUserChanged() observer call. | 782 // ActiveUserChanged() observer call. |
| 763 content::NotificationService::current()->Notify( | 783 content::NotificationService::current()->Notify( |
| 764 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 784 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 765 content::Source<UserManager>(this), | 785 content::Source<UserManager>(this), |
| 766 content::Details<const user_manager::User>(GetActiveUser())); | 786 content::Details<const user_manager::User>(GetActiveUser())); |
| 767 | 787 |
| 768 UserSessionManager::GetInstance()->PerformPostUserLoggedInActions(); | 788 UserSessionManager::GetInstance()->PerformPostUserLoggedInActions(); |
| 769 } | 789 } |
| 770 | 790 |
| 771 void ChromeUserManager::UpdateOwnership() { | 791 void ChromeUserManagerImpl::UpdateOwnership() { |
| 772 bool is_owner = DeviceSettingsService::Get()->HasPrivateOwnerKey(); | 792 bool is_owner = DeviceSettingsService::Get()->HasPrivateOwnerKey(); |
| 773 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); | 793 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); |
| 774 | 794 |
| 775 SetCurrentUserIsOwner(is_owner); | 795 SetCurrentUserIsOwner(is_owner); |
| 776 } | 796 } |
| 777 | 797 |
| 778 void ChromeUserManager::RemoveNonCryptohomeData(const std::string& user_id) { | 798 void ChromeUserManagerImpl::RemoveNonCryptohomeData( |
| 779 UserManagerBase::RemoveNonCryptohomeData(user_id); | 799 const std::string& user_id) { |
| 800 ChromeUserManager::RemoveNonCryptohomeData(user_id); |
| 780 | 801 |
| 781 WallpaperManager::Get()->RemoveUserWallpaperInfo(user_id); | 802 WallpaperManager::Get()->RemoveUserWallpaperInfo(user_id); |
| 782 GetUserImageManager(user_id)->DeleteUserImage(); | 803 GetUserImageManager(user_id)->DeleteUserImage(); |
| 783 | 804 |
| 784 supervised_user_manager_->RemoveNonCryptohomeData(user_id); | 805 supervised_user_manager_->RemoveNonCryptohomeData(user_id); |
| 785 | 806 |
| 786 multi_profile_user_controller_->RemoveCachedValues(user_id); | 807 multi_profile_user_controller_->RemoveCachedValues(user_id); |
| 787 } | 808 } |
| 788 | 809 |
| 789 void ChromeUserManager::CleanUpPublicAccountNonCryptohomeDataPendingRemoval() { | 810 void |
| 811 ChromeUserManagerImpl::CleanUpPublicAccountNonCryptohomeDataPendingRemoval() { |
| 790 PrefService* local_state = GetLocalState(); | 812 PrefService* local_state = GetLocalState(); |
| 791 const std::string public_account_pending_data_removal = | 813 const std::string public_account_pending_data_removal = |
| 792 local_state->GetString(kPublicAccountPendingDataRemoval); | 814 local_state->GetString(kPublicAccountPendingDataRemoval); |
| 793 if (public_account_pending_data_removal.empty() || | 815 if (public_account_pending_data_removal.empty() || |
| 794 (IsUserLoggedIn() && | 816 (IsUserLoggedIn() && |
| 795 public_account_pending_data_removal == GetActiveUser()->email())) { | 817 public_account_pending_data_removal == GetActiveUser()->email())) { |
| 796 return; | 818 return; |
| 797 } | 819 } |
| 798 | 820 |
| 799 RemoveNonCryptohomeData(public_account_pending_data_removal); | 821 RemoveNonCryptohomeData(public_account_pending_data_removal); |
| 800 local_state->ClearPref(kPublicAccountPendingDataRemoval); | 822 local_state->ClearPref(kPublicAccountPendingDataRemoval); |
| 801 } | 823 } |
| 802 | 824 |
| 803 void ChromeUserManager::CleanUpPublicAccountNonCryptohomeData( | 825 void ChromeUserManagerImpl::CleanUpPublicAccountNonCryptohomeData( |
| 804 const std::vector<std::string>& old_public_accounts) { | 826 const std::vector<std::string>& old_public_accounts) { |
| 805 std::set<std::string> users; | 827 std::set<std::string> users; |
| 806 for (user_manager::UserList::const_iterator it = users_.begin(); | 828 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 807 it != users_.end(); | 829 it != users_.end(); |
| 808 ++it) | 830 ++it) |
| 809 users.insert((*it)->email()); | 831 users.insert((*it)->email()); |
| 810 | 832 |
| 811 // If the user is logged into a public account that has been removed from the | 833 // If the user is logged into a public account that has been removed from the |
| 812 // user list, mark the account's data as pending removal after logout. | 834 // user list, mark the account's data as pending removal after logout. |
| 813 if (IsLoggedInAsPublicAccount()) { | 835 if (IsLoggedInAsPublicAccount()) { |
| 814 const std::string active_user_id = GetActiveUser()->email(); | 836 const std::string active_user_id = GetActiveUser()->email(); |
| 815 if (users.find(active_user_id) == users.end()) { | 837 if (users.find(active_user_id) == users.end()) { |
| 816 GetLocalState()->SetString(kPublicAccountPendingDataRemoval, | 838 GetLocalState()->SetString(kPublicAccountPendingDataRemoval, |
| 817 active_user_id); | 839 active_user_id); |
| 818 users.insert(active_user_id); | 840 users.insert(active_user_id); |
| 819 } | 841 } |
| 820 } | 842 } |
| 821 | 843 |
| 822 // Remove the data belonging to any other public accounts that are no longer | 844 // Remove the data belonging to any other public accounts that are no longer |
| 823 // found on the user list. | 845 // found on the user list. |
| 824 for (std::vector<std::string>::const_iterator it = | 846 for (std::vector<std::string>::const_iterator it = |
| 825 old_public_accounts.begin(); | 847 old_public_accounts.begin(); |
| 826 it != old_public_accounts.end(); | 848 it != old_public_accounts.end(); |
| 827 ++it) { | 849 ++it) { |
| 828 if (users.find(*it) == users.end()) | 850 if (users.find(*it) == users.end()) |
| 829 RemoveNonCryptohomeData(*it); | 851 RemoveNonCryptohomeData(*it); |
| 830 } | 852 } |
| 831 } | 853 } |
| 832 | 854 |
| 833 bool ChromeUserManager::UpdateAndCleanUpPublicAccounts( | 855 bool ChromeUserManagerImpl::UpdateAndCleanUpPublicAccounts( |
| 834 const std::vector<policy::DeviceLocalAccount>& device_local_accounts) { | 856 const std::vector<policy::DeviceLocalAccount>& device_local_accounts) { |
| 835 // Try to remove any public account data marked as pending removal. | 857 // Try to remove any public account data marked as pending removal. |
| 836 CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); | 858 CleanUpPublicAccountNonCryptohomeDataPendingRemoval(); |
| 837 | 859 |
| 838 // Get the current list of public accounts. | 860 // Get the current list of public accounts. |
| 839 std::vector<std::string> old_public_accounts; | 861 std::vector<std::string> old_public_accounts; |
| 840 for (user_manager::UserList::const_iterator it = users_.begin(); | 862 for (user_manager::UserList::const_iterator it = users_.begin(); |
| 841 it != users_.end(); | 863 it != users_.end(); |
| 842 ++it) { | 864 ++it) { |
| 843 if ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 865 if ((*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 GetUserImageManager((*ui)->email())->LoadUserImage(); | 934 GetUserImageManager((*ui)->email())->LoadUserImage(); |
| 913 } | 935 } |
| 914 | 936 |
| 915 // Remove data belonging to public accounts that are no longer found on the | 937 // Remove data belonging to public accounts that are no longer found on the |
| 916 // user list. | 938 // user list. |
| 917 CleanUpPublicAccountNonCryptohomeData(old_public_accounts); | 939 CleanUpPublicAccountNonCryptohomeData(old_public_accounts); |
| 918 | 940 |
| 919 return true; | 941 return true; |
| 920 } | 942 } |
| 921 | 943 |
| 922 void ChromeUserManager::UpdatePublicAccountDisplayName( | 944 void ChromeUserManagerImpl::UpdatePublicAccountDisplayName( |
| 923 const std::string& user_id) { | 945 const std::string& user_id) { |
| 924 std::string display_name; | 946 std::string display_name; |
| 925 | 947 |
| 926 if (device_local_account_policy_service_) { | 948 if (device_local_account_policy_service_) { |
| 927 policy::DeviceLocalAccountPolicyBroker* broker = | 949 policy::DeviceLocalAccountPolicyBroker* broker = |
| 928 device_local_account_policy_service_->GetBrokerForUser(user_id); | 950 device_local_account_policy_service_->GetBrokerForUser(user_id); |
| 929 if (broker) | 951 if (broker) |
| 930 display_name = broker->GetDisplayName(); | 952 display_name = broker->GetDisplayName(); |
| 931 } | 953 } |
| 932 | 954 |
| 933 // Set or clear the display name. | 955 // Set or clear the display name. |
| 934 SaveUserDisplayName(user_id, base::UTF8ToUTF16(display_name)); | 956 SaveUserDisplayName(user_id, base::UTF8ToUTF16(display_name)); |
| 935 } | 957 } |
| 936 | 958 |
| 937 UserFlow* ChromeUserManager::GetCurrentUserFlow() const { | 959 UserFlow* ChromeUserManagerImpl::GetCurrentUserFlow() const { |
| 938 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 939 if (!IsUserLoggedIn()) | 961 if (!IsUserLoggedIn()) |
| 940 return GetDefaultUserFlow(); | 962 return GetDefaultUserFlow(); |
| 941 return GetUserFlow(GetLoggedInUser()->email()); | 963 return GetUserFlow(GetLoggedInUser()->email()); |
| 942 } | 964 } |
| 943 | 965 |
| 944 UserFlow* ChromeUserManager::GetUserFlow(const std::string& user_id) const { | 966 UserFlow* ChromeUserManagerImpl::GetUserFlow(const std::string& user_id) const { |
| 945 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 967 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 946 FlowMap::const_iterator it = specific_flows_.find(user_id); | 968 FlowMap::const_iterator it = specific_flows_.find(user_id); |
| 947 if (it != specific_flows_.end()) | 969 if (it != specific_flows_.end()) |
| 948 return it->second; | 970 return it->second; |
| 949 return GetDefaultUserFlow(); | 971 return GetDefaultUserFlow(); |
| 950 } | 972 } |
| 951 | 973 |
| 952 void ChromeUserManager::SetUserFlow(const std::string& user_id, | 974 void ChromeUserManagerImpl::SetUserFlow(const std::string& user_id, |
| 953 UserFlow* flow) { | 975 UserFlow* flow) { |
| 954 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 976 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 955 ResetUserFlow(user_id); | 977 ResetUserFlow(user_id); |
| 956 specific_flows_[user_id] = flow; | 978 specific_flows_[user_id] = flow; |
| 957 } | 979 } |
| 958 | 980 |
| 959 void ChromeUserManager::ResetUserFlow(const std::string& user_id) { | 981 void ChromeUserManagerImpl::ResetUserFlow(const std::string& user_id) { |
| 960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 982 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 961 FlowMap::iterator it = specific_flows_.find(user_id); | 983 FlowMap::iterator it = specific_flows_.find(user_id); |
| 962 if (it != specific_flows_.end()) { | 984 if (it != specific_flows_.end()) { |
| 963 delete it->second; | 985 delete it->second; |
| 964 specific_flows_.erase(it); | 986 specific_flows_.erase(it); |
| 965 } | 987 } |
| 966 } | 988 } |
| 967 | 989 |
| 968 bool ChromeUserManager::AreSupervisedUsersAllowed() const { | 990 bool ChromeUserManagerImpl::AreSupervisedUsersAllowed() const { |
| 969 bool supervised_users_allowed = false; | 991 bool supervised_users_allowed = false; |
| 970 cros_settings_->GetBoolean(kAccountsPrefSupervisedUsersEnabled, | 992 cros_settings_->GetBoolean(kAccountsPrefSupervisedUsersEnabled, |
| 971 &supervised_users_allowed); | 993 &supervised_users_allowed); |
| 972 return supervised_users_allowed; | 994 return supervised_users_allowed; |
| 973 } | 995 } |
| 974 | 996 |
| 975 UserFlow* ChromeUserManager::GetDefaultUserFlow() const { | 997 UserFlow* ChromeUserManagerImpl::GetDefaultUserFlow() const { |
| 976 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 977 if (!default_flow_.get()) | 999 if (!default_flow_.get()) |
| 978 default_flow_.reset(new DefaultUserFlow()); | 1000 default_flow_.reset(new DefaultUserFlow()); |
| 979 return default_flow_.get(); | 1001 return default_flow_.get(); |
| 980 } | 1002 } |
| 981 | 1003 |
| 982 void ChromeUserManager::NotifyUserListChanged() { | 1004 void ChromeUserManagerImpl::NotifyUserListChanged() { |
| 983 content::NotificationService::current()->Notify( | 1005 content::NotificationService::current()->Notify( |
| 984 chrome::NOTIFICATION_USER_LIST_CHANGED, | 1006 chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 985 content::Source<UserManager>(this), | 1007 content::Source<UserManager>(this), |
| 986 content::NotificationService::NoDetails()); | 1008 content::NotificationService::NoDetails()); |
| 987 } | 1009 } |
| 988 | 1010 |
| 989 void ChromeUserManager::NotifyUserAddedToSession( | 1011 void ChromeUserManagerImpl::NotifyUserAddedToSession( |
| 990 const user_manager::User* added_user, | 1012 const user_manager::User* added_user, |
| 991 bool user_switch_pending) { | 1013 bool user_switch_pending) { |
| 992 if (user_switch_pending) | 1014 if (user_switch_pending) |
| 993 SetPendingUserSwitchID(added_user->email()); | 1015 SetPendingUserSwitchID(added_user->email()); |
| 994 | 1016 |
| 995 UpdateNumberOfUsers(); | 1017 UpdateNumberOfUsers(); |
| 996 UserManagerBase::NotifyUserAddedToSession(added_user, user_switch_pending); | 1018 ChromeUserManager::NotifyUserAddedToSession(added_user, user_switch_pending); |
| 997 } | 1019 } |
| 998 | 1020 |
| 999 void ChromeUserManager::OnUserNotAllowed(const std::string& user_email) { | 1021 void ChromeUserManagerImpl::OnUserNotAllowed(const std::string& user_email) { |
| 1000 LOG(ERROR) << "Shutdown session because a user is not allowed to be in the " | 1022 LOG(ERROR) << "Shutdown session because a user is not allowed to be in the " |
| 1001 "current session"; | 1023 "current session"; |
| 1002 chromeos::ShowMultiprofilesSessionAbortedDialog(user_email); | 1024 chromeos::ShowMultiprofilesSessionAbortedDialog(user_email); |
| 1003 } | 1025 } |
| 1004 | 1026 |
| 1005 void ChromeUserManager::UpdateNumberOfUsers() { | 1027 void ChromeUserManagerImpl::UpdateNumberOfUsers() { |
| 1006 size_t users = GetLoggedInUsers().size(); | 1028 size_t users = GetLoggedInUsers().size(); |
| 1007 if (users) { | 1029 if (users) { |
| 1008 // Write the user number as UMA stat when a multi user session is possible. | 1030 // Write the user number as UMA stat when a multi user session is possible. |
| 1009 if ((users + GetUsersAdmittedForMultiProfile().size()) > 1) | 1031 if ((users + GetUsersAdmittedForMultiProfile().size()) > 1) |
| 1010 ash::MultiProfileUMA::RecordUserCount(users); | 1032 ash::MultiProfileUMA::RecordUserCount(users); |
| 1011 } | 1033 } |
| 1012 | 1034 |
| 1013 base::debug::SetCrashKeyValue( | 1035 base::debug::SetCrashKeyValue( |
| 1014 crash_keys::kNumberOfUsers, | 1036 crash_keys::kNumberOfUsers, |
| 1015 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); | 1037 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); |
| 1016 } | 1038 } |
| 1017 | 1039 |
| 1018 } // namespace chromeos | 1040 } // namespace chromeos |
| OLD | NEW |