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

Unified Diff: chrome/browser/ui/webui/sync_setup_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
« no previous file with comments | « chrome/browser/ui/webui/options/personal_options_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/sync_setup_handler.cc
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 914f823f745edb3a76a69797f61db8f241a93202..7bec582deaabd3da57e73cf3f0400540cfebd86b 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -726,14 +726,15 @@ bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username,
return true;
// Check if the username is already in use by another profile.
- const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
- size_t current_profile_index = cache.GetIndexOfProfileWithPath(
- Profile::FromWebUI(web_ui_)->GetPath());
- string16 username_utf16 = UTF8ToUTF16(username);
+ FilePath cur_path = Profile::FromWebUI(web_ui_)->GetPath();
+ string16 cur_username = UTF8ToUTF16(username);
- for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
- if (i != current_profile_index && AreUserNamesEqual(
- cache.GetUserNameOfProfileAtIndex(i), username_utf16)) {
+ const ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
+ const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName());
+ for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin();
+ it != entries.end(); ++it) {
+ if (it->path() != cur_path &&
+ AreUserNamesEqual(it->user_name(), cur_username)) {
*error_message = l10n_util::GetStringUTF16(
IDS_SYNC_USER_NAME_IN_USE_ERROR);
return false;
« no previous file with comments | « chrome/browser/ui/webui/options/personal_options_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698