| Index: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
|
| index 6163f015f1daf352ec8af7f7bcdc90c51664d6d1..534ab905e7ee43fe2efef59a7a763db6badde541 100644
|
| --- a/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm
|
| @@ -74,6 +74,9 @@ CGFloat ButtonExtraPadding() {
|
| // Extra padding for the MD signed out avatar button.
|
| const CGFloat kMaterialSignedOutWidthPadding = 2;
|
|
|
| +// Kern value for the MD avatar button title.
|
| +const CGFloat kMaterialTitleKern = 0.25;
|
| +
|
| } // namespace
|
|
|
| // Button cell with a custom border given by a set of nine-patch image grids.
|
| @@ -258,23 +261,17 @@ const CGFloat kMaterialSignedOutWidthPadding = 2;
|
| - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
|
| // The button text has a black foreground and a white drop shadow for regular
|
| // windows, and a light text with a dark drop shadow for guest windows
|
| - // which are themed with a dark background.
|
| - base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
|
| - [shadow setShadowOffset:NSMakeSize(0, -1)];
|
| - [shadow setShadowBlurRadius:0];
|
| + // which are themed with a dark background. If we're using MD, then there
|
| + // should be no drop shadows.
|
| + BOOL isMaterial = ui::MaterialDesignController::IsModeMaterial();
|
|
|
| NSColor* foregroundColor;
|
| - if (browser_->profile()->IsGuestSession() &&
|
| - !ui::MaterialDesignController::IsModeMaterial()) {
|
| + if (browser_->profile()->IsGuestSession() && isMaterial)
|
| foregroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.9];
|
| - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.4]];
|
| - } else if (!isThemedWindow_) {
|
| + else if (!isThemedWindow_)
|
| foregroundColor = [NSColor blackColor];
|
| - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.7]];
|
| - } else {
|
| + else
|
| foregroundColor = [NSColor blackColor];
|
| - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]];
|
| - }
|
|
|
| ProfileAttributesStorage& storage =
|
| g_browser_process->profile_manager()->GetProfileAttributesStorage();
|
| @@ -286,7 +283,6 @@ const CGFloat kMaterialSignedOutWidthPadding = 2;
|
| storage.GetNumberOfProfiles() == 1 &&
|
| !storage.GetAllProfilesAttributes().front()->IsAuthenticated();
|
|
|
| -
|
| NSString* buttonTitle = base::SysUTF16ToNSString(useGenericButton ?
|
| base::string16() :
|
| profiles::GetAvatarButtonTextForProfile(browser_->profile()));
|
| @@ -296,7 +292,7 @@ const CGFloat kMaterialSignedOutWidthPadding = 2;
|
| base::mac::ObjCCastStrict<AvatarButton>(button_);
|
|
|
| if (useGenericButton) {
|
| - if (ui::MaterialDesignController::IsModeMaterial()) {
|
| + if (isMaterial) {
|
| NSImage* avatarIcon = NSImageFromImageSkia(
|
| gfx::CreateVectorIcon(gfx::VectorIconId::USER_ACCOUNT_AVATAR, 18,
|
| kMaterialAvatarIconColor));
|
| @@ -318,7 +314,6 @@ const CGFloat kMaterialSignedOutWidthPadding = 2;
|
| }
|
| [button setImagePosition:NSImageOnly];
|
| } else if (hasError_) {
|
| - BOOL isMaterial = ui::MaterialDesignController::IsModeMaterial();
|
| NSImage* errorIcon =
|
| isMaterial
|
| ? NSImageFromImageSkia(gfx::CreateVectorIcon(
|
| @@ -340,13 +335,39 @@ const CGFloat kMaterialSignedOutWidthPadding = 2;
|
| [[NSMutableParagraphStyle alloc] init]);
|
| [paragraphStyle setAlignment:NSLeftTextAlignment];
|
|
|
| - base::scoped_nsobject<NSAttributedString> attributedTitle(
|
| - [[NSAttributedString alloc]
|
| - initWithString:buttonTitle
|
| - attributes:@{ NSShadowAttributeName : shadow.get(),
|
| - NSForegroundColorAttributeName : foregroundColor,
|
| - NSParagraphStyleAttributeName : paragraphStyle }]);
|
| - [button_ setAttributedTitle:attributedTitle];
|
| + if (isMaterial) {
|
| + base::scoped_nsobject<NSAttributedString> attributedTitle(
|
| + [[NSAttributedString alloc]
|
| + initWithString:buttonTitle
|
| + attributes:@{
|
| + NSForegroundColorAttributeName : foregroundColor,
|
| + NSParagraphStyleAttributeName : paragraphStyle,
|
| + NSKernAttributeName :
|
| + [NSNumber numberWithFloat:kMaterialTitleKern]
|
| + }]);
|
| + [button_ setAttributedTitle:attributedTitle];
|
| + } else {
|
| + // Create the white drop shadow.
|
| + base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
|
| + [shadow setShadowOffset:NSMakeSize(0, -1)];
|
| + [shadow setShadowBlurRadius:0];
|
| + if (browser_->profile()->IsGuestSession())
|
| + [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.4]];
|
| + else if (!isThemedWindow_)
|
| + [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.7]];
|
| + else
|
| + [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]];
|
| +
|
| + base::scoped_nsobject<NSAttributedString> attributedTitle(
|
| + [[NSAttributedString alloc]
|
| + initWithString:buttonTitle
|
| + attributes:@{
|
| + NSShadowAttributeName : shadow.get(),
|
| + NSForegroundColorAttributeName : foregroundColor,
|
| + NSParagraphStyleAttributeName : paragraphStyle
|
| + }]);
|
| + [button_ setAttributedTitle:attributedTitle];
|
| + }
|
| [button_ sizeToFit];
|
|
|
| if (layoutParent) {
|
|
|