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

Unified Diff: chrome/browser/profiles/profiles_state.cc

Issue 128513002: Refactor the code that creates the list of secondary accounts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: alexei review Created 6 years, 11 months 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/profiles/profiles_state.cc
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index 62be3add6d38f38d49c4cbac7e14bf0eda86dec8..961fe6d941a988d8b5cf0fe47a7a78f5b55aff0f 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -12,6 +12,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/profile_oauth2_token_service.h"
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
@@ -101,4 +103,21 @@ void UpdateProfileName(Profile* profile,
}
}
+std::vector<std::string> GetSecondaryAccountsForProfile(
+ Profile* profile,
+ const std::string& primary_account) {
+ std::vector<std::string> accounts =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->GetAccounts();
+
+ // The vector returned by ProfileOAuth2TokenService::GetAccounts() contains
+ // the primary account too, so we need to remove it from the list.
+ std::vector<std::string>::iterator primary_index =
+ std::find_if(accounts.begin(), accounts.end(),
+ std::bind1st(std::equal_to<std::string>(), primary_account));
+ DCHECK(primary_index != accounts.end());
+ accounts.erase(primary_index);
+
+ return accounts;
+}
+
} // namespace profiles
« no previous file with comments | « chrome/browser/profiles/profiles_state.h ('k') | chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698