Index: chrome/browser/profiles/profile_manager.cc |
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc |
index 6cf3a09e95103a161d07fcd0d9412409ed14a0e4..49edc842bed13f8ecf83334a2c7e5bc1a671b8c4 100644 |
--- a/chrome/browser/profiles/profile_manager.cc |
+++ b/chrome/browser/profiles/profile_manager.cc |
@@ -32,6 +32,7 @@ |
#include "net/url_request/url_request_context.h" |
#include "net/url_request/url_request_context_getter.h" |
#include "net/url_request/url_request_job.h" |
+#include "ui/base/l10n/l10n_util.h" |
#if defined(OS_CHROMEOS) |
#include "chrome/browser/chromeos/cros/cros_library.h" |
@@ -302,6 +303,12 @@ ProfileManager::ProfileInfo* ProfileManager::RegisterProfile(Profile* profile, |
ProfileInfo* info = new ProfileInfo(profile, created); |
ProfilesInfoMap::iterator new_elem = |
(profiles_info_.insert(std::make_pair(profile->GetPath(), info))).first; |
+ |
+ NotificationService::current()->Notify( |
+ NotificationType::PROFILE_ADDED, |
+ Source<Profile>(profile), |
+ NotificationService::NoDetails()); |
+ |
return info; |
} |
@@ -429,3 +436,49 @@ void ProfileManager::RegisterPrefs(PrefService* prefs) { |
prefs->RegisterDictionaryPref(prefs::kProfileDirectoryMap); |
prefs->RegisterIntegerPref(prefs::kProfilesNumCreated, 1); |
} |
+ |
+ |
+size_t ProfileManager::GetNumberOfProfiles() { |
+ const DictionaryValue* path_map = |
+ g_browser_process->local_state()->GetDictionary( |
+ prefs::kProfileDirectoryMap); |
+ if (path_map) |
sky
2011/06/10 16:24:14
nit: return path_map ? path_map->size() : 0;
sail
2011/06/11 01:27:37
Done.
|
+ return path_map->size(); |
+ return 0; |
+} |
+ |
+string16 ProfileManager::GetNameOfProfileAtIndex(size_t index) { |
+ return GetSortedProfilesFromDirectoryMap()[index].second; |
+} |
+ |
+FilePath ProfileManager::GetFilePathOfProfileAtIndex( |
+ size_t index, FilePath user_data_dir) { |
+ FilePath base_name = GetSortedProfilesFromDirectoryMap()[index].first; |
+ return user_data_dir.Append(base_name); |
+} |
+ |
+std::vector<std::pair<FilePath, string16> > |
+ProfileManager::GetSortedProfilesFromDirectoryMap() { |
+ std::vector<std::pair<FilePath, string16> > profiles; |
+ |
+ const DictionaryValue* path_map = |
+ g_browser_process->local_state()->GetDictionary( |
+ prefs::kProfileDirectoryMap); |
+ if (!path_map) |
+ return profiles; |
+ |
+ for (DictionaryValue::key_iterator it = path_map->begin_keys(); |
+ it != path_map->end_keys(); ++it) { |
+ std::string name_ascii; |
+ path_map->GetString(*it, &name_ascii); |
+ string16 name = ASCIIToUTF16(name_ascii); |
+ if (name.empty()) |
+ name = l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME); |
+ FilePath file_path(*it); |
+ |
+ // Pending, need to insert it alphabetically. |
sky
2011/06/10 16:24:14
Pending -> TODO
sail
2011/06/11 01:27:37
Removed and added sorting.
|
+ profiles.push_back(std::pair<FilePath, string16>(file_path, name)); |
+ } |
+ |
+ return profiles; |
+} |