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

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 8815005: Lands http://codereview.chromium.org/8801034/ in hopes of getting a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index d4dee132245d4845efde5d766f573f5847918eba..1078a740c6bb10f6728d96211602239ccd957758 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -57,18 +57,6 @@ std::vector<FilePath>& ProfilesToDelete() {
return profiles_to_delete;
}
-// Checks if any user prefs for |profile| have default values.
-bool HasAnyDefaultUserPrefs(Profile* profile) {
- const PrefService::Preference* avatar_index =
- profile->GetPrefs()->FindPreference(prefs::kProfileAvatarIndex);
- DCHECK(avatar_index);
- const PrefService::Preference* profile_name =
- profile->GetPrefs()->FindPreference(prefs::kProfileName);
- DCHECK(profile_name);
- return avatar_index->IsDefaultValue() ||
- profile_name->IsDefaultValue();
-}
-
// Simple task to log the size of the current profile.
class ProfileSizeTask : public Task {
public:
@@ -481,7 +469,6 @@ void ProfileManager::OnBrowserSetLastActive(const Browser* browser) {
void ProfileManager::DoFinalInit(Profile* profile, bool go_off_the_record) {
DoFinalInitForServices(profile, go_off_the_record);
- InitProfileUserPrefs(profile);
AddProfileToCache(profile);
DoFinalInitLogging(profile);
}
@@ -633,49 +620,16 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
string16 username = UTF8ToUTF16(profile->GetPrefs()->GetString(
prefs::kGoogleServicesUsername));
- // Profile name and avatar are set by InitProfileUserPrefs and stored in the
- // profile. Use those values to setup the cache entry.
- string16 profile_name = UTF8ToUTF16(profile->GetPrefs()->GetString(
- prefs::kProfileName));
-
- size_t icon_index = profile->GetPrefs()->GetInteger(
- prefs::kProfileAvatarIndex);
-
- cache.AddProfileToCache(profile->GetPath(),
- profile_name,
- username,
- icon_index);
-}
-
-void ProfileManager::InitProfileUserPrefs(Profile* profile) {
- ProfileInfoCache& cache = GetProfileInfoCache();
-
- if (profile->GetPath().DirName() != cache.GetUserDataDir())
- return;
-
- // Initialize the user preferences (name and avatar) only if the profile
- // doesn't have default preferenc values for them.
- if (HasAnyDefaultUserPrefs(profile)) {
- size_t profile_cache_index =
- cache.GetIndexOfProfileWithPath(profile->GetPath());
- // If the cache has an entry for this profile, use the cache data
- if (profile_cache_index != std::string::npos) {
- profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex,
- cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index));
- profile->GetPrefs()->SetString(prefs::kProfileName,
- UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index)));
- } else if (profile->GetPath() ==
- GetDefaultProfileDir(cache.GetUserDataDir())) {
- profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, 0);
- profile->GetPrefs()->SetString(prefs::kProfileName,
- l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME));
- } else {
- size_t icon_index = cache.ChooseAvatarIconIndexForNewProfile();
- profile->GetPrefs()->SetInteger(prefs::kProfileAvatarIndex, icon_index);
- profile->GetPrefs()->SetString(
- prefs::kProfileName,
- UTF16ToUTF8(cache.ChooseNameForNewProfile(icon_index)));
- }
+ if (profile->GetPath() == GetDefaultProfileDir(cache.GetUserDataDir())) {
+ cache.AddProfileToCache(
+ profile->GetPath(),
+ l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), username, 0);
+ } else {
+ size_t icon_index = cache.ChooseAvatarIconIndexForNewProfile();
+ cache.AddProfileToCache(profile->GetPath(),
+ cache.ChooseNameForNewProfile(icon_index),
+ username,
+ icon_index);
}
}
« 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