| 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/supervised/supervised_user_creation_cont
roller_new.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_cont
roller_new.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/chromeos/login/auth/mount_manager.h" | 17 #include "chrome/browser/chromeos/login/auth/mount_manager.h" |
| 18 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" | 18 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
| 19 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" | 19 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" |
| 20 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 20 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 21 #include "chrome/browser/chromeos/login/users/user.h" | |
| 22 #include "chrome/browser/chromeos/login/users/user_manager.h" | 21 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 23 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 24 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
| 25 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 26 #include "chromeos/cryptohome/cryptohome_parameters.h" | 25 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 27 #include "chromeos/dbus/dbus_thread_manager.h" | 26 #include "chromeos/dbus/dbus_thread_manager.h" |
| 28 #include "chromeos/dbus/session_manager_client.h" | 27 #include "chromeos/dbus/session_manager_client.h" |
| 29 #include "chromeos/login/auth/key.h" | 28 #include "chromeos/login/auth/key.h" |
| 30 #include "chromeos/login/auth/user_context.h" | 29 #include "chromeos/login/auth/user_context.h" |
| 30 #include "components/user_manager/user.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/user_metrics.h" | 32 #include "content/public/browser/user_metrics.h" |
| 33 #include "crypto/random.h" | 33 #include "crypto/random.h" |
| 34 #include "google_apis/gaia/google_service_auth_error.h" | 34 #include "google_apis/gaia/google_service_auth_error.h" |
| 35 | 35 |
| 36 namespace chromeos { | 36 namespace chromeos { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. | 40 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 DCHECK_EQ(DASHBOARD_CREATED, stage_); | 361 DCHECK_EQ(DASHBOARD_CREATED, stage_); |
| 362 | 362 |
| 363 if (!success) { | 363 if (!success) { |
| 364 stage_ = STAGE_ERROR; | 364 stage_ = STAGE_ERROR; |
| 365 if (consumer_) | 365 if (consumer_) |
| 366 consumer_->OnCreationError(TOKEN_WRITE_FAILED); | 366 consumer_->OnCreationError(TOKEN_WRITE_FAILED); |
| 367 return; | 367 return; |
| 368 } | 368 } |
| 369 // Assume that new token is valid. It will be automatically invalidated if | 369 // Assume that new token is valid. It will be automatically invalidated if |
| 370 // sync service fails to use it. | 370 // sync service fails to use it. |
| 371 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, | 371 UserManager::Get()->SaveUserOAuthStatus( |
| 372 User::OAUTH2_TOKEN_STATUS_VALID); | 372 creation_context_->local_user_id, |
| 373 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 373 | 374 |
| 374 stage_ = TOKEN_WRITTEN; | 375 stage_ = TOKEN_WRITTEN; |
| 375 | 376 |
| 376 timeout_timer_.Stop(); | 377 timeout_timer_.Stop(); |
| 377 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); | 378 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); |
| 378 content::RecordAction( | 379 content::RecordAction( |
| 379 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); | 380 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); |
| 380 | 381 |
| 381 stage_ = TRANSACTION_COMMITTED; | 382 stage_ = TRANSACTION_COMMITTED; |
| 382 | 383 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 398 creation_context_->registration_utility.reset(); | 399 creation_context_->registration_utility.reset(); |
| 399 chrome::AttemptUserExit(); | 400 chrome::AttemptUserExit(); |
| 400 } | 401 } |
| 401 | 402 |
| 402 std::string SupervisedUserCreationControllerNew::GetSupervisedUserId() { | 403 std::string SupervisedUserCreationControllerNew::GetSupervisedUserId() { |
| 403 DCHECK(creation_context_); | 404 DCHECK(creation_context_); |
| 404 return creation_context_->local_user_id; | 405 return creation_context_->local_user_id; |
| 405 } | 406 } |
| 406 | 407 |
| 407 } // namespace chromeos | 408 } // namespace chromeos |
| OLD | NEW |