| 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 433ef2f58e89637d7abf9515f56fac0d40faccbd..5983840cf380559f41bb7a958edf310e9ae9009e 100644
|
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
|
| @@ -574,14 +574,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [[CustomCircleImageCell alloc] init]);
|
| [self setCell:cell.get()];
|
|
|
| - const int imageSide =
|
| - switches::IsMaterialDesignUserMenu() ? kMdImageSide : kLargeImageSide;
|
| - [self setDefaultImage:CreateProfileImage(profileIcon, imageSide,
|
| - profiles::SHAPE_CIRCLE)];
|
| + [self setDefaultImage:CreateProfileImage(profileIcon, kLargeImageSide,
|
| + profiles::SHAPE_SQUARE)];
|
| [self setImagePosition:NSImageOnly];
|
|
|
| if (editingAllowed) {
|
| - NSRect bounds = NSMakeRect(0, 0, imageSide, imageSide);
|
| + NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide);
|
| [self setTarget:self];
|
| [self setAction:@selector(editPhoto:)];
|
| changePhotoImage_.reset([[TransparentBackgroundImageView alloc]
|
| @@ -841,6 +839,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| initWithLeftMarginSpacing:kHorizontalSpacing
|
| imageTitleSpacing:imageTitleSpacing]);
|
| [cell setLineBreakMode:NSLineBreakByTruncatingTail];
|
| + if (switches::IsMaterialDesignUserMenu())
|
| + [cell setHighlightsBy:NSNoCellMask];
|
| [self setCell:cell.get()];
|
| }
|
| return self;
|
| @@ -870,7 +870,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| }
|
|
|
| - (BOOL)canBecomeKeyView {
|
| - return YES;
|
| + return [self isEnabled] ? YES : NO;
|
| }
|
|
|
| @end
|
| @@ -2051,20 +2051,38 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| // Profile card button that contains the profile icon, name, and username.
|
| NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(),
|
| kMdImageSide + kVerticalSpacing);
|
| - NSButton* profileCard = [self hoverButtonWithRect:rect
|
| - text:[[NSString alloc] init]
|
| - action:@selector(editProfile:)];
|
| + NSButton* profileCard =
|
| + [self hoverButtonWithRect:rect
|
| + text:[[NSString alloc] init]
|
| + image:CreateProfileImage(item.icon, kMdImageSide,
|
| + profiles::SHAPE_CIRCLE)
|
| + action:@selector(editProfile:)];
|
| + [[profileCard cell] setImageDimsWhenDisabled:NO];
|
| [container addSubview:profileCard];
|
| if (isGuestSession_)
|
| [profileCard setEnabled:NO];
|
|
|
| - // Profile icon, left-aligned.
|
| - base::scoped_nsobject<NSImageView> iconView([[NSImageView alloc]
|
| - initWithFrame:NSMakeRect(xOffset, cardYOffset, kMdImageSide,
|
| - kMdImageSide)]);
|
| - [iconView setImage:CreateProfileImage(item.icon, kMdImageSide,
|
| - profiles::SHAPE_CIRCLE)];
|
| - [profileCard addSubview:iconView];
|
| + // Profile badge for supervised account.
|
| + if (browser_->profile()->IsSupervised()) {
|
| + base::scoped_nsobject<NSImageView> supervisedIcon(
|
| + [[NSImageView alloc] initWithFrame:NSZeroRect]);
|
| + // TODO(janeliulwq): Replace the following two profile badge icons with
|
| + // smaller versions of them (24 x 24) to adapt to smaller profile icons.
|
| + int imageId = browser_->profile()->IsChild()
|
| + ? IDR_ICON_PROFILES_MENU_CHILD
|
| + : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED;
|
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| + [supervisedIcon setImage:rb.GetNativeImageNamed(imageId).ToNSImage()];
|
| +
|
| + NSSize size = [[supervisedIcon image] size];
|
| + [supervisedIcon setFrameSize:size];
|
| + const int badgeSpacing = 4;
|
| + [supervisedIcon setFrameOrigin:NSMakePoint(xOffset + kMdImageSide -
|
| + size.width + badgeSpacing,
|
| + cardYOffset + kMdImageSide -
|
| + size.height + badgeSpacing)];
|
| + [profileCard addSubview:supervisedIcon];
|
| + }
|
|
|
| // Profile name, left-aligned to the right of profile icon.
|
| xOffset += kMdImageSide + kHorizontalSpacing;
|
| @@ -2075,12 +2093,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| NSZeroPoint, nil);
|
| [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail];
|
| [profileName setFont:[NSFont labelFontOfSize:fontSize]];
|
| + [profileName sizeToFit];
|
| + const int profileNameYOffset =
|
| + cardYOffset +
|
| + std::floor((kMdImageSide - NSHeight([profileName frame])) / 2);
|
| [profileName
|
| - setFrame:NSMakeRect(
|
| - xOffset,
|
| - cardYOffset +
|
| - (kMdImageSide - [profileName frame].size.height) / 2,
|
| - availableTextWidth, [profileName frame].size.height)];
|
| + setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth,
|
| + NSHeight([profileName frame]))];
|
| [profileCard addSubview:profileName];
|
|
|
| // Username, left-aligned to the right of profile icon and below the profile
|
| @@ -2097,29 +2116,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [profileCard addSubview:username];
|
| }
|
|
|
| - // Profile badge for supervised account.
|
| - if (browser_->profile()->IsSupervised()) {
|
| - base::scoped_nsobject<NSImageView> supervisedIcon(
|
| - [[NSImageView alloc] initWithFrame:NSZeroRect]);
|
| - // TODO(janeliulwq): Replace the following two profile badge icons with
|
| - // smaller versions of them (24 x 24) to adapt to smaller profile icons.
|
| - int imageId = browser_->profile()->IsChild()
|
| - ? IDR_ICON_PROFILES_MENU_CHILD
|
| - : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED;
|
| - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| - [supervisedIcon setImage:rb.GetNativeImageNamed(imageId).ToNSImage()];
|
| -
|
| - NSSize size = [[supervisedIcon image] size];
|
| - [supervisedIcon setFrameSize:size];
|
| - NSRect profileIconFrame = [iconView frame];
|
| - const int badgeSpacing = 4;
|
| - [supervisedIcon setFrameOrigin:NSMakePoint(NSMaxX(profileIconFrame) -
|
| - size.width + badgeSpacing,
|
| - NSMaxY(profileIconFrame) -
|
| - size.height + badgeSpacing)];
|
| - [profileCard addSubview:supervisedIcon];
|
| - }
|
| -
|
| yOffset = NSMaxY([profileCard frame]);
|
| [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| return container.autorelease();
|
|
|