Chromium Code Reviews| 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/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 CreateUserSession(user_context, has_auth_cookies); | 506 CreateUserSession(user_context, has_auth_cookies); |
| 507 | 507 |
| 508 if (!has_active_session) | 508 if (!has_active_session) |
| 509 StartCrosSession(); | 509 StartCrosSession(); |
| 510 | 510 |
| 511 if (!user_context.GetDeviceId().empty()) { | 511 if (!user_context.GetDeviceId().empty()) { |
| 512 user_manager::known_user::SetDeviceId(user_context.GetAccountId(), | 512 user_manager::known_user::SetDeviceId(user_context.GetAccountId(), |
| 513 user_context.GetDeviceId()); | 513 user_context.GetDeviceId()); |
| 514 } | 514 } |
| 515 | 515 |
| 516 // If the filesystem compatibiliy with ARC is not established yet, test it. | |
|
Luis Héctor Chávez
2017/04/13 21:11:47
nit: s/compatibiliy/compatibility/
kinaba
2017/04/14 04:33:55
Acknowledged.
| |
| 517 int arc_filesystem_compatibility = arc::kFileSystemIncompatible; | |
|
Luis Héctor Chávez
2017/04/13 21:11:47
nit: s/int/arc::FileSystemCompatibilityState/
kinaba
2017/04/14 04:33:55
GetIntegerPref needs to take int* so it cannot be
| |
| 518 user_manager::known_user::GetIntegerPref( | |
| 519 user_context_.GetAccountId(), prefs::kArcCompatibleFilesystemChosen, | |
| 520 &arc_filesystem_compatibility); | |
| 521 if (arc_filesystem_compatibility == arc::kFileSystemIncompatible) { | |
|
xiyuan
2017/04/13 16:35:59
What about old devices that are never going to be
Luis Héctor Chávez
2017/04/13 21:11:47
When you move the ownership of the pref to arc_uti
kinaba
2017/04/14 04:33:55
Thanks for the suggestions. Both done (IsArcAvaila
| |
| 522 base::PostTaskWithTraitsAndReplyWithResult( | |
| 523 FROM_HERE, | |
| 524 base::TaskTraits() | |
| 525 .WithShutdownBehavior( | |
| 526 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | |
| 527 .WithPriority(base::TaskPriority::USER_BLOCKING) | |
| 528 .MayBlock(), | |
| 529 base::Bind(&arc::IsArcCompatibleFilesystem, | |
| 530 ProfileHelper::GetProfilePathByUserIdHash( | |
| 531 user_context_.GetUserIDHash())), | |
| 532 base::Bind(&UserSessionManager::SetFileSystemPrefAndPrepareProfile, | |
| 533 AsWeakPtr())); | |
| 534 return; | |
| 535 } | |
| 536 | |
| 516 PrepareProfile(); | 537 PrepareProfile(); |
| 517 } | 538 } |
| 518 | 539 |
| 519 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { | 540 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { |
| 520 if (delegate_ == delegate) | 541 if (delegate_ == delegate) |
| 521 delegate_ = nullptr; | 542 delegate_ = nullptr; |
| 522 } | 543 } |
| 523 | 544 |
| 524 void UserSessionManager::PerformPostUserLoggedInActions() { | 545 void UserSessionManager::PerformPostUserLoggedInActions() { |
| 525 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 546 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 } | 997 } |
| 977 | 998 |
| 978 void UserSessionManager::StartCrosSession() { | 999 void UserSessionManager::StartCrosSession() { |
| 979 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 1000 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
| 980 btl->AddLoginTimeMarker("StartSession-Start", false); | 1001 btl->AddLoginTimeMarker("StartSession-Start", false); |
| 981 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( | 1002 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
| 982 cryptohome::Identification(user_context_.GetAccountId())); | 1003 cryptohome::Identification(user_context_.GetAccountId())); |
| 983 btl->AddLoginTimeMarker("StartSession-End", false); | 1004 btl->AddLoginTimeMarker("StartSession-End", false); |
| 984 } | 1005 } |
| 985 | 1006 |
| 986 void UserSessionManager::PrepareProfile() { | 1007 void UserSessionManager::SetFileSystemPrefAndPrepareProfile( |
| 987 const base::FilePath profile_path = | 1008 bool arc_compatible_filesystem) { |
| 988 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()); | 1009 if (arc_compatible_filesystem) { |
| 989 | 1010 user_manager::known_user::SetIntegerPref( |
|
Luis Héctor Chávez
2017/04/13 21:11:47
Is it possible to centralize the ownership of pref
kinaba
2017/04/14 04:33:55
Done.
| |
| 990 base::PostTaskWithTraitsAndReplyWithResult( | 1011 user_context_.GetAccountId(), prefs::kArcCompatibleFilesystemChosen, |
| 991 FROM_HERE, | 1012 arc::kFileSystemCompatible); |
| 992 base::TaskTraits() | 1013 } |
| 993 .WithShutdownBehavior( | 1014 PrepareProfile(); |
| 994 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | |
| 995 .WithPriority(base::TaskPriority::USER_BLOCKING) | |
| 996 .MayBlock(), | |
| 997 base::Bind(&arc::IsArcCompatibleFilesystem, profile_path), | |
| 998 base::Bind(&UserSessionManager::PrepareProfileAfterFilesystemCheck, | |
| 999 AsWeakPtr())); | |
| 1000 } | 1015 } |
| 1001 | 1016 |
| 1002 void UserSessionManager::PrepareProfileAfterFilesystemCheck( | 1017 void UserSessionManager::PrepareProfile() { |
| 1003 bool arc_compatible_filesystem) { | |
| 1004 const bool is_demo_session = | 1018 const bool is_demo_session = |
| 1005 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); | 1019 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); |
| 1006 | 1020 |
| 1007 // TODO(nkostylev): Figure out whether demo session is using the right profile | 1021 // TODO(nkostylev): Figure out whether demo session is using the right profile |
| 1008 // path or not. See https://codereview.chromium.org/171423009 | 1022 // path or not. See https://codereview.chromium.org/171423009 |
| 1009 g_browser_process->profile_manager()->CreateProfileAsync( | 1023 g_browser_process->profile_manager()->CreateProfileAsync( |
| 1010 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), | 1024 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), |
| 1011 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), | 1025 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), |
| 1012 user_context_, is_demo_session, arc_compatible_filesystem), | 1026 user_context_, is_demo_session), |
| 1013 base::string16(), std::string(), std::string()); | 1027 base::string16(), std::string(), std::string()); |
| 1014 } | 1028 } |
| 1015 | 1029 |
| 1016 void UserSessionManager::OnProfileCreated(const UserContext& user_context, | 1030 void UserSessionManager::OnProfileCreated(const UserContext& user_context, |
| 1017 bool is_incognito_profile, | 1031 bool is_incognito_profile, |
| 1018 bool arc_compatible_filesystem, | |
| 1019 Profile* profile, | 1032 Profile* profile, |
| 1020 Profile::CreateStatus status) { | 1033 Profile::CreateStatus status) { |
| 1021 CHECK(profile); | 1034 CHECK(profile); |
| 1022 | 1035 |
| 1023 switch (status) { | 1036 switch (status) { |
| 1024 case Profile::CREATE_STATUS_CREATED: | 1037 case Profile::CREATE_STATUS_CREATED: |
| 1025 // Profile created but before initializing extensions and promo resources. | 1038 // Profile created but before initializing extensions and promo resources. |
| 1026 InitProfilePreferences(profile, user_context, arc_compatible_filesystem); | 1039 InitProfilePreferences(profile, user_context); |
| 1027 break; | 1040 break; |
| 1028 case Profile::CREATE_STATUS_INITIALIZED: | 1041 case Profile::CREATE_STATUS_INITIALIZED: |
| 1029 // Profile is created, extensions and promo resources are initialized. | 1042 // Profile is created, extensions and promo resources are initialized. |
| 1030 // At this point all other Chrome OS services will be notified that it is | 1043 // At this point all other Chrome OS services will be notified that it is |
| 1031 // safe to use this profile. | 1044 // safe to use this profile. |
| 1032 UserProfileInitialized(profile, is_incognito_profile, | 1045 UserProfileInitialized(profile, is_incognito_profile, |
| 1033 user_context.GetAccountId()); | 1046 user_context.GetAccountId()); |
| 1034 break; | 1047 break; |
| 1035 case Profile::CREATE_STATUS_LOCAL_FAIL: | 1048 case Profile::CREATE_STATUS_LOCAL_FAIL: |
| 1036 case Profile::CREATE_STATUS_REMOTE_FAIL: | 1049 case Profile::CREATE_STATUS_REMOTE_FAIL: |
| 1037 case Profile::CREATE_STATUS_CANCELED: | 1050 case Profile::CREATE_STATUS_CANCELED: |
| 1038 case Profile::MAX_CREATE_STATUS: | 1051 case Profile::MAX_CREATE_STATUS: |
| 1039 NOTREACHED(); | 1052 NOTREACHED(); |
| 1040 break; | 1053 break; |
| 1041 } | 1054 } |
| 1042 } | 1055 } |
| 1043 | 1056 |
| 1044 void UserSessionManager::InitProfilePreferences( | 1057 void UserSessionManager::InitProfilePreferences( |
| 1045 Profile* profile, | 1058 Profile* profile, |
| 1046 const UserContext& user_context, | 1059 const UserContext& user_context) { |
| 1047 bool arc_compatible_filesystem) { | |
| 1048 profile->GetPrefs()->SetBoolean(prefs::kArcCompatibleFilesystemChosen, | |
| 1049 arc_compatible_filesystem); | |
| 1050 | |
| 1051 const user_manager::User* user = | 1060 const user_manager::User* user = |
| 1052 ProfileHelper::Get()->GetUserByProfile(profile); | 1061 ProfileHelper::Get()->GetUserByProfile(profile); |
| 1053 if (user->GetType() == user_manager::USER_TYPE_KIOSK_APP && | 1062 if (user->GetType() == user_manager::USER_TYPE_KIOSK_APP && |
| 1054 profile->IsNewProfile()) { | 1063 profile->IsNewProfile()) { |
| 1055 ChromeUserManager::Get()->SetIsCurrentUserNew(true); | 1064 ChromeUserManager::Get()->SetIsCurrentUserNew(true); |
| 1056 } | 1065 } |
| 1057 | 1066 |
| 1058 if (user->is_active()) { | 1067 if (user->is_active()) { |
| 1059 input_method::InputMethodManager* manager = | 1068 input_method::InputMethodManager* manager = |
| 1060 input_method::InputMethodManager::Get(); | 1069 input_method::InputMethodManager::Get(); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1971 ->browser_policy_connector_chromeos() | 1980 ->browser_policy_connector_chromeos() |
| 1972 ->IsEnterpriseManaged()) { | 1981 ->IsEnterpriseManaged()) { |
| 1973 return false; | 1982 return false; |
| 1974 } | 1983 } |
| 1975 | 1984 |
| 1976 // Do not show end of life notification if this is a guest session | 1985 // Do not show end of life notification if this is a guest session |
| 1977 return !profile->IsGuestSession(); | 1986 return !profile->IsGuestSession(); |
| 1978 } | 1987 } |
| 1979 | 1988 |
| 1980 } // namespace chromeos | 1989 } // namespace chromeos |
| OLD | NEW |