Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 316863002: Rename "managed (mode|user)" to "supervised user" (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 size_t ProfileManager::GetNumberOfProfiles() { 366 size_t ProfileManager::GetNumberOfProfiles() {
367 return GetProfileInfoCache().GetNumberOfProfiles(); 367 return GetProfileInfoCache().GetNumberOfProfiles();
368 } 368 }
369 369
370 void ProfileManager::CreateProfileAsync( 370 void ProfileManager::CreateProfileAsync(
371 const base::FilePath& profile_path, 371 const base::FilePath& profile_path,
372 const CreateCallback& callback, 372 const CreateCallback& callback,
373 const base::string16& name, 373 const base::string16& name,
374 const base::string16& icon_url, 374 const base::string16& icon_url,
375 const std::string& managed_user_id) { 375 const std::string& supervised_user_id) {
376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
377 377
378 // Make sure that this profile is not pending deletion. 378 // Make sure that this profile is not pending deletion.
379 if (IsProfileMarkedForDeletion(profile_path)) { 379 if (IsProfileMarkedForDeletion(profile_path)) {
380 if (!callback.is_null()) 380 if (!callback.is_null())
381 callback.Run(NULL, Profile::CREATE_STATUS_LOCAL_FAIL); 381 callback.Run(NULL, Profile::CREATE_STATUS_LOCAL_FAIL);
382 return; 382 return;
383 } 383 }
384 384
385 // Create the profile if needed and collect its ProfileInfo. 385 // Create the profile if needed and collect its ProfileInfo.
386 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path); 386 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path);
387 ProfileInfo* info = NULL; 387 ProfileInfo* info = NULL;
388 388
389 if (iter != profiles_info_.end()) { 389 if (iter != profiles_info_.end()) {
390 info = iter->second.get(); 390 info = iter->second.get();
391 } else { 391 } else {
392 // Initiate asynchronous creation process. 392 // Initiate asynchronous creation process.
393 info = RegisterProfile(CreateProfileAsyncHelper(profile_path, this), false); 393 info = RegisterProfile(CreateProfileAsyncHelper(profile_path, this), false);
394 ProfileInfoCache& cache = GetProfileInfoCache(); 394 ProfileInfoCache& cache = GetProfileInfoCache();
395 // Get the icon index from the user's icon url 395 // Get the icon index from the user's icon url
396 size_t icon_index; 396 size_t icon_index;
397 std::string icon_url_std = base::UTF16ToASCII(icon_url); 397 std::string icon_url_std = base::UTF16ToASCII(icon_url);
398 if (profiles::IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) { 398 if (profiles::IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) {
399 // add profile to cache with user selected name and avatar 399 // add profile to cache with user selected name and avatar
400 cache.AddProfileToCache(profile_path, name, base::string16(), icon_index, 400 cache.AddProfileToCache(profile_path, name, base::string16(), icon_index,
401 managed_user_id); 401 supervised_user_id);
402 } 402 }
403 403
404 if (!managed_user_id.empty()) { 404 if (!supervised_user_id.empty()) {
405 content::RecordAction( 405 content::RecordAction(
406 UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); 406 UserMetricsAction("ManagedMode_LocallyManagedUserCreated"));
407 } 407 }
408 408
409 ProfileMetrics::UpdateReportedProfilesStatistics(this); 409 ProfileMetrics::UpdateReportedProfilesStatistics(this);
410 } 410 }
411 411
412 // Call or enqueue the callback. 412 // Call or enqueue the callback.
413 if (!callback.is_null()) { 413 if (!callback.is_null()) {
414 if (iter != profiles_info_.end() && info->created) { 414 if (iter != profiles_info_.end() && info->created) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const { 554 Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const {
555 ProfileInfo* profile_info = GetProfileInfoByPath(path); 555 ProfileInfo* profile_info = GetProfileInfoByPath(path);
556 return profile_info ? profile_info->profile.get() : NULL; 556 return profile_info ? profile_info->profile.get() : NULL;
557 } 557 }
558 558
559 // static 559 // static
560 base::FilePath ProfileManager::CreateMultiProfileAsync( 560 base::FilePath ProfileManager::CreateMultiProfileAsync(
561 const base::string16& name, 561 const base::string16& name,
562 const base::string16& icon_url, 562 const base::string16& icon_url,
563 const CreateCallback& callback, 563 const CreateCallback& callback,
564 const std::string& managed_user_id) { 564 const std::string& supervised_user_id) {
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
566 566
567 ProfileManager* profile_manager = g_browser_process->profile_manager(); 567 ProfileManager* profile_manager = g_browser_process->profile_manager();
568 568
569 base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath(); 569 base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath();
570 570
571 profile_manager->CreateProfileAsync(new_path, 571 profile_manager->CreateProfileAsync(new_path,
572 callback, 572 callback,
573 name, 573 name,
574 icon_url, 574 icon_url,
575 managed_user_id); 575 supervised_user_id);
576 return new_path; 576 return new_path;
577 } 577 }
578 578
579 // static 579 // static
580 base::FilePath ProfileManager::GetGuestProfilePath() { 580 base::FilePath ProfileManager::GetGuestProfilePath() {
581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
582 582
583 ProfileManager* profile_manager = g_browser_process->profile_manager(); 583 ProfileManager* profile_manager = g_browser_process->profile_manager();
584 584
585 base::FilePath guest_path = profile_manager->user_data_dir(); 585 base::FilePath guest_path = profile_manager->user_data_dir();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 service->CancelDownloads(); 633 service->CancelDownloads();
634 } 634 }
635 635
636 PrefService* local_state = g_browser_process->local_state(); 636 PrefService* local_state = g_browser_process->local_state();
637 ProfileInfoCache& cache = GetProfileInfoCache(); 637 ProfileInfoCache& cache = GetProfileInfoCache();
638 638
639 if (profile_dir.BaseName().MaybeAsASCII() == 639 if (profile_dir.BaseName().MaybeAsASCII() ==
640 local_state->GetString(prefs::kProfileLastUsed)) { 640 local_state->GetString(prefs::kProfileLastUsed)) {
641 // Update the last used profile pref before closing browser windows. This 641 // Update the last used profile pref before closing browser windows. This
642 // way the correct last used profile is set for any notification observers. 642 // way the correct last used profile is set for any notification observers.
643 base::FilePath last_non_managed_profile_path; 643 base::FilePath last_non_supervised_profile_path;
644 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { 644 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
645 base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i); 645 base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i);
646 // Make sure that this profile is not pending deletion. 646 // Make sure that this profile is not pending deletion.
647 if (cur_path != profile_dir && !cache.ProfileIsManagedAtIndex(i) && 647 if (cur_path != profile_dir && !cache.ProfileIsSupervisedAtIndex(i) &&
648 !IsProfileMarkedForDeletion(cur_path)) { 648 !IsProfileMarkedForDeletion(cur_path)) {
649 last_non_managed_profile_path = cur_path; 649 last_non_supervised_profile_path = cur_path;
650 break; 650 break;
651 } 651 }
652 } 652 }
653 653
654 // If we're deleting the last (non-managed) profile, then create a new 654 // If we're deleting the last (non-supervised) profile, then create a new
655 // profile in its place. 655 // profile in its place.
656 const std::string last_non_managed_profile = 656 const std::string last_non_supervised_profile =
657 last_non_managed_profile_path.BaseName().MaybeAsASCII(); 657 last_non_supervised_profile_path.BaseName().MaybeAsASCII();
658 if (last_non_managed_profile.empty()) { 658 if (last_non_supervised_profile.empty()) {
659 base::FilePath new_path = GenerateNextProfileDirectoryPath(); 659 base::FilePath new_path = GenerateNextProfileDirectoryPath();
660 // Make sure the last used profile path is pointing at it. This way the 660 // Make sure the last used profile path is pointing at it. This way the
661 // correct last used profile is set for any notification observers. 661 // correct last used profile is set for any notification observers.
662 local_state->SetString(prefs::kProfileLastUsed, 662 local_state->SetString(prefs::kProfileLastUsed,
663 new_path.BaseName().MaybeAsASCII()); 663 new_path.BaseName().MaybeAsASCII());
664 CreateProfileAsync(new_path, 664 CreateProfileAsync(new_path,
665 callback, 665 callback,
666 base::string16(), 666 base::string16(),
667 base::string16(), 667 base::string16(),
668 std::string()); 668 std::string());
669 } else { 669 } else {
670 // On the Mac, the browser process is not killed when all browser windows 670 // On the Mac, the browser process is not killed when all browser windows
671 // are closed, so just in case we are deleting the active profile, and no 671 // are closed, so just in case we are deleting the active profile, and no
672 // other profile has been loaded, we must pre-load a next one. 672 // other profile has been loaded, we must pre-load a next one.
673 #if defined(OS_MACOSX) 673 #if defined(OS_MACOSX)
674 CreateProfileAsync(last_non_managed_profile_path, 674 CreateProfileAsync(last_non_supervised_profile_path,
675 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, 675 base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
676 base::Unretained(this), 676 base::Unretained(this),
677 profile_dir, 677 profile_dir,
678 last_non_managed_profile_path, 678 last_non_supervised_profile_path,
679 callback), 679 callback),
680 base::string16(), 680 base::string16(),
681 base::string16(), 681 base::string16(),
682 std::string()); 682 std::string());
683 return; 683 return;
684 #else 684 #else
685 // For OS_MACOSX the pref is updated in the callback to make sure that 685 // For OS_MACOSX the pref is updated in the callback to make sure that
686 // it isn't used before the profile is actually loaded. 686 // it isn't used before the profile is actually loaded.
687 local_state->SetString(prefs::kProfileLastUsed, last_non_managed_profile); 687 local_state->SetString(prefs::kProfileLastUsed,
688 last_non_supervised_profile);
688 #endif 689 #endif
689 } 690 }
690 } 691 }
691 FinishDeletingProfile(profile_dir); 692 FinishDeletingProfile(profile_dir);
692 } 693 }
693 694
694 // static 695 // static
695 void ProfileManager::CleanUpStaleProfiles( 696 void ProfileManager::CleanUpStaleProfiles(
696 const std::vector<base::FilePath>& profile_paths) { 697 const std::vector<base::FilePath>& profile_paths) {
697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 698 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 26 matching lines...) Expand all
724 } 725 }
725 726
726 void ProfileManager::InitProfileUserPrefs(Profile* profile) { 727 void ProfileManager::InitProfileUserPrefs(Profile* profile) {
727 ProfileInfoCache& cache = GetProfileInfoCache(); 728 ProfileInfoCache& cache = GetProfileInfoCache();
728 729
729 if (profile->GetPath().DirName() != cache.GetUserDataDir()) 730 if (profile->GetPath().DirName() != cache.GetUserDataDir())
730 return; 731 return;
731 732
732 size_t avatar_index; 733 size_t avatar_index;
733 std::string profile_name; 734 std::string profile_name;
734 std::string managed_user_id; 735 std::string supervised_user_id;
735 if (profile->IsGuestSession()) { 736 if (profile->IsGuestSession()) {
736 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME); 737 profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME);
737 avatar_index = 0; 738 avatar_index = 0;
738 } else { 739 } else {
739 size_t profile_cache_index = 740 size_t profile_cache_index =
740 cache.GetIndexOfProfileWithPath(profile->GetPath()); 741 cache.GetIndexOfProfileWithPath(profile->GetPath());
741 // If the cache has an entry for this profile, use the cache data. 742 // If the cache has an entry for this profile, use the cache data.
742 if (profile_cache_index != std::string::npos) { 743 if (profile_cache_index != std::string::npos) {
743 avatar_index = 744 avatar_index =
744 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); 745 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index);
745 profile_name = 746 profile_name =
746 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); 747 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index));
747 managed_user_id = 748 supervised_user_id =
748 cache.GetManagedUserIdOfProfileAtIndex(profile_cache_index); 749 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index);
749 } else if (profile->GetPath() == 750 } else if (profile->GetPath() ==
750 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) { 751 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
751 avatar_index = 0; 752 avatar_index = 0;
752 // The --new-profile-management flag no longer uses the "First User" name. 753 // The --new-profile-management flag no longer uses the "First User" name.
753 profile_name = switches::IsNewProfileManagement() ? 754 profile_name = switches::IsNewProfileManagement() ?
754 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) : 755 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) :
755 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); 756 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
756 } else { 757 } else {
757 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); 758 avatar_index = cache.ChooseAvatarIconIndexForNewProfile();
758 profile_name = 759 profile_name =
759 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); 760 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index));
760 } 761 }
761 } 762 }
762 763
763 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) 764 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex))
764 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); 765 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index);
765 766
766 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName)) 767 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileName))
767 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name); 768 profile->GetPrefs()->SetString(prefs::kProfileName, profile_name);
768 769
769 CommandLine* command_line = CommandLine::ForCurrentProcess(); 770 CommandLine* command_line = CommandLine::ForCurrentProcess();
770 bool force_managed_user_id = 771 bool force_supervised_user_id =
771 command_line->HasSwitch(switches::kManagedUserId); 772 command_line->HasSwitch(switches::kSupervisedUserId);
772 if (force_managed_user_id) { 773 if (force_supervised_user_id) {
773 managed_user_id = 774 supervised_user_id =
774 command_line->GetSwitchValueASCII(switches::kManagedUserId); 775 command_line->GetSwitchValueASCII(switches::kSupervisedUserId);
775 } 776 }
776 if (force_managed_user_id || 777 if (force_supervised_user_id ||
777 !profile->GetPrefs()->HasPrefPath(prefs::kManagedUserId)) { 778 !profile->GetPrefs()->HasPrefPath(prefs::kSupervisedUserId)) {
778 profile->GetPrefs()->SetString(prefs::kManagedUserId, managed_user_id); 779 profile->GetPrefs()->SetString(prefs::kSupervisedUserId,
780 supervised_user_id);
779 } 781 }
780 } 782 }
781 783
782 void ProfileManager::RegisterTestingProfile(Profile* profile, 784 void ProfileManager::RegisterTestingProfile(Profile* profile,
783 bool add_to_cache, 785 bool add_to_cache,
784 bool start_deferred_task_runners) { 786 bool start_deferred_task_runners) {
785 RegisterProfile(profile, true); 787 RegisterProfile(profile, true);
786 if (add_to_cache) { 788 if (add_to_cache) {
787 InitProfileUserPrefs(profile); 789 InitProfileUserPrefs(profile);
788 AddProfileToCache(profile); 790 AddProfileToCache(profile);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 // During tests, when |profile| is an instance of TestingProfile, 969 // During tests, when |profile| is an instance of TestingProfile,
968 // ExtensionSystem might not create an ExtensionService. 970 // ExtensionSystem might not create an ExtensionService.
969 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { 971 if (extensions::ExtensionSystem::Get(profile)->extension_service()) {
970 profile->GetHostContentSettingsMap()->RegisterExtensionService( 972 profile->GetHostContentSettingsMap()->RegisterExtensionService(
971 extensions::ExtensionSystem::Get(profile)->extension_service()); 973 extensions::ExtensionSystem::Get(profile)->extension_service());
972 } 974 }
973 #endif 975 #endif
974 #if defined(ENABLE_MANAGED_USERS) 976 #if defined(ENABLE_MANAGED_USERS)
975 // Initialization needs to happen after extension system initialization (for 977 // Initialization needs to happen after extension system initialization (for
976 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the 978 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the
977 // initializing the managed flag if necessary). 979 // initializing the supervised flag if necessary).
978 ManagedUserServiceFactory::GetForProfile(profile)->Init(); 980 ManagedUserServiceFactory::GetForProfile(profile)->Init();
979 #endif 981 #endif
980 // Start the deferred task runners once the profile is loaded. 982 // Start the deferred task runners once the profile is loaded.
981 StartupTaskRunnerServiceFactory::GetForProfile(profile)-> 983 StartupTaskRunnerServiceFactory::GetForProfile(profile)->
982 StartDeferredTaskRunners(); 984 StartDeferredTaskRunners();
983 985
984 AccountReconcilorFactory::GetForProfile(profile); 986 AccountReconcilorFactory::GetForProfile(profile);
985 } 987 }
986 988
987 void ProfileManager::DoFinalInitLogging(Profile* profile) { 989 void ProfileManager::DoFinalInitLogging(Profile* profile) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 prefs::kGoogleServicesUsername)); 1128 prefs::kGoogleServicesUsername));
1127 1129
1128 // Profile name and avatar are set by InitProfileUserPrefs and stored in the 1130 // Profile name and avatar are set by InitProfileUserPrefs and stored in the
1129 // profile. Use those values to setup the cache entry. 1131 // profile. Use those values to setup the cache entry.
1130 base::string16 profile_name = 1132 base::string16 profile_name =
1131 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); 1133 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName));
1132 1134
1133 size_t icon_index = profile->GetPrefs()->GetInteger( 1135 size_t icon_index = profile->GetPrefs()->GetInteger(
1134 prefs::kProfileAvatarIndex); 1136 prefs::kProfileAvatarIndex);
1135 1137
1136 std::string managed_user_id = 1138 std::string supervised_user_id =
1137 profile->GetPrefs()->GetString(prefs::kManagedUserId); 1139 profile->GetPrefs()->GetString(prefs::kSupervisedUserId);
1138 1140
1139 cache.AddProfileToCache(profile->GetPath(), 1141 cache.AddProfileToCache(profile->GetPath(),
1140 profile_name, 1142 profile_name,
1141 username, 1143 username,
1142 icon_index, 1144 icon_index,
1143 managed_user_id); 1145 supervised_user_id);
1144 1146
1145 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) { 1147 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) {
1146 cache.SetProfileIsEphemeralAtIndex( 1148 cache.SetProfileIsEphemeralAtIndex(
1147 cache.GetIndexOfProfileWithPath(profile->GetPath()), true); 1149 cache.GetIndexOfProfileWithPath(profile->GetPath()), true);
1148 } 1150 }
1149 } 1151 }
1150 1152
1151 void ProfileManager::SetGuestProfilePrefs(Profile* profile) { 1153 void ProfileManager::SetGuestProfilePrefs(Profile* profile) {
1152 PrefService* prefs = profile->GetPrefs(); 1154 PrefService* prefs = profile->GetPrefs();
1153 prefs->SetBoolean(prefs::kSigninAllowed, false); 1155 prefs->SetBoolean(prefs::kSigninAllowed, false);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 cache.GetIndexOfProfileWithPath(last_active->GetPath()); 1253 cache.GetIndexOfProfileWithPath(last_active->GetPath());
1252 if (profile_index != std::string::npos) 1254 if (profile_index != std::string::npos)
1253 cache.SetProfileActiveTimeAtIndex(profile_index); 1255 cache.SetProfileActiveTimeAtIndex(profile_index);
1254 } 1256 }
1255 } 1257 }
1256 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 1258 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
1257 1259
1258 #if defined(OS_MACOSX) 1260 #if defined(OS_MACOSX)
1259 void ProfileManager::OnNewActiveProfileLoaded( 1261 void ProfileManager::OnNewActiveProfileLoaded(
1260 const base::FilePath& profile_to_delete_path, 1262 const base::FilePath& profile_to_delete_path,
1261 const base::FilePath& last_non_managed_profile_path, 1263 const base::FilePath& last_non_supervised_profile_path,
1262 const CreateCallback& original_callback, 1264 const CreateCallback& original_callback,
1263 Profile* loaded_profile, 1265 Profile* loaded_profile,
1264 Profile::CreateStatus status) { 1266 Profile::CreateStatus status) {
1265 DCHECK(status != Profile::CREATE_STATUS_LOCAL_FAIL && 1267 DCHECK(status != Profile::CREATE_STATUS_LOCAL_FAIL &&
1266 status != Profile::CREATE_STATUS_REMOTE_FAIL); 1268 status != Profile::CREATE_STATUS_REMOTE_FAIL);
1267 1269
1268 // Only run the code if the profile initialization has finished completely. 1270 // Only run the code if the profile initialization has finished completely.
1269 if (status == Profile::CREATE_STATUS_INITIALIZED) { 1271 if (status == Profile::CREATE_STATUS_INITIALIZED) {
1270 if (IsProfileMarkedForDeletion(last_non_managed_profile_path)) { 1272 if (IsProfileMarkedForDeletion(last_non_supervised_profile_path)) {
1271 // If the profile we tried to load as the next active profile has been 1273 // If the profile we tried to load as the next active profile has been
1272 // deleted, then retry deleting this profile to redo the logic to load 1274 // deleted, then retry deleting this profile to redo the logic to load
1273 // the next available profile. 1275 // the next available profile.
1274 ScheduleProfileForDeletion(profile_to_delete_path, original_callback); 1276 ScheduleProfileForDeletion(profile_to_delete_path, original_callback);
1275 } else { 1277 } else {
1276 // Update the local state as promised in the ScheduleProfileForDeletion. 1278 // Update the local state as promised in the ScheduleProfileForDeletion.
1277 g_browser_process->local_state()->SetString( 1279 g_browser_process->local_state()->SetString(
1278 prefs::kProfileLastUsed, 1280 prefs::kProfileLastUsed,
1279 last_non_managed_profile_path.BaseName().MaybeAsASCII()); 1281 last_non_supervised_profile_path.BaseName().MaybeAsASCII());
1280 FinishDeletingProfile(profile_to_delete_path); 1282 FinishDeletingProfile(profile_to_delete_path);
1281 } 1283 }
1282 } 1284 }
1283 } 1285 }
1284 #endif 1286 #endif
1285 1287
1286 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1288 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1287 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1289 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1288 } 1290 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.h ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698