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; |