Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| index 7198d96d9d1d6146d5026bdfd79803edcfec0e48..fa33f0ea161ea7768321ef7a9ee0bbcd32713948 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| @@ -42,10 +42,10 @@ |
| #include "chrome/browser/ui/singleton_tabs.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/url_constants.h" |
| -#include "components/signin/core/common/profile_management_switches.h" |
| #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
| #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| #include "components/signin/core/browser/signin_manager.h" |
| +#include "components/signin/core/common/profile_management_switches.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/web_contents.h" |
| #include "google_apis/gaia/oauth2_token_service.h" |
| @@ -861,7 +861,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| // |reauthRequired| is true, the button also displays a warning icon. |tag| |
| // indicates which account the button refers to. |
| - (NSButton*)accountButtonWithRect:(NSRect)rect |
| - title:(const std::string&)title |
| + account_id:(const std::string&)account_id |
|
Alexei Svitkine (slow)
2014/08/26 01:04:44
Nit: accountId change on both sides of :.
Roger Tawa OOO till Jul 10th
2014/08/26 19:25:12
Done.
|
| tag:(int)tag |
| reauthRequired:(BOOL)reauthRequired; |
| @@ -926,7 +926,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| - (IBAction)navigateBackFromSigninPage:(id)sender { |
| std::string primaryAccount = SigninManagerFactory::GetForProfile( |
| - browser_->profile())->GetAuthenticatedUsername(); |
| + browser_->profile())->GetAuthenticatedAccountId(); |
| bool hasAccountManagement = !primaryAccount.empty() && |
| switches::IsEnableAccountConsistency(); |
| [self initMenuContentsWithView:hasAccountManagement ? |
| @@ -942,7 +942,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| int tag = [sender tag]; |
| if (tag == kPrimaryProfileTag) { |
| accountIdToRemove_ = SigninManagerFactory::GetForProfile( |
| - browser_->profile())->GetAuthenticatedUsername(); |
| + browser_->profile())->GetAuthenticatedAccountId(); |
| } else { |
| DCHECK(ContainsKey(currentProfileAccounts_, tag)); |
| accountIdToRemove_ = currentProfileAccounts_[tag]; |
| @@ -1789,7 +1789,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| Profile* profile = browser_->profile(); |
| std::string primaryAccount = |
| - SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); |
| + SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
| DCHECK(!primaryAccount.empty()); |
| std::vector<std::string>accounts = |
| profiles::GetSecondaryAccountsForProfile(profile, primaryAccount); |
| @@ -1807,7 +1807,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| currentProfileAccounts_[i] = accounts[i]; |
| NSButton* accountButton = |
| [self accountButtonWithRect:rect |
| - title:accounts[i] |
| + account_id:accounts[i] |
| tag:i |
| reauthRequired:errorAccountId == accounts[i]]; |
| [container addSubview:accountButton]; |
| @@ -1817,7 +1817,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| // The primary account should always be listed first. |
| NSButton* accountButton = |
| [self accountButtonWithRect:rect |
| - title:primaryAccount |
| + account_id:primaryAccount |
| tag:kPrimaryProfileTag |
| reauthRequired:errorAccountId == primaryAccount]; |
| [container addSubview:accountButton]; |
| @@ -1899,7 +1899,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| CGFloat yOffset = kVerticalSpacing; |
| const std::string& primaryAccount = SigninManagerFactory::GetForProfile( |
| - browser_->profile())->GetAuthenticatedUsername(); |
| + browser_->profile())->GetAuthenticatedAccountId(); |
| bool isPrimaryAccount = primaryAccount == accountIdToRemove_; |
| // Adds "remove account" button at the bottom if needed. |
| @@ -1923,10 +1923,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| NSView* contentView; |
| NSPoint contentFrameOrigin = NSMakePoint(kHorizontalSpacing, yOffset); |
| if (isPrimaryAccount) { |
| + std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), |
| + accountIdToRemove_); |
| std::vector<size_t> offsets; |
| NSString* contentStr = l10n_util::GetNSStringF( |
| IDS_PROFILES_PRIMARY_ACCOUNT_REMOVAL_TEXT, |
| - base::UTF8ToUTF16(accountIdToRemove_), base::string16(), &offsets); |
| + base::UTF8ToUTF16(email), base::string16(), &offsets); |
| NSString* linkStr = l10n_util::GetNSString(IDS_PROFILES_SETTINGS_LINK); |
| contentView = BuildFixedWidthTextViewWithLink(self, contentStr, linkStr, |
| offsets[1], contentFrameOrigin, availableWidth); |
| @@ -2089,9 +2091,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| } |
| - (NSButton*)accountButtonWithRect:(NSRect)rect |
| - title:(const std::string&)title |
| + account_id:(const std::string&)account_id |
| tag:(int)tag |
| reauthRequired:(BOOL)reauthRequired { |
| + // Get display email address for account. |
| + std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), |
| + account_id); |
| + |
| ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| NSImage* deleteImage = rb->GetNativeImageNamed(IDR_CLOSE_1).ToNSImage(); |
| CGFloat deleteImageWidth = [deleteImage size].width; |
| @@ -2110,7 +2116,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| [[BackgroundColorHoverButton alloc] initWithFrame:rect |
| imageTitleSpacing:0 |
| backgroundColor:backgroundColor]); |
| - [button setTitle:ElideEmail(title, availableTextWidth)]; |
| + [button setTitle:ElideEmail(email, availableTextWidth)]; |
| [button setAlignment:NSLeftTextAlignment]; |
| [button setBordered:NO]; |
| if (reauthRequired) { |