Index: chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
diff --git a/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
index 739f3a69bf05e4bfa5dcafc70c719ef9e13c2e6d..8a4c1a7f799a4a9edc3296c5219372f2d576c98d 100644 |
--- a/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
@@ -7,7 +7,6 @@ |
#import "chrome/browser/ui/cocoa/browser/profile_chooser_controller.h" |
#include "base/mac/bundle_locations.h" |
-#include "base/stl_util.h" |
#include "base/strings/sys_string_conversions.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/browser_process.h" |
@@ -17,6 +16,7 @@ |
#include "chrome/browser/profiles/profile_info_util.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/profiles/profile_window.h" |
+#include "chrome/browser/profiles/profiles_state.h" |
#include "chrome/browser/signin/profile_oauth2_token_service.h" |
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
#include "chrome/browser/signin/signin_manager.h" |
@@ -580,39 +580,29 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); |
currentProfileAccounts_.clear(); |
- // The primary account should always be listed first. However, the vector |
- // returned by ProfileOAuth2TokenService::GetAccounts() will contain the |
- // primary account too. Ignore it when it appears later. |
- // TODO(rogerta): we still need to further differentiate the primary account |
- // from the others, so more work is likely required here: crbug.com/311124. |
Profile* profile = browser_->profile(); |
- |
- // TODO(noms): This code is duplicated by the views implementation. See |
- // crbug.com/331805. |
std::string primaryAccount = |
SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); |
DCHECK(!primaryAccount.empty()); |
- std::vector<std::string> accounts = |
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->GetAccounts(); |
- DCHECK_EQ(1, std::count_if(accounts.begin(), accounts.end(), |
- std::bind1st(std::equal_to<std::string>(), |
- primaryAccount))); |
+ std::vector<std::string>accounts = |
+ profiles::GetSecondaryAccountsForProfile(profile, primaryAccount); |
+ |
rect.origin.y = 0; |
for (size_t i = 0; i < accounts.size(); ++i) { |
// Save the original email address, as the button text could be elided. |
currentProfileAccounts_[i] = accounts[i]; |
- if (primaryAccount != accounts[i]) { |
- NSButton* accountButton = [self makeAccountButtonWithRect:rect |
- title:accounts[i] |
- canBeDeleted:true]; |
- [accountButton setTag:i]; |
- [container addSubview:accountButton]; |
- rect.origin.y = NSMaxY([accountButton frame]) + kSmallVerticalSpacing; |
- } |
+ NSButton* accountButton = [self makeAccountButtonWithRect:rect |
+ title:accounts[i] |
+ canBeDeleted:true]; |
+ [accountButton setTag:i]; |
+ [container addSubview:accountButton]; |
+ rect.origin.y = NSMaxY([accountButton frame]) + kSmallVerticalSpacing; |
} |
- // Add the primary account button. It doesn't need a tag, as it cannot be |
- // removed. |
+ // The primary account should always be listed first. It doesn't need a tag, |
+ // as it cannot be removed. |
+ // TODO(rogerta): we still need to further differentiate the primary account |
+ // from the others, so more work is likely required here: crbug.com/311124. |
Alexei Svitkine (slow)
2014/01/08 21:28:37
Should this TODO be in the utility function? Or do
noms (inactive)
2014/01/08 21:35:13
Differentiate in the UI. Fixed.
On 2014/01/08 21:2
|
NSButton* accountButton = [self makeAccountButtonWithRect:rect |
title:primaryAccount |
canBeDeleted:false]; |