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

Unified Diff: chrome/browser/ui/webui/options/personal_options_handler.cc

Issue 8539043: Refactor ProfileInfoCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
Index: chrome/browser/ui/webui/options/personal_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/personal_options_handler.cc b/chrome/browser/ui/webui/options/personal_options_handler.cc
index 10fcf2a5930920a47a69c429e893166827024d21..291a6a8ec9c3ecbe1eeed0638a8ba2e9bd9e031a 100644
--- a/chrome/browser/ui/webui/options/personal_options_handler.cc
+++ b/chrome/browser/ui/webui/options/personal_options_handler.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_info_util.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -404,17 +405,17 @@ void PersonalOptionsHandler::SendProfilesInfo() {
ListValue profile_info_list;
FilePath current_profile_path =
web_ui_->tab_contents()->browser_context()->GetPath();
- for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
- DictionaryValue* profile_value = new DictionaryValue();
- size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
- FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
- profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i));
- profile_value->SetString("iconURL",
- cache.GetDefaultAvatarIconUrl(icon_index));
- profile_value->Set("filePath", base::CreateFilePathValue(profile_path));
- profile_value->SetBoolean("isCurrentProfile",
- profile_path == current_profile_path);
- profile_info_list.Append(profile_value);
+
+ const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName());
+ for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin();
+ it != entries.end(); ++it) {
+ DictionaryValue* value = new DictionaryValue();
+ value->SetString("name", it->name());
+ value->SetString("iconURL",
+ profiles::GetDefaultAvatarIconUrl(it->icon_index()));
+ value->Set("filePath", base::CreateFilePathValue(it->path()));
+ value->SetBoolean("isCurrentProfile", it->path() == current_profile_path);
+ profile_info_list.Append(value);
}
web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo",
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.cc ('k') | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698