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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 return new_path; | 589 return new_path; |
590 } | 590 } |
591 | 591 |
592 // static | 592 // static |
593 base::FilePath ProfileManager::GetGuestProfilePath() { | 593 base::FilePath ProfileManager::GetGuestProfilePath() { |
594 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 594 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
595 | 595 |
596 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 596 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
597 | 597 |
598 base::FilePath guest_path = profile_manager->user_data_dir(); | 598 base::FilePath guest_path = profile_manager->user_data_dir(); |
599 return guest_path.Append(chrome::kGuestProfileDir); | 599 return guest_path.AppendASCII(chrome::kGuestProfileDir); |
| 600 } |
| 601 |
| 602 // static |
| 603 base::FilePath ProfileManager::GetUserManagerProfilePath() { |
| 604 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 605 |
| 606 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 607 |
| 608 base::FilePath profile_path = profile_manager->user_data_dir(); |
| 609 return profile_path.AppendASCII(chrome::kUserManagerProfileDir); |
600 } | 610 } |
601 | 611 |
602 base::FilePath ProfileManager::GenerateNextProfileDirectoryPath() { | 612 base::FilePath ProfileManager::GenerateNextProfileDirectoryPath() { |
603 PrefService* local_state = g_browser_process->local_state(); | 613 PrefService* local_state = g_browser_process->local_state(); |
604 DCHECK(local_state); | 614 DCHECK(local_state); |
605 | 615 |
606 DCHECK(profiles::IsMultipleProfilesEnabled()); | 616 DCHECK(profiles::IsMultipleProfilesEnabled()); |
607 | 617 |
608 // Create the next profile in the next available directory slot. | 618 // Create the next profile in the next available directory slot. |
609 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); | 619 int next_directory = local_state->GetInteger(prefs::kProfilesNumCreated); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 return info; | 1123 return info; |
1114 } | 1124 } |
1115 | 1125 |
1116 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath( | 1126 ProfileManager::ProfileInfo* ProfileManager::GetProfileInfoByPath( |
1117 const base::FilePath& path) const { | 1127 const base::FilePath& path) const { |
1118 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); | 1128 ProfilesInfoMap::const_iterator iter = profiles_info_.find(path); |
1119 return (iter == profiles_info_.end()) ? NULL : iter->second.get(); | 1129 return (iter == profiles_info_.end()) ? NULL : iter->second.get(); |
1120 } | 1130 } |
1121 | 1131 |
1122 void ProfileManager::AddProfileToCache(Profile* profile) { | 1132 void ProfileManager::AddProfileToCache(Profile* profile) { |
1123 if (profile->IsGuestSession()) | 1133 // Don't add guest profiles or the generic user manager profile to the cache. |
| 1134 if (profile->IsGuestSession() || |
| 1135 profile->GetPath() == ProfileManager::GetUserManagerProfilePath()) |
1124 return; | 1136 return; |
1125 ProfileInfoCache& cache = GetProfileInfoCache(); | 1137 ProfileInfoCache& cache = GetProfileInfoCache(); |
1126 if (profile->GetPath().DirName() != cache.GetUserDataDir()) | 1138 if (profile->GetPath().DirName() != cache.GetUserDataDir()) |
1127 return; | 1139 return; |
1128 | 1140 |
1129 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) | 1141 if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos) |
1130 return; | 1142 return; |
1131 | 1143 |
1132 base::string16 username = base::UTF8ToUTF16(profile->GetPrefs()->GetString( | 1144 base::string16 username = base::UTF8ToUTF16(profile->GetPrefs()->GetString( |
1133 prefs::kGoogleServicesUsername)); | 1145 prefs::kGoogleServicesUsername)); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 last_non_managed_profile_path.BaseName().MaybeAsASCII()); | 1298 last_non_managed_profile_path.BaseName().MaybeAsASCII()); |
1287 FinishDeletingProfile(profile_to_delete_path); | 1299 FinishDeletingProfile(profile_to_delete_path); |
1288 } | 1300 } |
1289 } | 1301 } |
1290 } | 1302 } |
1291 #endif | 1303 #endif |
1292 | 1304 |
1293 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1305 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1294 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1306 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1295 } | 1307 } |
OLD | NEW |