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 13 matching lines...) Expand all Loading... | |
| 24 #include "base/task_scheduler/post_task.h" | 24 #include "base/task_scheduler/post_task.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "chrome/browser/about_flags.h" | 26 #include "chrome/browser/about_flags.h" |
| 27 #include "chrome/browser/app_mode/app_mode_utils.h" | 27 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 29 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 30 #include "chrome/browser/browser_shutdown.h" | 30 #include "chrome/browser/browser_shutdown.h" |
| 31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
| 32 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 32 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 33 #include "chrome/browser/chromeos/arc/arc_service_launcher.h" | 33 #include "chrome/browser/chromeos/arc/arc_service_launcher.h" |
| 34 #include "chrome/browser/chromeos/arc/arc_util.h" | |
| 34 #include "chrome/browser/chromeos/base/locale_util.h" | 35 #include "chrome/browser/chromeos/base/locale_util.h" |
| 35 #include "chrome/browser/chromeos/boot_times_recorder.h" | 36 #include "chrome/browser/chromeos/boot_times_recorder.h" |
| 36 #include "chrome/browser/chromeos/first_run/first_run.h" | 37 #include "chrome/browser/chromeos/first_run/first_run.h" |
| 37 #include "chrome/browser/chromeos/first_run/goodies_displayer.h" | 38 #include "chrome/browser/chromeos/first_run/goodies_displayer.h" |
| 38 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 39 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 39 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h" | 40 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h" |
| 40 #include "chrome/browser/chromeos/login/chrome_restart_request.h" | 41 #include "chrome/browser/chromeos/login/chrome_restart_request.h" |
| 41 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 42 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
| 42 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" | 43 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
| 43 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 44 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 | 979 |
| 979 void UserSessionManager::StartCrosSession() { | 980 void UserSessionManager::StartCrosSession() { |
| 980 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 981 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
| 981 btl->AddLoginTimeMarker("StartSession-Start", false); | 982 btl->AddLoginTimeMarker("StartSession-Start", false); |
| 982 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( | 983 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
| 983 cryptohome::Identification(user_context_.GetAccountId())); | 984 cryptohome::Identification(user_context_.GetAccountId())); |
| 984 btl->AddLoginTimeMarker("StartSession-End", false); | 985 btl->AddLoginTimeMarker("StartSession-End", false); |
| 985 } | 986 } |
| 986 | 987 |
| 987 void UserSessionManager::PrepareProfile() { | 988 void UserSessionManager::PrepareProfile() { |
| 989 const base::FilePath profile_path = | |
| 990 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()); | |
| 991 | |
| 992 base::PostTaskWithTraitsAndReplyWithResult(FROM_HERE, | |
|
xiyuan
2017/04/03 16:20:49
nit: Skip the check if prefs::kArcCompatibleFilesy
kinaba
2017/04/04 04:13:56
Profile is not created at this point, so it is dif
xiyuan
2017/04/04 15:32:21
Right. Overlooked that.
| |
| 993 base::TaskTraits() | |
| 994 .WithShutdownBehavior( | |
| 995 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | |
| 996 .WithPriority(base::TaskPriority::USER_BLOCKING) | |
| 997 .MayBlock(), | |
| 998 base::Bind(&arc::IsArcCompatibleFilesystem, profile_path), | |
| 999 base::Bind(&UserSessionManager::PrepareProfileAfterFilesystemCheck, | |
| 1000 AsWeakPtr())); | |
| 1001 } | |
| 1002 | |
| 1003 void UserSessionManager::PrepareProfileAfterFilesystemCheck( | |
| 1004 bool arc_compatible_filesystem) { | |
| 988 const bool is_demo_session = | 1005 const bool is_demo_session = |
| 989 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); | 1006 DemoAppLauncher::IsDemoAppSession(user_context_.GetAccountId()); |
| 990 | 1007 |
| 991 // TODO(nkostylev): Figure out whether demo session is using the right profile | 1008 // TODO(nkostylev): Figure out whether demo session is using the right profile |
| 992 // path or not. See https://codereview.chromium.org/171423009 | 1009 // path or not. See https://codereview.chromium.org/171423009 |
| 993 g_browser_process->profile_manager()->CreateProfileAsync( | 1010 g_browser_process->profile_manager()->CreateProfileAsync( |
| 994 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), | 1011 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), |
| 995 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), | 1012 base::Bind(&UserSessionManager::OnProfileCreated, AsWeakPtr(), |
| 996 user_context_, is_demo_session), | 1013 user_context_, is_demo_session, arc_compatible_filesystem), |
| 997 base::string16(), std::string(), std::string()); | 1014 base::string16(), std::string(), std::string()); |
| 998 } | 1015 } |
| 999 | 1016 |
| 1000 void UserSessionManager::OnProfileCreated(const UserContext& user_context, | 1017 void UserSessionManager::OnProfileCreated(const UserContext& user_context, |
| 1001 bool is_incognito_profile, | 1018 bool is_incognito_profile, |
| 1019 bool arc_compatible_filesystem, | |
| 1002 Profile* profile, | 1020 Profile* profile, |
| 1003 Profile::CreateStatus status) { | 1021 Profile::CreateStatus status) { |
| 1004 CHECK(profile); | 1022 CHECK(profile); |
| 1005 | 1023 |
| 1006 switch (status) { | 1024 switch (status) { |
| 1007 case Profile::CREATE_STATUS_CREATED: | 1025 case Profile::CREATE_STATUS_CREATED: |
| 1008 // Profile created but before initializing extensions and promo resources. | 1026 // Profile created but before initializing extensions and promo resources. |
| 1009 InitProfilePreferences(profile, user_context); | 1027 InitProfilePreferences(profile, user_context, arc_compatible_filesystem); |
| 1010 break; | 1028 break; |
| 1011 case Profile::CREATE_STATUS_INITIALIZED: | 1029 case Profile::CREATE_STATUS_INITIALIZED: |
| 1012 // Profile is created, extensions and promo resources are initialized. | 1030 // Profile is created, extensions and promo resources are initialized. |
| 1013 // At this point all other Chrome OS services will be notified that it is | 1031 // At this point all other Chrome OS services will be notified that it is |
| 1014 // safe to use this profile. | 1032 // safe to use this profile. |
| 1015 UserProfileInitialized(profile, is_incognito_profile, | 1033 UserProfileInitialized(profile, is_incognito_profile, |
| 1016 user_context.GetAccountId()); | 1034 user_context.GetAccountId()); |
| 1017 break; | 1035 break; |
| 1018 case Profile::CREATE_STATUS_LOCAL_FAIL: | 1036 case Profile::CREATE_STATUS_LOCAL_FAIL: |
| 1019 case Profile::CREATE_STATUS_REMOTE_FAIL: | 1037 case Profile::CREATE_STATUS_REMOTE_FAIL: |
| 1020 case Profile::CREATE_STATUS_CANCELED: | 1038 case Profile::CREATE_STATUS_CANCELED: |
| 1021 case Profile::MAX_CREATE_STATUS: | 1039 case Profile::MAX_CREATE_STATUS: |
| 1022 NOTREACHED(); | 1040 NOTREACHED(); |
| 1023 break; | 1041 break; |
| 1024 } | 1042 } |
| 1025 } | 1043 } |
| 1026 | 1044 |
| 1027 void UserSessionManager::InitProfilePreferences( | 1045 void UserSessionManager::InitProfilePreferences( |
| 1028 Profile* profile, | 1046 Profile* profile, |
| 1029 const UserContext& user_context) { | 1047 const UserContext& user_context, |
| 1048 bool arc_compatible_filesystem) { | |
| 1049 profile->GetPrefs()->SetBoolean(prefs::kArcCompatibleFilesystemChosen, | |
| 1050 arc_compatible_filesystem); | |
| 1051 | |
| 1030 const user_manager::User* user = | 1052 const user_manager::User* user = |
| 1031 ProfileHelper::Get()->GetUserByProfile(profile); | 1053 ProfileHelper::Get()->GetUserByProfile(profile); |
| 1032 if (user->GetType() == user_manager::USER_TYPE_KIOSK_APP && | 1054 if (user->GetType() == user_manager::USER_TYPE_KIOSK_APP && |
| 1033 profile->IsNewProfile()) { | 1055 profile->IsNewProfile()) { |
| 1034 ChromeUserManager::Get()->SetIsCurrentUserNew(true); | 1056 ChromeUserManager::Get()->SetIsCurrentUserNew(true); |
| 1035 } | 1057 } |
| 1036 | 1058 |
| 1037 if (user->is_active()) { | 1059 if (user->is_active()) { |
| 1038 input_method::InputMethodManager* manager = | 1060 input_method::InputMethodManager* manager = |
| 1039 input_method::InputMethodManager::Get(); | 1061 input_method::InputMethodManager::Get(); |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1947 ->browser_policy_connector_chromeos() | 1969 ->browser_policy_connector_chromeos() |
| 1948 ->IsEnterpriseManaged()) { | 1970 ->IsEnterpriseManaged()) { |
| 1949 return false; | 1971 return false; |
| 1950 } | 1972 } |
| 1951 | 1973 |
| 1952 // Do not show end of life notification if this is a guest session | 1974 // Do not show end of life notification if this is a guest session |
| 1953 return !profile->IsGuestSession(); | 1975 return !profile->IsGuestSession(); |
| 1954 } | 1976 } |
| 1955 | 1977 |
| 1956 } // namespace chromeos | 1978 } // namespace chromeos |
| OLD | NEW |