| 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 62b634fecd91984bf3e082ea20ad01bf59b94d7a..d3e3f2c3bac65124397a80e09f586c1044d19bd7 100644
|
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm
|
| @@ -94,9 +94,10 @@ namespace {
|
| // Constants taken from the Windows/Views implementation at:
|
| // chrome/browser/ui/views/profile_chooser_view.cc
|
| const int kLargeImageSide = 88;
|
| -const int kSmallImageSide = 32;
|
| const int kMdImageSide = 40;
|
|
|
| +const CGFloat kFixedMenuWidth = 240.0;
|
| +const int kIconImageSide = 18;
|
| const CGFloat kVerticalSpacing = 16.0;
|
| const CGFloat kSmallVerticalSpacing = 10.0;
|
| const CGFloat kRelatedControllVerticalSpacing = 8.0;
|
| @@ -105,7 +106,6 @@ const CGFloat kTitleFontSize = 15.0;
|
| const CGFloat kTextFontSize = 12.0;
|
| const CGFloat kProfileButtonHeight = 30;
|
| const int kBezelThickness = 3; // Width of the bezel on an NSButton.
|
| -const int kImageTitleSpacing = 10;
|
| const int kBlueButtonHeight = 30;
|
| const CGFloat kFocusRingLineWidth = 2;
|
|
|
| @@ -121,10 +121,6 @@ const int kFixedSwitchUserViewWidth = 320;
|
| // The tag number for the primary account.
|
| const int kPrimaryProfileTag = -1;
|
|
|
| -CGFloat GetFixedMenuWidth() {
|
| - return switches::IsMaterialDesignUserMenu() ? 240.0 : 250.0;
|
| -}
|
| -
|
| NSImage* CreateProfileImage(const gfx::Image& icon,
|
| int imageSize,
|
| profiles::AvatarShape shape) {
|
| @@ -861,8 +857,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| initWithLeftMarginSpacing:kHorizontalSpacing
|
| imageTitleSpacing:imageTitleSpacing]);
|
| [cell setLineBreakMode:NSLineBreakByTruncatingTail];
|
| - if (switches::IsMaterialDesignUserMenu())
|
| - [cell setHighlightsBy:NSNoCellMask];
|
| + [cell setHighlightsBy:NSNoCellMask];
|
| [self setCell:cell.get()];
|
| }
|
| return self;
|
| @@ -965,8 +960,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| // Builds the profile chooser view.
|
| - (NSView*)buildProfileChooserView;
|
|
|
| -- (NSView*)buildTutorialViewIfNeededForItem:(const AvatarMenu::Item&)item;
|
| -
|
| // Builds a tutorial card with a title label using |titleMessage|, a content
|
| // label using |contentMessage|, a link using |linkMessage|, and a button using
|
| // |buttonMessage|. If |stackButton| is YES, places the button above the link.
|
| @@ -1006,7 +999,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| // Creates the main profile card for the profile |item| at the top of
|
| // the bubble, for non-material-design and material design user menu
|
| // respectively.
|
| -- (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item;
|
| - (NSView*)createMaterialDesignCurrentProfileView:(const AvatarMenu::Item&)item;
|
|
|
| // Creates the possible links for the main profile card with profile |item|.
|
| @@ -1024,10 +1016,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| // switcher view.
|
| - (NSButton*)createOtherProfileView:(int)itemIndex;
|
|
|
| -// Creates the following option buttons: lock profile, go incognito, and switch
|
| -// user/exit guest.
|
| -- (NSView*)createOptionsViewWithRect:(NSRect)rect
|
| - showLock:(BOOL)showLock;
|
| // For material design user menu, creates the following option buttons: lock
|
| // profile/close all windows, switch user/exit guest, and open guest profile.
|
| - (NSView*)createMaterialDesignOptionsViewWithFrame:(NSRect)frame
|
| @@ -1431,9 +1419,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
|
|
| - (CGFloat)addSeparatorToContainer:(NSView*)container
|
| atYOffset:(CGFloat)yOffset {
|
| - NSBox* separator =
|
| - [self horizontalSeparatorWithFrame:NSMakeRect(0, yOffset,
|
| - GetFixedMenuWidth(), 0)];
|
| + NSBox* separator = [self
|
| + horizontalSeparatorWithFrame:NSMakeRect(0, yOffset, kFixedMenuWidth, 0)];
|
| [container addSubview:separator];
|
| return NSMaxY([separator frame]);
|
| }
|
| @@ -1450,12 +1437,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)];
|
| [container addSubview:otherProfileView];
|
| yOffset = NSMaxY([otherProfileView frame]);
|
| -
|
| - if (!switches::IsMaterialDesignUserMenu())
|
| - yOffset = [self addSeparatorToContainer:container atYOffset:yOffset];
|
| }
|
|
|
| - [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
|
| return yOffset;
|
| }
|
|
|
| @@ -1466,28 +1450,22 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| atYOffset:(CGFloat)yOffset
|
| inContainer:(NSView*)container
|
| showLock:(bool)showLock {
|
| - if (switches::IsMaterialDesignUserMenu())
|
| - yOffset += kRelatedControllVerticalSpacing;
|
| + yOffset += kRelatedControllVerticalSpacing;
|
|
|
| // Option buttons.
|
| - NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(), 0);
|
| + NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0);
|
| NSView* optionsView =
|
| - switches::IsMaterialDesignUserMenu()
|
| - ? [self createMaterialDesignOptionsViewWithFrame:rect
|
| - showLock:showLock]
|
| - : [self createOptionsViewWithRect:rect showLock:showLock];
|
| + [self createMaterialDesignOptionsViewWithFrame:rect showLock:showLock];
|
| [container addSubview:optionsView];
|
| rect.origin.y = NSMaxY([optionsView frame]);
|
| yOffset = rect.origin.y;
|
|
|
| - // For material design user menu, add the fast user switching buttons.
|
| - if (switches::IsMaterialDesignUserMenu()) {
|
| - yOffset = [self buildFastUserSwitcherViewWithProfiles:otherProfiles
|
| - atYOffset:yOffset
|
| - inContainer:container];
|
| - yOffset += kRelatedControllVerticalSpacing;
|
| - rect.origin.y = yOffset;
|
| - }
|
| + // Add the fast user switching buttons.
|
| + yOffset = [self buildFastUserSwitcherViewWithProfiles:otherProfiles
|
| + atYOffset:yOffset
|
| + inContainer:container];
|
| + yOffset += kRelatedControllVerticalSpacing;
|
| + rect.origin.y = yOffset;
|
|
|
| NSBox* separator = [self horizontalSeparatorWithFrame:rect];
|
| [container addSubview:separator];
|
| @@ -1495,17 +1473,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
|
|
| // For supervised users, add the disclaimer text.
|
| if (browser_->profile()->IsSupervised()) {
|
| - yOffset += switches::IsMaterialDesignUserMenu() ? kVerticalSpacing
|
| - : kSmallVerticalSpacing;
|
| + yOffset += kVerticalSpacing;
|
| NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView];
|
| [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)];
|
| [container addSubview:disclaimerContainer];
|
| yOffset = NSMaxY([disclaimerContainer frame]);
|
| -
|
| - if (!switches::IsMaterialDesignUserMenu()) {
|
| - yOffset += kSmallVerticalSpacing;
|
| - yOffset = [self addSeparatorToContainer:container atYOffset:yOffset];
|
| - }
|
| }
|
|
|
| if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
|
| @@ -1514,7 +1486,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| if (item.signed_in) {
|
| NSView* currentProfileAccountsView = [self
|
| createCurrentProfileAccountsView:NSMakeRect(0, yOffset,
|
| - GetFixedMenuWidth(), 0)];
|
| + kFixedMenuWidth, 0)];
|
| [container addSubview:currentProfileAccountsView];
|
| yOffset = NSMaxY([currentProfileAccountsView frame]);
|
|
|
| @@ -1529,9 +1501,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
|
|
| // Active profile card.
|
| if (currentProfileView) {
|
| - const CGFloat verticalSpacing = switches::IsMaterialDesignUserMenu()
|
| - ? kRelatedControllVerticalSpacing
|
| - : kVerticalSpacing;
|
| + const CGFloat verticalSpacing = kRelatedControllVerticalSpacing;
|
| yOffset += verticalSpacing;
|
| [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)];
|
| [container addSubview:currentProfileView];
|
| @@ -1554,7 +1524,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
|
| }
|
|
|
| - [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
|
| }
|
|
|
| - (NSView*)buildProfileChooserView {
|
| @@ -1582,15 +1552,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) {
|
| const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i);
|
| if (item.active) {
|
| - if (switches::IsMaterialDesignUserMenu()) {
|
| - syncErrorView = [self buildSyncErrorViewIfNeeded];
|
| - } else if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
|
| - tutorialView = [self buildTutorialViewIfNeededForItem:item];
|
| - }
|
| - currentProfileView =
|
| - switches::IsMaterialDesignUserMenu()
|
| - ? [self createMaterialDesignCurrentProfileView:item]
|
| - : [self createCurrentProfileView:item];
|
| + syncErrorView = [self buildSyncErrorViewIfNeeded];
|
| + currentProfileView = [self createMaterialDesignCurrentProfileView:item];
|
| showLock = item.signed_in &&
|
| profiles::IsLockAvailable(browser_->profile());
|
| } else {
|
| @@ -1606,13 +1569,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| // overlap the bubble's rounded corners.
|
| CGFloat yOffset = 1;
|
|
|
| - if (isFastProfileChooser) {
|
| - if (!switches::IsMaterialDesignUserMenu()) {
|
| - [self buildFastUserSwitcherViewWithProfiles:otherProfiles.get()
|
| - atYOffset:yOffset
|
| - inContainer:container];
|
| - }
|
| - } else {
|
| + if (!isFastProfileChooser) {
|
| [self buildProfileChooserViewWithProfileView:currentProfileView
|
| tutorialView:tutorialView
|
| syncErrorView:syncErrorView
|
| @@ -1678,11 +1635,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT);
|
| // For local profiles, the "Not you" link doesn't make sense.
|
| NSString* linkMessage =
|
| - item.signed_in
|
| - ? ElideMessage(
|
| - l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, item.name),
|
| - GetFixedMenuWidth() - 2 * kHorizontalSpacing)
|
| - : nil;
|
| + item.signed_in ? ElideMessage(l10n_util::GetStringFUTF16(
|
| + IDS_PROFILES_NOT_YOU, item.name),
|
| + kFixedMenuWidth - 2 * kHorizontalSpacing)
|
| + : nil;
|
| NSString* buttonMessage = l10n_util::GetNSString(
|
| IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON);
|
| return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE
|
| @@ -1716,32 +1672,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| buttonAction:@selector(dismissTutorial:)];
|
| }
|
|
|
| -- (NSView*)buildTutorialViewIfNeededForItem:(const AvatarMenu::Item&)item {
|
| - if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN)
|
| - return [self buildSigninConfirmationView];
|
| -
|
| - if (tutorialMode_ == profiles::TUTORIAL_MODE_SHOW_ERROR)
|
| - return [self buildSigninErrorView];
|
| -
|
| - if (profiles::ShouldShowWelcomeUpgradeTutorial(
|
| - browser_->profile(), tutorialMode_)) {
|
| - if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
|
| - Profile* profile = browser_->profile();
|
| - const int showCount = profile->GetPrefs()->GetInteger(
|
| - prefs::kProfileAvatarTutorialShown);
|
| - profile->GetPrefs()->SetInteger(
|
| - prefs::kProfileAvatarTutorialShown, showCount + 1);
|
| - }
|
| -
|
| - return [self buildWelcomeUpgradeTutorialView:item];
|
| - }
|
| -
|
| - if (profiles::ShouldShowRightClickTutorial(browser_->profile()))
|
| - return [self buildRightClickTutorialView];
|
| -
|
| - return nil;
|
| -}
|
| -
|
| - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode
|
| titleMessage:(NSString*)titleMessage
|
| contentMessage:(NSString*)contentMessage
|
| @@ -1756,9 +1686,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| NSColor* tutorialBackgroundColor =
|
| skia::SkColorToSRGBNSColor(profiles::kAvatarTutorialBackgroundColor);
|
| base::scoped_nsobject<NSView> container([[BackgroundColorView alloc]
|
| - initWithFrame:NSMakeRect(0, 0, GetFixedMenuWidth(), 0)
|
| + initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0)
|
| withColor:tutorialBackgroundColor]);
|
| - CGFloat availableWidth = GetFixedMenuWidth() - 2 * kHorizontalSpacing;
|
| + CGFloat availableWidth = kFixedMenuWidth - 2 * kHorizontalSpacing;
|
| CGFloat yOffset = kVerticalSpacing;
|
|
|
| // Adds links and buttons at the bottom.
|
| @@ -1782,10 +1712,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| }
|
|
|
| if (stackButton) {
|
| - [learnMoreLink
|
| - setFrameOrigin:NSMakePoint((GetFixedMenuWidth() -
|
| - NSWidth([learnMoreLink frame])) / 2,
|
| - yOffset)];
|
| + [learnMoreLink setFrameOrigin:NSMakePoint((kFixedMenuWidth -
|
| + NSWidth([learnMoreLink frame])) /
|
| + 2,
|
| + yOffset)];
|
| [tutorialOkButton setFrameSize:NSMakeSize(
|
| availableWidth, NSHeight([tutorialOkButton frame]))];
|
| [tutorialOkButton setFrameOrigin:NSMakePoint(
|
| @@ -1799,7 +1729,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| buttonSize.width += 2 * kLeftRightTextPadding;
|
| buttonSize.height += 2 * kTopBottomTextPadding;
|
| [tutorialOkButton setFrameSize:buttonSize];
|
| - CGFloat buttonXOffset = GetFixedMenuWidth() -
|
| + CGFloat buttonXOffset = kFixedMenuWidth -
|
| NSWidth([tutorialOkButton frame]) -
|
| kHorizontalSpacing;
|
| [tutorialOkButton setFrameOrigin:NSMakePoint(buttonXOffset, yOffset)];
|
| @@ -1862,7 +1792,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [closeButton setAction:@selector(dismissTutorial:)];
|
| [closeButton setFrameSize:[closeImage size]];
|
| [closeButton
|
| - setFrameOrigin:NSMakePoint(GetFixedMenuWidth() - kHorizontalSpacing -
|
| + setFrameOrigin:NSMakePoint(kFixedMenuWidth - kHorizontalSpacing -
|
| closeImageWidth,
|
| yOffset)];
|
| [container addSubview:closeButton];
|
| @@ -1877,7 +1807,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [container addSubview:titleLabel];
|
| yOffset = NSMaxY([titleLabel frame]) + kVerticalSpacing;
|
|
|
| - [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
|
| [container setFrameOrigin:NSZeroPoint];
|
| return container.autorelease();
|
| }
|
| @@ -1914,10 +1844,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| }
|
|
|
| base::scoped_nsobject<NSView> container(
|
| - [[NSView alloc] initWithFrame:NSMakeRect(0, 0, GetFixedMenuWidth(), 0)]);
|
| + [[NSView alloc] initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0)]);
|
| CGFloat iconSize = 20.0;
|
| CGFloat xOffset = kHorizontalSpacing + iconSize + 12.0;
|
| - CGFloat availableWidth = GetFixedMenuWidth() - xOffset - kHorizontalSpacing;
|
| + CGFloat availableWidth = kFixedMenuWidth - xOffset - kHorizontalSpacing;
|
| CGFloat yOffset = 16.0;
|
|
|
| // Adds an action button for resolving the error at the bottom.
|
| @@ -1966,83 +1896,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [container addSubview:syncProblemIcon];
|
|
|
| [container
|
| - setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset + kVerticalSpacing)];
|
| - return container.autorelease();
|
| -}
|
| -
|
| -- (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item {
|
| - base::scoped_nsobject<NSView> container([[NSView alloc]
|
| - initWithFrame:NSZeroRect]);
|
| -
|
| - CGFloat xOffset = kHorizontalSpacing;
|
| - CGFloat yOffset = 0;
|
| - CGFloat availableTextWidth = GetFixedMenuWidth() - 2 * kHorizontalSpacing;
|
| - CGFloat maxAvailableTextWidth = GetFixedMenuWidth() - kHorizontalSpacing;
|
| -
|
| - // Profile options. This can be a link to the accounts view, the profile's
|
| - // username for signed in users, or a "Sign in" button for local profiles.
|
| - SigninManagerBase* signinManager =
|
| - SigninManagerFactory::GetForProfile(
|
| - browser_->profile()->GetOriginalProfile());
|
| - if (!isGuestSession_ && signinManager->IsSigninAllowed()) {
|
| - NSView* linksContainer = [self
|
| - createCurrentProfileLinksForItem:item
|
| - rect:NSMakeRect(xOffset, yOffset,
|
| - maxAvailableTextWidth, 0)];
|
| - [container addSubview:linksContainer];
|
| - yOffset = NSMaxY([linksContainer frame]);
|
| - }
|
| -
|
| - // Profile name, centered.
|
| - bool editingAllowed = !isGuestSession_ &&
|
| - !browser_->profile()->IsLegacySupervised();
|
| - base::scoped_nsobject<EditableProfileNameButton> profileName(
|
| - [[EditableProfileNameButton alloc]
|
| - initWithFrame:NSMakeRect(xOffset,
|
| - yOffset,
|
| - availableTextWidth,
|
| - kProfileButtonHeight)
|
| - profile:browser_->profile()
|
| - profileName:base::SysUTF16ToNSString(
|
| - profiles::GetAvatarNameForProfile(
|
| - browser_->profile()->GetPath()))
|
| - editingAllowed:editingAllowed
|
| - withController:self]);
|
| -
|
| - [container addSubview:profileName];
|
| - yOffset = NSMaxY([profileName frame]) + 4; // Adds a small vertical padding.
|
| -
|
| - // Profile icon, centered.
|
| - xOffset = (GetFixedMenuWidth() - kLargeImageSide) / 2;
|
| - base::scoped_nsobject<EditableProfilePhoto> iconView(
|
| - [[EditableProfilePhoto alloc]
|
| - initWithFrame:NSMakeRect(xOffset, yOffset,
|
| - kLargeImageSide, kLargeImageSide)
|
| - avatarMenu:avatarMenu_.get()
|
| - profileIcon:item.icon
|
| - editingAllowed:!isGuestSession_
|
| - withController:self]);
|
| -
|
| - [container addSubview:iconView];
|
| - yOffset = NSMaxY([iconView frame]);
|
| -
|
| - if (browser_->profile()->IsSupervised()) {
|
| - base::scoped_nsobject<NSImageView> supervisedIcon(
|
| - [[NSImageView alloc] initWithFrame:NSZeroRect]);
|
| - 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 parentFrame = [iconView frame];
|
| - [supervisedIcon setFrameOrigin:NSMakePoint(NSMaxX(parentFrame) - size.width,
|
| - NSMinY(parentFrame))];
|
| - [container addSubview:supervisedIcon];
|
| - }
|
| -
|
| - [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| + setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset + kVerticalSpacing)];
|
| return container.autorelease();
|
| }
|
|
|
| @@ -2055,8 +1909,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| CGFloat yOffset = 0.0;
|
| CGFloat cardYOffset = kRelatedControllVerticalSpacing;
|
| CGFloat availableTextWidth =
|
| - GetFixedMenuWidth() - 3.0 * kHorizontalSpacing - kMdImageSide;
|
| - CGFloat maxAvailableTextWidth = GetFixedMenuWidth() - kHorizontalSpacing;
|
| + kFixedMenuWidth - 3.0 * kHorizontalSpacing - kMdImageSide;
|
| + CGFloat maxAvailableTextWidth = kFixedMenuWidth - kHorizontalSpacing;
|
|
|
| // Profile options. This can be a link to the accounts view, or a "Sign in"
|
| // button for local profiles.
|
| @@ -2064,7 +1918,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| browser_->profile()->GetOriginalProfile());
|
| NSRect profileLinksBound = NSZeroRect;
|
| if (item.signed_in && switches::IsEnableAccountConsistency()) {
|
| - profileLinksBound = NSMakeRect(0, 0, GetFixedMenuWidth(), kVerticalSpacing);
|
| + profileLinksBound = NSMakeRect(0, 0, kFixedMenuWidth, kVerticalSpacing);
|
| } else if (!item.signed_in && signinManager->IsSigninAllowed()) {
|
| profileLinksBound = NSMakeRect(xOffset, kRelatedControllVerticalSpacing,
|
| maxAvailableTextWidth, kVerticalSpacing);
|
| @@ -2079,8 +1933,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| // Profile card button that contains the profile icon, name, and username.
|
| const base::string16 profileNameString =
|
| profiles::GetAvatarNameForProfile(browser_->profile()->GetPath());
|
| - NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(),
|
| - kMdImageSide + kVerticalSpacing);
|
| + NSRect rect =
|
| + NSMakeRect(0, yOffset, kFixedMenuWidth, kMdImageSide + kVerticalSpacing);
|
| NSButton* profileCard =
|
| [self hoverButtonWithRect:rect
|
| text:[[NSString alloc] init]
|
| @@ -2179,21 +2033,19 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| }
|
|
|
| yOffset = NSMaxY([profileCard frame]);
|
| - [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
|
| return container.autorelease();
|
| }
|
|
|
| - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item
|
| rect:(NSRect)rect {
|
| - if (switches::IsMaterialDesignUserMenu()) {
|
| - // The branch is empty for material design user menu in non-account-
|
| - // consistency mode, because in that case, the username would appear in the
|
| - // profile card instead of as a separate link here.
|
| - SigninManagerBase* signinManager = SigninManagerFactory::GetForProfile(
|
| - browser_->profile()->GetOriginalProfile());
|
| - DCHECK((item.signed_in && switches::IsEnableAccountConsistency()) ||
|
| - (!item.signed_in && signinManager->IsSigninAllowed()));
|
| - }
|
| + // The branch is empty in non-account-consistency mode, because in that case,
|
| + // the username would appear in the profile card instead of as a separate link
|
| + // here.
|
| + SigninManagerBase* signinManager = SigninManagerFactory::GetForProfile(
|
| + browser_->profile()->GetOriginalProfile());
|
| + DCHECK((item.signed_in && switches::IsEnableAccountConsistency()) ||
|
| + (!item.signed_in && signinManager->IsSigninAllowed()));
|
|
|
| base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]);
|
|
|
| @@ -2215,48 +2067,17 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| SEL linkSelector =
|
| (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) ?
|
| @selector(showAccountManagement:) : @selector(hideAccountManagement:);
|
| - if (switches::IsMaterialDesignUserMenu()) {
|
| - rect.size.width +=
|
| - kRightPadding; // Spans the width of the entire menu.
|
| - link = [self hoverButtonWithRect:NSMakeRect(0, 0, rect.size.width,
|
| - kBlueButtonHeight)
|
| - text:linkTitle
|
| - action:linkSelector];
|
| - } else {
|
| - link = [self linkButtonWithTitle:linkTitle
|
| - frameOrigin:rect.origin
|
| - action:linkSelector];
|
| - }
|
| - } else if (!switches::IsMaterialDesignUserMenu()) {
|
| - link = [self linkButtonWithTitle:base::SysUTF16ToNSString(item.username)
|
| - frameOrigin:rect.origin
|
| - action:nil];
|
| - if (HasAuthError(browser_->profile())) {
|
| - [link setImage:ui::ResourceBundle::GetSharedInstance().
|
| - GetNativeImageNamed(IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).
|
| - ToNSImage()];
|
| - [link setImagePosition:NSImageRight];
|
| - [link setTarget:self];
|
| - [link setAction:@selector(showAccountReauthenticationView:)];
|
| - [link setTag:kPrimaryProfileTag];
|
| - [[link cell]
|
| - accessibilitySetOverrideValue:l10n_util::GetNSStringF(
|
| - IDS_PROFILES_ACCOUNT_BUTTON_AUTH_ERROR_ACCESSIBLE_NAME,
|
| - item.username)
|
| - forAttribute:NSAccessibilityTitleAttribute];
|
| - } else {
|
| - // Signed in profiles with no authentication errors do not have a
|
| - // clickable email link.
|
| - [link setEnabled:NO];
|
| - }
|
| + rect.size.width += kRightPadding; // Spans the width of the entire menu.
|
| + link = [self hoverButtonWithRect:NSMakeRect(0, 0, rect.size.width,
|
| + kBlueButtonHeight)
|
| + text:linkTitle
|
| + action:linkSelector];
|
| }
|
| if (link) {
|
| // -linkButtonWithTitle sizeToFit's the link. We can use the height, but
|
| // need to re-stretch the width so that the link can be centered correctly
|
| // in the view.
|
| rect.size.height = [link frame].size.height;
|
| - if (!switches::IsMaterialDesignUserMenu())
|
| - [link setAlignment:NSCenterTextAlignment];
|
| [link setFrame:rect];
|
| [container addSubview:link];
|
| [container setFrameSize:rect.size];
|
| @@ -2275,8 +2096,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| gfx::FontList(), rect.size.width, gfx::ELIDE_TAIL));
|
|
|
| [signinButton setTitle:elidedButtonText];
|
| - if (switches::IsMaterialDesignUserMenu())
|
| - [signinButton sizeToFit];
|
| + [signinButton sizeToFit];
|
| [signinButton setTarget:self];
|
| [signinButton setAction:@selector(showInlineSigninPage:)];
|
| [container addSubview:signinButton];
|
| @@ -2293,12 +2113,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:promo];
|
| [container addSubview:promo];
|
|
|
| - [container
|
| - setFrameSize:NSMakeSize(rect.size.width,
|
| - NSMaxY([promo frame]) +
|
| - (switches::IsMaterialDesignUserMenu()
|
| - ? kRelatedControllVerticalSpacing
|
| - : 4))];
|
| + [container setFrameSize:NSMakeSize(rect.size.width,
|
| + NSMaxY([promo frame]) +
|
| + kRelatedControllVerticalSpacing)];
|
| content::RecordAction(
|
| base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
|
| }
|
| @@ -2311,7 +2128,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [[NSView alloc] initWithFrame:NSZeroRect]);
|
|
|
| int yOffset = 0;
|
| - int availableTextWidth = GetFixedMenuWidth() - 2 * kHorizontalSpacing;
|
| + int availableTextWidth = kFixedMenuWidth - 2 * kHorizontalSpacing;
|
|
|
| NSTextField* disclaimer = BuildLabel(
|
| base::SysUTF16ToNSString(avatarMenu_->GetSupervisedUserInformation()),
|
| @@ -2321,7 +2138,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| yOffset = NSMaxY([disclaimer frame]);
|
|
|
| [container addSubview:disclaimer];
|
| - [container setFrameSize:NSMakeSize(GetFixedMenuWidth(), yOffset)];
|
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
|
| return container.autorelease();
|
| }
|
|
|
| @@ -2336,48 +2153,31 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| guestItem.name = base::SysNSStringToUTF16(
|
| l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME));
|
|
|
| - return switches::IsMaterialDesignUserMenu()
|
| - ? [self createMaterialDesignCurrentProfileView:guestItem]
|
| - : [self createCurrentProfileView:guestItem];
|
| + return [self createMaterialDesignCurrentProfileView:guestItem];
|
| }
|
|
|
| - (NSButton*)createOtherProfileView:(int)itemIndex {
|
| const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex);
|
|
|
| - NSRect rect = NSMakeRect(0, 0, GetFixedMenuWidth(),
|
| + NSRect rect = NSMakeRect(0, 0, kFixedMenuWidth,
|
| kBlueButtonHeight + kSmallVerticalSpacing);
|
| - const int imageTitleSpacing = switches::IsMaterialDesignUserMenu()
|
| - ? kHorizontalSpacing
|
| - : kImageTitleSpacing;
|
| + const int imageTitleSpacing = kHorizontalSpacing;
|
| base::scoped_nsobject<BackgroundColorHoverButton> profileButton(
|
| [[BackgroundColorHoverButton alloc]
|
| initWithFrame:rect
|
| imageTitleSpacing:imageTitleSpacing
|
| backgroundColor:GetDialogBackgroundColor()]);
|
| - if (switches::IsMaterialDesignUserMenu())
|
| - [profileButton setRightMarginSpacing:kHorizontalSpacing];
|
| + [profileButton setRightMarginSpacing:kHorizontalSpacing];
|
|
|
| NSString* title = base::SysUTF16ToNSString(
|
| profiles::GetProfileSwitcherTextForItem(item));
|
| [profileButton setTitle:title];
|
|
|
| CGFloat availableWidth;
|
| - if (switches::IsMaterialDesignUserMenu()) {
|
| - int iconImageSide = 18;
|
| - [profileButton setDefaultImage:CreateProfileImage(item.icon, iconImageSide,
|
| - profiles::SHAPE_CIRCLE)];
|
| - availableWidth = rect.size.width - iconImageSide - imageTitleSpacing -
|
| - 2 * kHorizontalSpacing;
|
| - } else {
|
| - // Use the low-res, small default avatars in the fast user switcher, like
|
| - // we do in the menu bar.
|
| - gfx::Image itemIcon;
|
| - AvatarMenu::GetImageForMenuButton(item.profile_path, &itemIcon);
|
| - [profileButton setDefaultImage:CreateProfileImage(itemIcon, kSmallImageSide,
|
| - profiles::SHAPE_SQUARE)];
|
| - availableWidth = rect.size.width - kSmallImageSide - imageTitleSpacing -
|
| - kHorizontalSpacing;
|
| - }
|
| + [profileButton setDefaultImage:CreateProfileImage(item.icon, kIconImageSide,
|
| + profiles::SHAPE_CIRCLE)];
|
| + availableWidth = rect.size.width - kIconImageSide - imageTitleSpacing -
|
| + 2 * kHorizontalSpacing;
|
|
|
| [profileButton setImagePosition:NSImageLeft];
|
| [profileButton setAlignment:NSLeftTextAlignment];
|
| @@ -2386,70 +2186,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| [profileButton setTarget:self];
|
| [profileButton setAction:@selector(switchToProfile:)];
|
|
|
| - NSSize textSize = [[profileButton title] sizeWithAttributes:@{
|
| - NSFontAttributeName : [profileButton font]
|
| - }];
|
| -
|
| - if (!switches::IsMaterialDesignUserMenu() &&
|
| - std::ceil(textSize.width) > availableWidth)
|
| - [profileButton setToolTip:[profileButton title]];
|
| -
|
| return profileButton.autorelease();
|
| }
|
|
|
| -- (NSView*)createOptionsViewWithRect:(NSRect)rect
|
| - showLock:(BOOL)showLock {
|
| - NSRect viewRect = NSMakeRect(0, 0,
|
| - rect.size.width,
|
| - kBlueButtonHeight + kSmallVerticalSpacing);
|
| - base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]);
|
| -
|
| - if (showLock) {
|
| - NSButton* lockButton =
|
| - [self hoverButtonWithRect:viewRect
|
| - text:l10n_util::GetNSString(
|
| - IDS_PROFILES_PROFILE_SIGNOUT_BUTTON)
|
| - imageResourceId:IDR_ICON_PROFILES_MENU_LOCK
|
| - action:@selector(lockProfile:)];
|
| - [container addSubview:lockButton];
|
| - viewRect.origin.y = NSMaxY([lockButton frame]);
|
| -
|
| - NSBox* separator = [self horizontalSeparatorWithFrame:viewRect];
|
| - [container addSubview:separator];
|
| - viewRect.origin.y = NSMaxY([separator frame]);
|
| - }
|
| -
|
| - if ([self shouldShowGoIncognito]) {
|
| - NSButton* goIncognitoButton =
|
| - [self hoverButtonWithRect:viewRect
|
| - text:l10n_util::GetNSString(
|
| - IDS_PROFILES_GO_INCOGNITO_BUTTON)
|
| - imageResourceId:IDR_ICON_PROFILES_MENU_INCOGNITO
|
| - action:@selector(goIncognito:)];
|
| - viewRect.origin.y = NSMaxY([goIncognitoButton frame]);
|
| - [container addSubview:goIncognitoButton];
|
| -
|
| - NSBox* separator = [self horizontalSeparatorWithFrame:viewRect];
|
| - [container addSubview:separator];
|
| - viewRect.origin.y = NSMaxY([separator frame]);
|
| - }
|
| -
|
| - NSString* text = isGuestSession_ ?
|
| - l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) :
|
| - l10n_util::GetNSString(IDS_PROFILES_SWITCH_USERS_BUTTON);
|
| - NSButton* switchUsersButton =
|
| - [self hoverButtonWithRect:viewRect
|
| - text:text
|
| - imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
|
| - action:isGuestSession_? @selector(exitGuest:) :
|
| - @selector(showUserManager:)];
|
| - viewRect.origin.y = NSMaxY([switchUsersButton frame]);
|
| - [container addSubview:switchUsersButton];
|
| -
|
| - [container setFrameSize:NSMakeSize(rect.size.width, viewRect.origin.y)];
|
| - return container.autorelease();
|
| -}
|
| -
|
| - (NSView*)createCurrentProfileAccountsView:(NSRect)rect {
|
| const CGFloat kAccountButtonHeight = 34;
|
|
|
| @@ -2851,9 +2590,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
|
| base::scoped_nsobject<BackgroundColorHoverButton> button(
|
| [[BackgroundColorHoverButton alloc]
|
| initWithFrame:rect
|
| - imageTitleSpacing:switches::IsMaterialDesignUserMenu()
|
| - ? md_image_title_spacing
|
| - : kImageTitleSpacing
|
| + imageTitleSpacing:md_image_title_spacing
|
| backgroundColor:GetDialogBackgroundColor()]);
|
|
|
| [button setTitle:text];
|
|
|