| 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 <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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 if (cur_path != profile_dir && | 681 if (cur_path != profile_dir && |
| 682 !cache.ProfileIsLegacySupervisedAtIndex(i) && | 682 !cache.ProfileIsLegacySupervisedAtIndex(i) && |
| 683 !IsProfileMarkedForDeletion(cur_path)) { | 683 !IsProfileMarkedForDeletion(cur_path)) { |
| 684 last_non_supervised_profile_path = cur_path; | 684 last_non_supervised_profile_path = cur_path; |
| 685 break; | 685 break; |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 | 688 |
| 689 base::FilePath new_path; | 689 base::FilePath new_path; |
| 690 if (last_non_supervised_profile_path.empty()) { | 690 if (last_non_supervised_profile_path.empty()) { |
| 691 // If we are using --new-avatar-menu, then assign the default | 691 base::string16 new_avatar_url = base::string16(); |
| 692 // placeholder avatar and name. Otherwise, use random ones. | 692 base::string16 new_profile_name = base::string16(); |
| 693 bool is_new_avatar_menu = switches::IsNewAvatarMenu(); | 693 |
| 694 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
| 694 int avatar_index = profiles::GetPlaceholderAvatarIndex(); | 695 int avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 695 base::string16 new_avatar_url = is_new_avatar_menu ? | 696 new_avatar_url = |
| 696 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index)) : | 697 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index)); |
| 697 base::string16(); | 698 new_profile_name = cache.ChooseNameForNewProfile(avatar_index); |
| 698 base::string16 new_profile_name = is_new_avatar_menu ? | 699 #endif |
| 699 cache.ChooseNameForNewProfile(avatar_index) : base::string16(); | |
| 700 | 700 |
| 701 new_path = GenerateNextProfileDirectoryPath(); | 701 new_path = GenerateNextProfileDirectoryPath(); |
| 702 CreateProfileAsync(new_path, | 702 CreateProfileAsync(new_path, |
| 703 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, | 703 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, |
| 704 base::Unretained(this), | 704 base::Unretained(this), |
| 705 profile_dir, | 705 profile_dir, |
| 706 new_path, | 706 new_path, |
| 707 callback), | 707 callback), |
| 708 new_profile_name, | 708 new_profile_name, |
| 709 new_avatar_url, | 709 new_avatar_url, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 // If the cache has an entry for this profile, use the cache data. | 816 // If the cache has an entry for this profile, use the cache data. |
| 817 if (profile_cache_index != std::string::npos) { | 817 if (profile_cache_index != std::string::npos) { |
| 818 avatar_index = | 818 avatar_index = |
| 819 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); | 819 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); |
| 820 profile_name = | 820 profile_name = |
| 821 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); | 821 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); |
| 822 supervised_user_id = | 822 supervised_user_id = |
| 823 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index); | 823 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index); |
| 824 } else if (profile->GetPath() == | 824 } else if (profile->GetPath() == |
| 825 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) { | 825 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) { |
| 826 // The --new-avatar-menu flag no longer uses the "First User" name. | |
| 827 bool is_new_avatar_menu = switches::IsNewAvatarMenu(); | |
| 828 avatar_index = profiles::GetPlaceholderAvatarIndex(); | 826 avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 829 profile_name = is_new_avatar_menu ? | 827 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) |
| 830 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) : | 828 profile_name = |
| 831 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); | 829 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); |
| 830 #else |
| 831 profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); |
| 832 #endif |
| 832 } else { | 833 } else { |
| 833 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); | 834 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); |
| 834 profile_name = | 835 profile_name = |
| 835 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); | 836 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); |
| 836 } | 837 } |
| 837 } | 838 } |
| 838 | 839 |
| 839 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) | 840 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) |
| 840 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); | 841 profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, avatar_index); |
| 841 | 842 |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 } | 1488 } |
| 1488 | 1489 |
| 1489 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1490 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
| 1490 if (!original_callback.is_null()) | 1491 if (!original_callback.is_null()) |
| 1491 original_callback.Run(loaded_profile, status); | 1492 original_callback.Run(loaded_profile, status); |
| 1492 } | 1493 } |
| 1493 | 1494 |
| 1494 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1495 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
| 1495 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1496 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
| 1496 } | 1497 } |
| OLD | NEW |