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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 303463010: [Mac] Show a warning in the new avatar button/menu if there's an auth error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rachel nits Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 [container addSubview:button]; 222 [container addSubview:button];
223 [container addSubview:title_label]; 223 [container addSubview:title_label];
224 CGFloat height = std::max(NSMaxY([title_label frame]), 224 CGFloat height = std::max(NSMaxY([title_label frame]),
225 NSMaxY([button frame])) + kSmallVerticalSpacing; 225 NSMaxY([button frame])) + kSmallVerticalSpacing;
226 [container setFrameSize:NSMakeSize(NSWidth([container frame]), height)]; 226 [container setFrameSize:NSMakeSize(NSWidth([container frame]), height)];
227 227
228 return container.autorelease(); 228 return container.autorelease();
229 } 229 }
230 230
231 bool HasAuthError(Profile* profile) {
232 const SigninErrorController* error_controller =
233 profiles::GetSigninErrorController(profile);
234 return error_controller && error_controller->HasError();
235 }
236
231 } // namespace 237 } // namespace
232 238
233 // Class that listens to changes to the OAuth2Tokens for the active profile, 239 // Class that listens to changes to the OAuth2Tokens for the active profile,
234 // changes to the avatar menu model or browser close notifications. 240 // changes to the avatar menu model or browser close notifications.
235 class ActiveProfileObserverBridge : public AvatarMenuObserver, 241 class ActiveProfileObserverBridge : public AvatarMenuObserver,
236 public content::NotificationObserver, 242 public content::NotificationObserver,
237 public OAuth2TokenService::Observer { 243 public OAuth2TokenService::Observer {
238 public: 244 public:
239 ActiveProfileObserverBridge(ProfileChooserController* controller, 245 ActiveProfileObserverBridge(ProfileChooserController* controller,
240 Browser* browser) 246 Browser* browser)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 278 }
273 279
274 // OAuth2TokenService::Observer: 280 // OAuth2TokenService::Observer:
275 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE { 281 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE {
276 // Tokens can only be added by adding an account through the inline flow, 282 // Tokens can only be added by adding an account through the inline flow,
277 // which is started from the account management view. Refresh it to show the 283 // which is started from the account management view. Refresh it to show the
278 // update. 284 // update.
279 profiles::BubbleViewMode viewMode = [controller_ viewMode]; 285 profiles::BubbleViewMode viewMode = [controller_ viewMode];
280 if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || 286 if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ||
281 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || 287 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
282 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { 288 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
289 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
283 [controller_ initMenuContentsWithView: 290 [controller_ initMenuContentsWithView:
284 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 291 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
285 } 292 }
286 } 293 }
287 294
288 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { 295 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE {
289 // Tokens can only be removed from the account management view. Refresh it 296 // Tokens can only be removed from the account management view. Refresh it
290 // to show the update. 297 // to show the update.
291 if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) 298 if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT)
292 [controller_ initMenuContentsWithView: 299 [controller_ initMenuContentsWithView:
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 imageResourceId:(int)imageResourceId 746 imageResourceId:(int)imageResourceId
740 alternateImageResourceId:(int)alternateImageResourceId 747 alternateImageResourceId:(int)alternateImageResourceId
741 action:(SEL)action; 748 action:(SEL)action;
742 749
743 // Creates a generic link button with |title| and an |action| positioned at 750 // Creates a generic link button with |title| and an |action| positioned at
744 // |frameOrigin|. 751 // |frameOrigin|.
745 - (NSButton*)linkButtonWithTitle:(NSString*)title 752 - (NSButton*)linkButtonWithTitle:(NSString*)title
746 frameOrigin:(NSPoint)frameOrigin 753 frameOrigin:(NSPoint)frameOrigin
747 action:(SEL)action; 754 action:(SEL)action;
748 755
749 // Creates an email account button with |title| and a remove icon. |tag| 756 // Creates an email account button with |title| and a remove icon. If
757 // |reauthRequired| is true, the button also displays a warning icon. |tag|
750 // indicates which account the button refers to. 758 // indicates which account the button refers to.
751 - (NSButton*)accountButtonWithRect:(NSRect)rect 759 - (NSButton*)accountButtonWithRect:(NSRect)rect
752 title:(const std::string&)title 760 title:(const std::string&)title
753 tag:(int)tag; 761 tag:(int)tag
762 reauthRequired:(BOOL)reauthRequired;
754 @end 763 @end
755 764
756 @implementation ProfileChooserController 765 @implementation ProfileChooserController
757 - (profiles::BubbleViewMode) viewMode { 766 - (profiles::BubbleViewMode) viewMode {
758 return viewMode_; 767 return viewMode_;
759 } 768 }
760 769
761 - (IBAction)switchToProfile:(id)sender { 770 - (IBAction)switchToProfile:(id)sender {
762 // Check the event flags to see if a new window should be created. 771 // Check the event flags to see if a new window should be created.
763 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( 772 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 accountIdToRemove_ = SigninManagerFactory::GetForProfile( 829 accountIdToRemove_ = SigninManagerFactory::GetForProfile(
821 browser_->profile())->GetAuthenticatedUsername(); 830 browser_->profile())->GetAuthenticatedUsername();
822 } else { 831 } else {
823 DCHECK(ContainsKey(currentProfileAccounts_, tag)); 832 DCHECK(ContainsKey(currentProfileAccounts_, tag));
824 accountIdToRemove_ = currentProfileAccounts_[tag]; 833 accountIdToRemove_ = currentProfileAccounts_[tag];
825 } 834 }
826 835
827 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL]; 836 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL];
828 } 837 }
829 838
839 - (IBAction)showAccountReauthenticationView:(id)sender {
840 DCHECK(!isGuestSession_);
841 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH];
842 }
843
830 - (IBAction)removeAccount:(id)sender { 844 - (IBAction)removeAccount:(id)sender {
831 DCHECK(!accountIdToRemove_.empty()); 845 DCHECK(!accountIdToRemove_.empty());
832 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 846 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
833 browser_->profile())->RevokeCredentials(accountIdToRemove_); 847 browser_->profile())->RevokeCredentials(accountIdToRemove_);
834 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT]; 848 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT];
835 accountIdToRemove_.clear(); 849 accountIdToRemove_.clear();
836 850
837 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 851 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
838 } 852 }
839 853
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 924
911 avatarMenu_.reset(new AvatarMenu( 925 avatarMenu_.reset(new AvatarMenu(
912 &g_browser_process->profile_manager()->GetProfileInfoCache(), 926 &g_browser_process->profile_manager()->GetProfileInfoCache(),
913 observer_.get(), 927 observer_.get(),
914 browser_)); 928 browser_));
915 avatarMenu_->RebuildMenu(); 929 avatarMenu_->RebuildMenu();
916 930
917 // Guest profiles do not have a token service. 931 // Guest profiles do not have a token service.
918 isGuestSession_ = browser_->profile()->IsGuestSession(); 932 isGuestSession_ = browser_->profile()->IsGuestSession();
919 933
934 // If view mode is PROFILE_CHOOSER but there is an auth error, force
935 // ACCOUNT_MANAGEMENT mode.
936 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
937 HasAuthError(browser_->profile())) {
938 viewMode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
939 }
940
920 [[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge]; 941 [[self bubble] setAlignment:info_bubble::kAlignRightEdgeToAnchorEdge];
921 [[self bubble] setArrowLocation:info_bubble::kNoArrow]; 942 [[self bubble] setArrowLocation:info_bubble::kNoArrow];
922 [[self bubble] setBackgroundColor:GetDialogBackgroundColor()]; 943 [[self bubble] setBackgroundColor:GetDialogBackgroundColor()];
923 [self initMenuContentsWithView:viewMode_]; 944 [self initMenuContentsWithView:viewMode_];
924 } 945 }
925 946
926 return self; 947 return self;
927 } 948 }
928 949
929 - (void)initMenuContentsWithView:(profiles::BubbleViewMode)viewToDisplay { 950 - (void)initMenuContentsWithView:(profiles::BubbleViewMode)viewToDisplay {
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); 1520 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]);
1500 currentProfileAccounts_.clear(); 1521 currentProfileAccounts_.clear();
1501 1522
1502 Profile* profile = browser_->profile(); 1523 Profile* profile = browser_->profile();
1503 std::string primaryAccount = 1524 std::string primaryAccount =
1504 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); 1525 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername();
1505 DCHECK(!primaryAccount.empty()); 1526 DCHECK(!primaryAccount.empty());
1506 std::vector<std::string>accounts = 1527 std::vector<std::string>accounts =
1507 profiles::GetSecondaryAccountsForProfile(profile, primaryAccount); 1528 profiles::GetSecondaryAccountsForProfile(profile, primaryAccount);
1508 1529
1530 // If there is an account with an authentication error, it needs to be
1531 // badged with a warning icon.
1532 const SigninErrorController* errorController =
1533 profiles::GetSigninErrorController(profile);
1534 std::string errorAccountId =
1535 errorController ? errorController->error_account_id() : std::string();
1536
1509 rect.origin.y = 0; 1537 rect.origin.y = 0;
1510 for (size_t i = 0; i < accounts.size(); ++i) { 1538 for (size_t i = 0; i < accounts.size(); ++i) {
1511 // Save the original email address, as the button text could be elided. 1539 // Save the original email address, as the button text could be elided.
1512 currentProfileAccounts_[i] = accounts[i]; 1540 currentProfileAccounts_[i] = accounts[i];
1513 NSButton* accountButton = [self accountButtonWithRect:rect 1541 NSButton* accountButton =
1514 title:accounts[i] 1542 [self accountButtonWithRect:rect
1515 tag:i]; 1543 title:accounts[i]
1544 tag:i
1545 reauthRequired:errorAccountId == accounts[i]];
1516 [container addSubview:accountButton]; 1546 [container addSubview:accountButton];
1517 rect.origin.y = NSMaxY([accountButton frame]); 1547 rect.origin.y = NSMaxY([accountButton frame]);
1518 } 1548 }
1519 1549
1520 // The primary account should always be listed first. 1550 // The primary account should always be listed first.
1521 NSButton* accountButton = [self accountButtonWithRect:rect 1551 NSButton* accountButton =
1522 title:primaryAccount 1552 [self accountButtonWithRect:rect
1523 tag:kPrimaryProfileTag]; 1553 title:primaryAccount
1554 tag:kPrimaryProfileTag
1555 reauthRequired:errorAccountId == primaryAccount];
1524 [container addSubview:accountButton]; 1556 [container addSubview:accountButton];
1525 [container setFrameSize:NSMakeSize(NSWidth([container frame]), 1557 [container setFrameSize:NSMakeSize(NSWidth([container frame]),
1526 NSMaxY([accountButton frame]))]; 1558 NSMaxY([accountButton frame]))];
1527 return container.autorelease(); 1559 return container.autorelease();
1528 } 1560 }
1529 1561
1530 - (NSView*)buildGaiaEmbeddedView { 1562 - (NSView*)buildGaiaEmbeddedView {
1531 base::scoped_nsobject<NSView> container( 1563 base::scoped_nsobject<NSView> container(
1532 [[NSView alloc] initWithFrame:NSZeroRect]); 1564 [[NSView alloc] initWithFrame:NSZeroRect]);
1533 CGFloat yOffset = 0; 1565 CGFloat yOffset = 0;
1534 1566
1535 bool addSecondaryAccount = 1567 GURL url;
1536 viewMode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT; 1568 int messageId = -1;
1537 signin::Source source = addSecondaryAccount ? 1569 SigninErrorController* errorController = NULL;
1538 signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT : 1570 switch (viewMode_) {
1539 signin::SOURCE_AVATAR_BUBBLE_SIGN_IN; 1571 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
1572 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN,
1573 false /* auto_close */,
1574 true /* is_constrained */);
1575 messageId = IDS_PROFILES_GAIA_SIGNIN_TITLE;
1576 break;
1577 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
1578 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT,
1579 false /* auto_close */,
1580 true /* is_constrained */);
1581 messageId = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE;
1582 break;
1583 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH:
1584 DCHECK(HasAuthError(browser_->profile()));
1585 errorController = profiles::GetSigninErrorController(browser_->profile());
1586 url = signin::GetReauthURL(
1587 browser_->profile(),
1588 errorController ? errorController->error_username() : std::string());
1589 messageId = IDS_PROFILES_GAIA_REAUTH_TITLE;
1590 break;
1591 default:
1592 NOTREACHED() << "Called with invalid mode=" << viewMode_;
1593 break;
1594 }
1540 1595
1541 webContents_.reset(content::WebContents::Create( 1596 webContents_.reset(content::WebContents::Create(
1542 content::WebContents::CreateParams(browser_->profile()))); 1597 content::WebContents::CreateParams(browser_->profile())));
1543 webContents_->GetController().LoadURL( 1598 webContents_->GetController().LoadURL(url,
1544 signin::GetPromoURL( 1599 content::Referrer(),
1545 source, false /* auto_close */, true /* is_constrained */), 1600 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
1546 content::Referrer(), 1601 std::string());
1547 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
1548 std::string());
1549 NSView* webview = webContents_->GetNativeView(); 1602 NSView* webview = webContents_->GetNativeView();
1550 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)]; 1603 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)];
1551 [container addSubview:webview]; 1604 [container addSubview:webview];
1552 yOffset = NSMaxY([webview frame]); 1605 yOffset = NSMaxY([webview frame]);
1553 1606
1554 // Adds the title card. 1607 // Adds the title card.
1555 NSBox* separator = [self separatorWithFrame: 1608 NSBox* separator = [self separatorWithFrame:
1556 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; 1609 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)];
1557 [container addSubview:separator]; 1610 [container addSubview:separator];
1558 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 1611 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing;
1559 1612
1560 NSView* titleView = BuildTitleCard( 1613 NSView* titleView = BuildTitleCard(
1561 NSMakeRect(0, yOffset, kFixedGaiaViewWidth,0), 1614 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0),
1562 addSecondaryAccount ? IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE : 1615 messageId,
1563 IDS_PROFILES_GAIA_SIGNIN_TITLE,
1564 self /* backButtonTarget*/, 1616 self /* backButtonTarget*/,
1565 @selector(navigateBackFromSigninPage:) /* backButtonAction */); 1617 @selector(navigateBackFromSigninPage:) /* backButtonAction */);
1566 [container addSubview:titleView]; 1618 [container addSubview:titleView];
1567 yOffset = NSMaxY([titleView frame]); 1619 yOffset = NSMaxY([titleView frame]);
1568 1620
1569 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)]; 1621 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)];
1570 return container.autorelease(); 1622 return container.autorelease();
1571 } 1623 }
1572 1624
1573 - (NSView*)buildAccountRemovalView { 1625 - (NSView*)buildAccountRemovalView {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 [link setTarget:self]; 1794 [link setTarget:self];
1743 [link setAction:action]; 1795 [link setAction:action];
1744 [link setFrameOrigin:frameOrigin]; 1796 [link setFrameOrigin:frameOrigin];
1745 [link sizeToFit]; 1797 [link sizeToFit];
1746 1798
1747 return link.autorelease(); 1799 return link.autorelease();
1748 } 1800 }
1749 1801
1750 - (NSButton*)accountButtonWithRect:(NSRect)rect 1802 - (NSButton*)accountButtonWithRect:(NSRect)rect
1751 title:(const std::string&)title 1803 title:(const std::string&)title
1752 tag:(int)tag { 1804 tag:(int)tag
1805 reauthRequired:(BOOL)reauthRequired {
1806 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1807 NSImage* deleteImage = rb->GetNativeImageNamed(IDR_CLOSE_1).ToNSImage();
1808 CGFloat deleteImageWidth = [deleteImage size].width;
1809 NSImage* warningImage = reauthRequired ? rb->GetNativeImageNamed(
1810 IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToNSImage() : nil;
1811 CGFloat warningImageWidth = [warningImage size].width;
1812
1813 CGFloat availableTextWidth = rect.size.width - kHorizontalSpacing -
1814 warningImageWidth - deleteImageWidth;
1815 if (warningImage)
1816 availableTextWidth -= kHorizontalSpacing;
1817
1753 NSColor* backgroundColor = gfx::SkColorToCalibratedNSColor( 1818 NSColor* backgroundColor = gfx::SkColorToCalibratedNSColor(
1754 profiles::kAvatarBubbleAccountsBackgroundColor); 1819 profiles::kAvatarBubbleAccountsBackgroundColor);
1755 base::scoped_nsobject<BackgroundColorHoverButton> button( 1820 base::scoped_nsobject<BackgroundColorHoverButton> button(
1756 [[BackgroundColorHoverButton alloc] initWithFrame:rect 1821 [[BackgroundColorHoverButton alloc] initWithFrame:rect
1757 imageTitleSpacing:0 1822 imageTitleSpacing:0
1758 backgroundColor:backgroundColor]); 1823 backgroundColor:backgroundColor]);
1759 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1824 [button setTitle:ElideEmail(title, availableTextWidth)];
1760 NSImage* defaultImage = rb->GetNativeImageNamed(IDR_CLOSE_1).AsNSImage();
1761 CGFloat kDeleteButtonWidth = [defaultImage size].width;
1762 CGFloat availableWidth = rect.size.width -
1763 kDeleteButtonWidth - kHorizontalSpacing;
1764 [button setTitle:ElideEmail(title, availableWidth)];
1765 [button setAlignment:NSLeftTextAlignment]; 1825 [button setAlignment:NSLeftTextAlignment];
1766 [button setBordered:NO]; 1826 [button setBordered:NO];
1827 if (reauthRequired) {
1828 [button setDefaultImage:warningImage];
1829 [button setImagePosition:NSImageLeft];
1830 [button setTarget:self];
1831 [button setAction:@selector(showAccountReauthenticationView:)];
1832 [button setTag:tag];
1833 }
1767 1834
1768 // Delete button. 1835 // Delete button.
1769 rect.origin = NSMakePoint(availableWidth, 0); 1836 NSRect buttonRect;
1770 rect.size.width = kDeleteButtonWidth; 1837 NSDivideRect(rect, &buttonRect, &rect,
1838 deleteImageWidth + kHorizontalSpacing, NSMaxXEdge);
1839 buttonRect.origin.y = 0;
1840
1771 base::scoped_nsobject<HoverImageButton> deleteButton( 1841 base::scoped_nsobject<HoverImageButton> deleteButton(
1772 [[HoverImageButton alloc] initWithFrame:rect]); 1842 [[HoverImageButton alloc] initWithFrame:buttonRect]);
1773 [deleteButton setBordered:NO]; 1843 [deleteButton setBordered:NO];
1774 [deleteButton setDefaultImage:defaultImage]; 1844 [deleteButton setDefaultImage:deleteImage];
1775 [deleteButton setHoverImage:rb->GetNativeImageNamed( 1845 [deleteButton setHoverImage:rb->GetNativeImageNamed(
1776 IDR_CLOSE_1_H).ToNSImage()]; 1846 IDR_CLOSE_1_H).ToNSImage()];
1777 [deleteButton setPressedImage:rb->GetNativeImageNamed( 1847 [deleteButton setPressedImage:rb->GetNativeImageNamed(
1778 IDR_CLOSE_1_P).ToNSImage()]; 1848 IDR_CLOSE_1_P).ToNSImage()];
1779 [deleteButton setTarget:self]; 1849 [deleteButton setTarget:self];
1780 [deleteButton setAction:@selector(showAccountRemovalView:)]; 1850 [deleteButton setAction:@selector(showAccountRemovalView:)];
1781 [deleteButton setTag:tag]; 1851 [deleteButton setTag:tag];
1782 1852
1783 [button addSubview:deleteButton]; 1853 [button addSubview:deleteButton];
1854
1784 return button.autorelease(); 1855 return button.autorelease();
1785 } 1856 }
1786 1857
1787 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { 1858 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action {
1788 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); 1859 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_);
1789 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; 1860 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE;
1790 } 1861 }
1791 1862
1792 @end 1863 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698