| 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/managed/managed_user_creation_controller
_old.h" | 5 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller
_old.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 sync_service->QuerySyncStatusSummary(); | 128 sync_service->QuerySyncStatusSummary(); |
| 129 | 129 |
| 130 if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) | 130 if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) |
| 131 consumer_->OnLongCreationWarning(); | 131 consumer_->OnLongCreationWarning(); |
| 132 | 132 |
| 133 timeout_timer_.Start( | 133 timeout_timer_.Start( |
| 134 FROM_HERE, | 134 FROM_HERE, |
| 135 base::TimeDelta::FromSeconds(kUserCreationTimeoutSeconds), | 135 base::TimeDelta::FromSeconds(kUserCreationTimeoutSeconds), |
| 136 this, | 136 this, |
| 137 &ManagedUserCreationControllerOld::CreationTimedOut); | 137 &ManagedUserCreationControllerOld::CreationTimedOut); |
| 138 SupervisedUserManager* manager = | 138 SupervisedUserManager* manager = GetUserManager()->GetSupervisedUserManager(); |
| 139 UserManager::Get()->GetSupervisedUserManager(); | |
| 140 manager->StartCreationTransaction(creation_context_->display_name); | 139 manager->StartCreationTransaction(creation_context_->display_name); |
| 141 | 140 |
| 142 creation_context_->local_user_id = manager->GenerateUserId(); | 141 creation_context_->local_user_id = manager->GenerateUserId(); |
| 143 | 142 |
| 144 if (creation_context_->creation_type == NEW_USER) { | 143 if (creation_context_->creation_type == NEW_USER) { |
| 145 creation_context_->sync_user_id = | 144 creation_context_->sync_user_id = |
| 146 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(); | 145 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(); |
| 147 } | 146 } |
| 148 | 147 |
| 149 manager->CreateUserRecord(creation_context_->manager_id, | 148 manager->CreateUserRecord(creation_context_->manager_id, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 190 } |
| 192 if (consumer_) | 191 if (consumer_) |
| 193 consumer_->OnCreationError(code); | 192 consumer_->OnCreationError(code); |
| 194 } | 193 } |
| 195 | 194 |
| 196 void ManagedUserCreationControllerOld::OnMountSuccess( | 195 void ManagedUserCreationControllerOld::OnMountSuccess( |
| 197 const std::string& mount_hash) { | 196 const std::string& mount_hash) { |
| 198 creation_context_->mount_hash = mount_hash; | 197 creation_context_->mount_hash = mount_hash; |
| 199 | 198 |
| 200 SupervisedUserAuthentication* authentication = | 199 SupervisedUserAuthentication* authentication = |
| 201 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 200 GetUserManager()->GetSupervisedUserManager()->GetAuthentication(); |
| 202 | 201 |
| 203 if (creation_context_->creation_type == NEW_USER) { | 202 if (creation_context_->creation_type == NEW_USER) { |
| 204 // Generate master password. | 203 // Generate master password. |
| 205 creation_context_->master_key = authentication->GenerateMasterKey(); | 204 creation_context_->master_key = authentication->GenerateMasterKey(); |
| 206 } | 205 } |
| 207 | 206 |
| 208 VLOG(1) << "Adding master key"; | 207 VLOG(1) << "Adding master key"; |
| 209 | 208 |
| 210 UserContext context(creation_context_->local_user_id); | 209 UserContext context(creation_context_->local_user_id); |
| 211 context.SetKey(Key(creation_context_->password)); | 210 context.SetKey(Key(creation_context_->password)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 content::RecordAction( | 290 content::RecordAction( |
| 292 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); | 291 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); |
| 293 | 292 |
| 294 if (!success) { | 293 if (!success) { |
| 295 if (consumer_) | 294 if (consumer_) |
| 296 consumer_->OnCreationError(TOKEN_WRITE_FAILED); | 295 consumer_->OnCreationError(TOKEN_WRITE_FAILED); |
| 297 return; | 296 return; |
| 298 } | 297 } |
| 299 // Assume that new token is valid. It will be automatically invalidated if | 298 // Assume that new token is valid. It will be automatically invalidated if |
| 300 // sync service fails to use it. | 299 // sync service fails to use it. |
| 301 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, | 300 GetUserManager()->SaveUserOAuthStatus(creation_context_->local_user_id, |
| 302 User::OAUTH2_TOKEN_STATUS_VALID); | 301 User::OAUTH2_TOKEN_STATUS_VALID); |
| 303 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); | 302 GetUserManager()->GetSupervisedUserManager()->CommitCreationTransaction(); |
| 304 if (consumer_) | 303 if (consumer_) |
| 305 consumer_->OnCreationSuccess(); | 304 consumer_->OnCreationSuccess(); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace chromeos | 307 } // namespace chromeos |
| OLD | NEW |