| OLD | NEW |
| 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 // Creates the Gaia sign-in/add account view. | 749 // Creates the Gaia sign-in/add account view. |
| 750 - (NSView*)buildGaiaEmbeddedView; | 750 - (NSView*)buildGaiaEmbeddedView; |
| 751 | 751 |
| 752 // Creates the account removal view. | 752 // Creates the account removal view. |
| 753 - (NSView*)buildAccountRemovalView; | 753 - (NSView*)buildAccountRemovalView; |
| 754 | 754 |
| 755 // Creates the end-preview view. | 755 // Creates the end-preview view. |
| 756 - (NSView*)buildEndPreviewView; | 756 - (NSView*)buildEndPreviewView; |
| 757 | 757 |
| 758 // Creates a button with |text|, an icon given by |imageResourceId| and with | 758 // Creates a button with |text|, an icon given by |imageResourceId| and with |
| 759 // |action|. The icon |alternateImageResourceId| is displayed in the button's | 759 // |action|. |
| 760 // hovered and pressed states. | |
| 761 - (NSButton*)hoverButtonWithRect:(NSRect)rect | 760 - (NSButton*)hoverButtonWithRect:(NSRect)rect |
| 762 text:(NSString*)text | 761 text:(NSString*)text |
| 763 imageResourceId:(int)imageResourceId | 762 imageResourceId:(int)imageResourceId |
| 764 alternateImageResourceId:(int)alternateImageResourceId | |
| 765 action:(SEL)action; | 763 action:(SEL)action; |
| 766 | 764 |
| 767 // Creates a generic link button with |title| and an |action| positioned at | 765 // Creates a generic link button with |title| and an |action| positioned at |
| 768 // |frameOrigin|. | 766 // |frameOrigin|. |
| 769 - (NSButton*)linkButtonWithTitle:(NSString*)title | 767 - (NSButton*)linkButtonWithTitle:(NSString*)title |
| 770 frameOrigin:(NSPoint)frameOrigin | 768 frameOrigin:(NSPoint)frameOrigin |
| 771 action:(SEL)action; | 769 action:(SEL)action; |
| 772 | 770 |
| 773 // Creates an email account button with |title| and a remove icon. If | 771 // Creates an email account button with |title| and a remove icon. If |
| 774 // |reauthRequired| is true, the button also displays a warning icon. |tag| | 772 // |reauthRequired| is true, the button also displays a warning icon. |tag| |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 | 1422 |
| 1425 [link setTitle:elidedButtonText]; | 1423 [link setTitle:elidedButtonText]; |
| 1426 [link setTarget:self]; | 1424 [link setTarget:self]; |
| 1427 [link setAction:@selector(showInlineSigninPage:)]; | 1425 [link setAction:@selector(showInlineSigninPage:)]; |
| 1428 [container addSubview:link]; | 1426 [container addSubview:link]; |
| 1429 | 1427 |
| 1430 // Sign-in promo text. | 1428 // Sign-in promo text. |
| 1431 NSTextField* promo = BuildLabel( | 1429 NSTextField* promo = BuildLabel( |
| 1432 l10n_util::GetNSString(IDS_PROFILES_SIGNIN_PROMO), | 1430 l10n_util::GetNSString(IDS_PROFILES_SIGNIN_PROMO), |
| 1433 NSMakePoint(0, NSMaxY([link frame]) + kVerticalSpacing), | 1431 NSMakePoint(0, NSMaxY([link frame]) + kVerticalSpacing), |
| 1434 nil, nil); | 1432 GetDialogBackgroundColor(), nil); |
| 1435 [promo setFrameSize:NSMakeSize(rect.size.width, 0)]; | 1433 [promo setFrameSize:NSMakeSize(rect.size.width, 0)]; |
| 1436 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:promo]; | 1434 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:promo]; |
| 1437 [container addSubview:promo]; | 1435 [container addSubview:promo]; |
| 1438 | 1436 |
| 1439 [container setFrameSize:NSMakeSize( | 1437 [container setFrameSize:NSMakeSize( |
| 1440 rect.size.width, | 1438 rect.size.width, |
| 1441 NSMaxY([promo frame]) + 4)]; // Adds a small vertical padding. | 1439 NSMaxY([promo frame]) + 4)]; // Adds a small vertical padding. |
| 1442 } | 1440 } |
| 1443 | 1441 |
| 1444 return container.autorelease(); | 1442 return container.autorelease(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 rect.size.width, | 1505 rect.size.width, |
| 1508 kBlueButtonHeight + kSmallVerticalSpacing); | 1506 kBlueButtonHeight + kSmallVerticalSpacing); |
| 1509 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); | 1507 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); |
| 1510 | 1508 |
| 1511 if (enableLock) { | 1509 if (enableLock) { |
| 1512 NSButton* lockButton = | 1510 NSButton* lockButton = |
| 1513 [self hoverButtonWithRect:viewRect | 1511 [self hoverButtonWithRect:viewRect |
| 1514 text:l10n_util::GetNSString( | 1512 text:l10n_util::GetNSString( |
| 1515 IDS_PROFILES_PROFILE_SIGNOUT_BUTTON) | 1513 IDS_PROFILES_PROFILE_SIGNOUT_BUTTON) |
| 1516 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK | 1514 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK |
| 1517 alternateImageResourceId:IDR_ICON_PROFILES_MENU_LOCK | |
| 1518 action:@selector(lockProfile:)]; | 1515 action:@selector(lockProfile:)]; |
| 1519 [container addSubview:lockButton]; | 1516 [container addSubview:lockButton]; |
| 1520 viewRect.origin.y = NSMaxY([lockButton frame]); | 1517 viewRect.origin.y = NSMaxY([lockButton frame]); |
| 1521 | 1518 |
| 1522 NSBox* separator = [self horizontalSeparatorWithFrame:viewRect]; | 1519 NSBox* separator = [self horizontalSeparatorWithFrame:viewRect]; |
| 1523 [container addSubview:separator]; | 1520 [container addSubview:separator]; |
| 1524 viewRect.origin.y = NSMaxY([separator frame]); | 1521 viewRect.origin.y = NSMaxY([separator frame]); |
| 1525 } | 1522 } |
| 1526 | 1523 |
| 1527 if (!isGuestSession_) { | 1524 if (!isGuestSession_) { |
| 1528 // TODO(noms): Use the correct incognito icon when it's available. | 1525 // TODO(noms): Use the correct incognito icon when it's available. |
| 1529 NSButton* goIncognitoButton = | 1526 NSButton* goIncognitoButton = |
| 1530 [self hoverButtonWithRect:viewRect | 1527 [self hoverButtonWithRect:viewRect |
| 1531 text:l10n_util::GetNSString( | 1528 text:l10n_util::GetNSString( |
| 1532 IDS_PROFILES_GO_INCOGNITO_BUTTON) | 1529 IDS_PROFILES_GO_INCOGNITO_BUTTON) |
| 1533 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR | 1530 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
| 1534 alternateImageResourceId:IDR_ICON_PROFILES_MENU_AVATAR | |
| 1535 action:@selector(goIncognito:)]; | 1531 action:@selector(goIncognito:)]; |
| 1536 viewRect.origin.y = NSMaxY([goIncognitoButton frame]); | 1532 viewRect.origin.y = NSMaxY([goIncognitoButton frame]); |
| 1537 [container addSubview:goIncognitoButton]; | 1533 [container addSubview:goIncognitoButton]; |
| 1538 | 1534 |
| 1539 NSBox* separator = [self horizontalSeparatorWithFrame:viewRect]; | 1535 NSBox* separator = [self horizontalSeparatorWithFrame:viewRect]; |
| 1540 [container addSubview:separator]; | 1536 [container addSubview:separator]; |
| 1541 viewRect.origin.y = NSMaxY([separator frame]); | 1537 viewRect.origin.y = NSMaxY([separator frame]); |
| 1542 } | 1538 } |
| 1543 | 1539 |
| 1544 NSString* text = isGuestSession_ ? | 1540 NSString* text = isGuestSession_ ? |
| 1545 l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) : | 1541 l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) : |
| 1546 l10n_util::GetNSString(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1542 l10n_util::GetNSString(IDS_PROFILES_SWITCH_USERS_BUTTON); |
| 1547 NSButton* switchUsersButton = | 1543 NSButton* switchUsersButton = |
| 1548 [self hoverButtonWithRect:viewRect | 1544 [self hoverButtonWithRect:viewRect |
| 1549 text:text | 1545 text:text |
| 1550 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR | 1546 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
| 1551 alternateImageResourceId:IDR_ICON_PROFILES_MENU_AVATAR | |
| 1552 action:isGuestSession_? @selector(exitGuest:) : | 1547 action:isGuestSession_? @selector(exitGuest:) : |
| 1553 @selector(showUserManager:)]; | 1548 @selector(showUserManager:)]; |
| 1554 viewRect.origin.y = NSMaxY([switchUsersButton frame]); | 1549 viewRect.origin.y = NSMaxY([switchUsersButton frame]); |
| 1555 [container addSubview:switchUsersButton]; | 1550 [container addSubview:switchUsersButton]; |
| 1556 | 1551 |
| 1557 [container setFrameSize:NSMakeSize(rect.size.width, viewRect.origin.y)]; | 1552 [container setFrameSize:NSMakeSize(rect.size.width, viewRect.origin.y)]; |
| 1558 return container.autorelease(); | 1553 return container.autorelease(); |
| 1559 } | 1554 } |
| 1560 | 1555 |
| 1561 - (NSView*)createCurrentProfileAccountsView:(NSRect)rect { | 1556 - (NSView*)createCurrentProfileAccountsView:(NSRect)rect { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 - (BOOL)textView:(NSTextView*)textView | 1826 - (BOOL)textView:(NSTextView*)textView |
| 1832 clickedOnLink:(id)link | 1827 clickedOnLink:(id)link |
| 1833 atIndex:(NSUInteger)charIndex { | 1828 atIndex:(NSUInteger)charIndex { |
| 1834 chrome::ShowSettings(browser_); | 1829 chrome::ShowSettings(browser_); |
| 1835 return YES; | 1830 return YES; |
| 1836 } | 1831 } |
| 1837 | 1832 |
| 1838 - (NSButton*)hoverButtonWithRect:(NSRect)rect | 1833 - (NSButton*)hoverButtonWithRect:(NSRect)rect |
| 1839 text:(NSString*)text | 1834 text:(NSString*)text |
| 1840 imageResourceId:(int)imageResourceId | 1835 imageResourceId:(int)imageResourceId |
| 1841 alternateImageResourceId:(int)alternateImageResourceId | |
| 1842 action:(SEL)action { | 1836 action:(SEL)action { |
| 1843 base::scoped_nsobject<BackgroundColorHoverButton> button( | 1837 base::scoped_nsobject<BackgroundColorHoverButton> button( |
| 1844 [[BackgroundColorHoverButton alloc] | 1838 [[BackgroundColorHoverButton alloc] |
| 1845 initWithFrame:rect | 1839 initWithFrame:rect |
| 1846 imageTitleSpacing:kImageTitleSpacing | 1840 imageTitleSpacing:kImageTitleSpacing |
| 1847 backgroundColor:GetDialogBackgroundColor()]); | 1841 backgroundColor:GetDialogBackgroundColor()]); |
| 1848 | 1842 |
| 1849 [button setTitle:text]; | 1843 [button setTitle:text]; |
| 1850 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1844 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 1851 NSImage* alternateImage = rb->GetNativeImageNamed( | 1845 NSImage* image = rb->GetNativeImageNamed(imageResourceId).ToNSImage(); |
| 1852 alternateImageResourceId).ToNSImage(); | 1846 [button setDefaultImage:image]; |
| 1853 [button setDefaultImage:rb->GetNativeImageNamed(imageResourceId).ToNSImage()]; | 1847 [button setHoverImage:image]; |
| 1854 [button setHoverImage:alternateImage]; | 1848 [button setPressedImage:image]; |
| 1855 [button setPressedImage:alternateImage]; | |
| 1856 [button setImagePosition:NSImageLeft]; | 1849 [button setImagePosition:NSImageLeft]; |
| 1857 [button setAlignment:NSLeftTextAlignment]; | 1850 [button setAlignment:NSLeftTextAlignment]; |
| 1858 [button setBordered:NO]; | 1851 [button setBordered:NO]; |
| 1859 [button setTarget:self]; | 1852 [button setTarget:self]; |
| 1860 [button setAction:action]; | 1853 [button setAction:action]; |
| 1861 | 1854 |
| 1862 return button.autorelease(); | 1855 return button.autorelease(); |
| 1863 } | 1856 } |
| 1864 | 1857 |
| 1865 - (NSButton*)linkButtonWithTitle:(NSString*)title | 1858 - (NSButton*)linkButtonWithTitle:(NSString*)title |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 | 1932 |
| 1940 return button.autorelease(); | 1933 return button.autorelease(); |
| 1941 } | 1934 } |
| 1942 | 1935 |
| 1943 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { | 1936 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { |
| 1944 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); | 1937 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); |
| 1945 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; | 1938 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1946 } | 1939 } |
| 1947 | 1940 |
| 1948 @end | 1941 @end |
| OLD | NEW |