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 PrepareProfile(); | 516 arc::UpdateArcFileSystemCompatibilityPrefIfNeeded( |
| 517 user_context_.GetAccountId(), |
| 518 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), |
| 519 base::Bind(&UserSessionManager::PrepareProfile, AsWeakPtr())); |
517 } | 520 } |
518 | 521 |
519 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { | 522 void UserSessionManager::DelegateDeleted(UserSessionManagerDelegate* delegate) { |
520 if (delegate_ == delegate) | 523 if (delegate_ == delegate) |
521 delegate_ = nullptr; | 524 delegate_ = nullptr; |
522 } | 525 } |
523 | 526 |
524 void UserSessionManager::PerformPostUserLoggedInActions() { | 527 void UserSessionManager::PerformPostUserLoggedInActions() { |
525 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 528 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
526 if (user_manager->GetLoggedInUsers().size() == 1) { | 529 if (user_manager->GetLoggedInUsers().size() == 1) { |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 | 980 |
978 void UserSessionManager::StartCrosSession() { | 981 void UserSessionManager::StartCrosSession() { |
979 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 982 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
980 btl->AddLoginTimeMarker("StartSession-Start", false); | 983 btl->AddLoginTimeMarker("StartSession-Start", false); |
981 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( | 984 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
982 cryptohome::Identification(user_context_.GetAccountId())); | 985 cryptohome::Identification(user_context_.GetAccountId())); |
983 btl->AddLoginTimeMarker("StartSession-End", false); | 986 btl->AddLoginTimeMarker("StartSession-End", false); |
984 } | 987 } |
985 | 988 |
986 void UserSessionManager::PrepareProfile() { | 989 void UserSessionManager::PrepareProfile() { |
987 const base::FilePath profile_path = | |
988 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()); | |
989 | |
990 base::PostTaskWithTraitsAndReplyWithResult( | |
991 FROM_HERE, | |
992 base::TaskTraits() | |
993 .WithShutdownBehavior( | |
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 } | |
1001 | |
1002 void UserSessionManager::PrepareProfileAfterFilesystemCheck( | |
1003 bool arc_compatible_filesystem) { | |
1004 const bool is_demo_session = | 990 const bool is_demo_session = |
1005 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); | 991 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); |
1006 | 992 |
1007 // TODO(nkostylev): Figure out whether demo session is using the right profile | 993 // TODO(nkostylev): Figure out whether demo session is using the right profile |
1008 // path or not. See https://codereview.chromium.org/171423009 | 994 // path or not. See https://codereview.chromium.org/171423009 |
1009 g_browser_process->profile_manager()->CreateProfileAsync( | 995 g_browser_process->profile_manager()->CreateProfileAsync( |
1010 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), | 996 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), |
1011 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), | 997 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), |
1012 user_context_, is_demo_session, arc_compatible_filesystem), | 998 user_context_, is_demo_session), |
1013 base::string16(), std::string(), std::string()); | 999 base::string16(), std::string(), std::string()); |
1014 } | 1000 } |
1015 | 1001 |
1016 void UserSessionManager::OnProfileCreated(const UserContext& user_context, | 1002 void UserSessionManager::OnProfileCreated(const UserContext& user_context, |
1017 bool is_incognito_profile, | 1003 bool is_incognito_profile, |
1018 bool arc_compatible_filesystem, | |
1019 Profile* profile, | 1004 Profile* profile, |
1020 Profile::CreateStatus status) { | 1005 Profile::CreateStatus status) { |
1021 CHECK(profile); | 1006 CHECK(profile); |
1022 | 1007 |
1023 switch (status) { | 1008 switch (status) { |
1024 case Profile::CREATE_STATUS_CREATED: | 1009 case Profile::CREATE_STATUS_CREATED: |
1025 // Profile created but before initializing extensions and promo resources. | 1010 // Profile created but before initializing extensions and promo resources. |
1026 InitProfilePreferences(profile, user_context, arc_compatible_filesystem); | 1011 InitProfilePreferences(profile, user_context); |
1027 break; | 1012 break; |
1028 case Profile::CREATE_STATUS_INITIALIZED: | 1013 case Profile::CREATE_STATUS_INITIALIZED: |
1029 // Profile is created, extensions and promo resources are initialized. | 1014 // Profile is created, extensions and promo resources are initialized. |
1030 // At this point all other Chrome OS services will be notified that it is | 1015 // At this point all other Chrome OS services will be notified that it is |
1031 // safe to use this profile. | 1016 // safe to use this profile. |
1032 UserProfileInitialized(profile, is_incognito_profile, | 1017 UserProfileInitialized(profile, is_incognito_profile, |
1033 user_context.GetAccountId()); | 1018 user_context.GetAccountId()); |
1034 break; | 1019 break; |
1035 case Profile::CREATE_STATUS_LOCAL_FAIL: | 1020 case Profile::CREATE_STATUS_LOCAL_FAIL: |
1036 case Profile::CREATE_STATUS_REMOTE_FAIL: | 1021 case Profile::CREATE_STATUS_REMOTE_FAIL: |
1037 case Profile::CREATE_STATUS_CANCELED: | 1022 case Profile::CREATE_STATUS_CANCELED: |
1038 case Profile::MAX_CREATE_STATUS: | 1023 case Profile::MAX_CREATE_STATUS: |
1039 NOTREACHED(); | 1024 NOTREACHED(); |
1040 break; | 1025 break; |
1041 } | 1026 } |
1042 } | 1027 } |
1043 | 1028 |
1044 void UserSessionManager::InitProfilePreferences( | 1029 void UserSessionManager::InitProfilePreferences( |
1045 Profile* profile, | 1030 Profile* profile, |
1046 const UserContext& user_context, | 1031 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 = | 1032 const user_manager::User* user = |
1052 ProfileHelper::Get()->GetUserByProfile(profile); | 1033 ProfileHelper::Get()->GetUserByProfile(profile); |
1053 if (user->GetType() == user_manager::USER_TYPE_KIOSK_APP && | 1034 if (user->GetType() == user_manager::USER_TYPE_KIOSK_APP && |
1054 profile->IsNewProfile()) { | 1035 profile->IsNewProfile()) { |
1055 ChromeUserManager::Get()->SetIsCurrentUserNew(true); | 1036 ChromeUserManager::Get()->SetIsCurrentUserNew(true); |
1056 } | 1037 } |
1057 | 1038 |
1058 if (user->is_active()) { | 1039 if (user->is_active()) { |
1059 input_method::InputMethodManager* manager = | 1040 input_method::InputMethodManager* manager = |
1060 input_method::InputMethodManager::Get(); | 1041 input_method::InputMethodManager::Get(); |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 ->browser_policy_connector_chromeos() | 1952 ->browser_policy_connector_chromeos() |
1972 ->IsEnterpriseManaged()) { | 1953 ->IsEnterpriseManaged()) { |
1973 return false; | 1954 return false; |
1974 } | 1955 } |
1975 | 1956 |
1976 // Do not show end of life notification if this is a guest session | 1957 // Do not show end of life notification if this is a guest session |
1977 return !profile->IsGuestSession(); | 1958 return !profile->IsGuestSession(); |
1978 } | 1959 } |
1979 | 1960 |
1980 } // namespace chromeos | 1961 } // namespace chromeos |
OLD | NEW |