OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 // since it may refer to profile that has been in use in previous session. | 626 // since it may refer to profile that has been in use in previous session. |
627 // That profile dir may not be mounted in this session so instead return | 627 // That profile dir may not be mounted in this session so instead return |
628 // active profile from current session. | 628 // active profile from current session. |
629 profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir(); | 629 profile_dir = chromeos::ProfileHelper::Get()->GetActiveUserProfileDir(); |
630 | 630 |
631 base::FilePath profile_path(user_data_dir); | 631 base::FilePath profile_path(user_data_dir); |
632 Profile* profile = GetProfileByPath(profile_path.Append(profile_dir)); | 632 Profile* profile = GetProfileByPath(profile_path.Append(profile_dir)); |
633 // If we get here, it means the user has logged in but the profile has not | 633 // If we get here, it means the user has logged in but the profile has not |
634 // finished initializing, so treat the user as not having logged in. | 634 // finished initializing, so treat the user as not having logged in. |
635 if (!profile) { | 635 if (!profile) { |
636 DLOG(WARNING) << "Calling GetLastUsedProfile() before profile " | 636 LOG(WARNING) << "Calling GetLastUsedProfile() before profile " |
637 << "initialization is completed. Returning login profile."; | 637 << "initialization is completed. Returning login profile."; |
638 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir); | 638 return GetActiveUserOrOffTheRecordProfileFromPath(user_data_dir); |
emaxx
2017/06/06 12:11:23
Not insisting (I'm not aware of the general guidel
xiyuan
2017/06/06 20:29:39
I will fix the offending code and change this to a
| |
639 } | 639 } |
640 return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : | 640 return profile->IsGuestSession() ? profile->GetOffTheRecordProfile() : |
641 profile; | 641 profile; |
642 } | 642 } |
643 #else | 643 #else |
644 | 644 |
645 return GetProfile(GetLastUsedProfileDir(user_data_dir)); | 645 return GetProfile(GetLastUsedProfileDir(user_data_dir)); |
646 #endif | 646 #endif |
647 } | 647 } |
648 | 648 |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1319 // For cros, return the OTR profile so we never accidentally keep | 1319 // For cros, return the OTR profile so we never accidentally keep |
1320 // user data in an unencrypted profile. But doing this makes | 1320 // user data in an unencrypted profile. But doing this makes |
1321 // many of the browser and ui tests fail. We do return the OTR profile | 1321 // many of the browser and ui tests fail. We do return the OTR profile |
1322 // if the login-profile switch is passed so that we can test this. | 1322 // if the login-profile switch is passed so that we can test this. |
1323 if (ShouldGoOffTheRecord(profile)) | 1323 if (ShouldGoOffTheRecord(profile)) |
1324 return profile->GetOffTheRecordProfile(); | 1324 return profile->GetOffTheRecordProfile(); |
1325 DCHECK(!user_manager::UserManager::Get()->IsLoggedInAsGuest()); | 1325 DCHECK(!user_manager::UserManager::Get()->IsLoggedInAsGuest()); |
1326 return profile; | 1326 return profile; |
1327 } | 1327 } |
1328 | 1328 |
1329 // Only allow user profile loading on browser restart, where kLoginUser | |
1330 // switch is present in the command line. For all other cases, the user | |
1331 // profile loading should be from UserSessionManager. | |
1332 const bool allow_user_profile_loading = | |
emaxx
2017/06/06 12:11:23
I'm a bit unhappy with keeping the lazy profile lo
xiyuan
2017/06/06 20:29:39
Added ProfileManager::CreateInitialProfile() and u
| |
1333 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1334 chromeos::switches::kLoginUser); | |
1335 | |
1329 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); | 1336 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); |
1330 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); | 1337 ProfileInfo* profile_info = GetProfileInfoByPath(default_profile_dir); |
1331 // Fallback to default off-the-record profile, if user profile has not fully | 1338 // Fallback to default off-the-record profile, if user profile is not loaded |
1332 // loaded yet. | 1339 // and should not be loaded or has not fully loaded yet. |
1333 if (profile_info && !profile_info->created) | 1340 if ((!allow_user_profile_loading && !profile_info) || |
1341 (profile_info && !profile_info->created)) { | |
1334 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); | 1342 default_profile_dir = profiles::GetDefaultProfileDir(user_data_dir); |
1343 } | |
1335 | 1344 |
1336 Profile* profile = GetProfile(default_profile_dir); | 1345 Profile* profile = GetProfile(default_profile_dir); |
1337 // Some unit tests didn't initialize the UserManager. | 1346 // Some unit tests didn't initialize the UserManager. |
1338 if (user_manager::UserManager::IsInitialized() && | 1347 if (user_manager::UserManager::IsInitialized() && |
1339 user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 1348 user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
1340 return profile->GetOffTheRecordProfile(); | 1349 return profile->GetOffTheRecordProfile(); |
1341 return profile; | 1350 return profile; |
1342 #else | 1351 #else |
1343 base::FilePath default_profile_dir(user_data_dir); | 1352 base::FilePath default_profile_dir(user_data_dir); |
1344 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); | 1353 default_profile_dir = default_profile_dir.Append(GetInitialProfileDir()); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1781 | 1790 |
1782 const base::FilePath new_active_profile_dir = | 1791 const base::FilePath new_active_profile_dir = |
1783 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); | 1792 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); |
1784 FinishDeletingProfile(profile_dir, new_active_profile_dir); | 1793 FinishDeletingProfile(profile_dir, new_active_profile_dir); |
1785 } | 1794 } |
1786 #endif // !defined(OS_ANDROID) | 1795 #endif // !defined(OS_ANDROID) |
1787 | 1796 |
1788 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1797 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1789 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1798 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1790 } | 1799 } |
OLD | NEW |