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

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

Issue 392313002: [Profiles] With new-profile-management all new profiles should have default avatars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 // If we're deleting the last (non-supervised) profile, then create a new 668 // If we're deleting the last (non-supervised) profile, then create a new
669 // profile in its place. 669 // profile in its place.
670 const std::string last_non_supervised_profile = 670 const std::string last_non_supervised_profile =
671 last_non_supervised_profile_path.BaseName().MaybeAsASCII(); 671 last_non_supervised_profile_path.BaseName().MaybeAsASCII();
672 if (last_non_supervised_profile.empty()) { 672 if (last_non_supervised_profile.empty()) {
673 base::FilePath new_path = GenerateNextProfileDirectoryPath(); 673 base::FilePath new_path = GenerateNextProfileDirectoryPath();
674 // Make sure the last used profile path is pointing at it. This way the 674 // Make sure the last used profile path is pointing at it. This way the
675 // correct last used profile is set for any notification observers. 675 // correct last used profile is set for any notification observers.
676 local_state->SetString(prefs::kProfileLastUsed, 676 local_state->SetString(prefs::kProfileLastUsed,
677 new_path.BaseName().MaybeAsASCII()); 677 new_path.BaseName().MaybeAsASCII());
678
679 // If we are using --new-profile-management, then assign the default
680 // placeholder avatar and name. Otherwise, use random ones.
681 bool is_new_profile_management = switches::IsNewProfileManagement();
682 int avatar_index = profiles::GetPlaceholderAvatarIndex();
683 base::string16 new_avatar_url = is_new_profile_management ?
684 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index)) :
685 base::string16();
686 base::string16 new_profile_name = is_new_profile_management ?
687 cache.ChooseNameForNewProfile(avatar_index) : base::string16();
erg 2014/07/16 19:39:07 So, won't this always build new profiles with the
noms (inactive) 2014/07/16 19:41:22 Yup. But this is only runs if you're deleting the
688
678 CreateProfileAsync(new_path, 689 CreateProfileAsync(new_path,
679 callback, 690 callback,
680 base::string16(), 691 new_profile_name,
681 base::string16(), 692 new_avatar_url,
682 std::string()); 693 std::string());
683 } else { 694 } else {
684 // On the Mac, the browser process is not killed when all browser windows 695 // On the Mac, the browser process is not killed when all browser windows
685 // are closed, so just in case we are deleting the active profile, and no 696 // are closed, so just in case we are deleting the active profile, and no
686 // other profile has been loaded, we must pre-load a next one. 697 // other profile has been loaded, we must pre-load a next one.
687 #if defined(OS_MACOSX) 698 #if defined(OS_MACOSX)
688 CreateProfileAsync(last_non_supervised_profile_path, 699 CreateProfileAsync(last_non_supervised_profile_path,
689 base::Bind(&ProfileManager::OnNewActiveProfileLoaded, 700 base::Bind(&ProfileManager::OnNewActiveProfileLoaded,
690 base::Unretained(this), 701 base::Unretained(this),
691 profile_dir, 702 profile_dir,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // If the cache has an entry for this profile, use the cache data. 767 // If the cache has an entry for this profile, use the cache data.
757 if (profile_cache_index != std::string::npos) { 768 if (profile_cache_index != std::string::npos) {
758 avatar_index = 769 avatar_index =
759 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index); 770 cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index);
760 profile_name = 771 profile_name =
761 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)); 772 base::UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index));
762 supervised_user_id = 773 supervised_user_id =
763 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index); 774 cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index);
764 } else if (profile->GetPath() == 775 } else if (profile->GetPath() ==
765 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) { 776 profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
766 avatar_index = 0; 777 // The --new-profile-management flag no longer uses the "First User"
767 // The --new-profile-management flag no longer uses the "First User" name. 778 // name, and should assign the default avatar icon to all new profiles.
768 profile_name = switches::IsNewProfileManagement() ? 779 bool is_new_profile_management = switches::IsNewProfileManagement();
780 avatar_index = is_new_profile_management ?
781 profiles::GetPlaceholderAvatarIndex() : 0;
782 profile_name = is_new_profile_management ?
769 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) : 783 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) :
770 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME); 784 l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
771 } else { 785 } else {
772 avatar_index = cache.ChooseAvatarIconIndexForNewProfile(); 786 avatar_index = cache.ChooseAvatarIconIndexForNewProfile();
773 profile_name = 787 profile_name =
774 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)); 788 base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index));
775 } 789 }
776 } 790 }
777 791
778 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex)) 792 if (!profile->GetPrefs()->HasPrefPath(prefs::kProfileAvatarIndex))
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); 1321 last_non_supervised_profile_path.BaseName().MaybeAsASCII());
1308 FinishDeletingProfile(profile_to_delete_path); 1322 FinishDeletingProfile(profile_to_delete_path);
1309 } 1323 }
1310 } 1324 }
1311 } 1325 }
1312 #endif 1326 #endif
1313 1327
1314 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1328 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1315 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1329 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1316 } 1330 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698