Chromium Code Reviews| 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 29afe4656c062367f0de181eae0430a6f5dd7c9a..8b8cd78fbcee56301d90dd745a5c36cf6e183c5f 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
| @@ -875,6 +875,18 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| @end |
| @interface ProfileChooserController () |
| +// Builds the right-click profile switcher. |
| +- (void)buildFastUserSwitcherViewWithProfiles:(NSMutableArray*)otherProfiles |
| + atYOffset:(CGFloat)yOffset |
| + inContainer:(NSView*)container; |
| + |
| +// Builds the regular profile chooser view. |
| +- (void)buildProfileChooserViewWithProfileView:(NSView*)currentProfileView |
| + tutorialView:(NSView*)tutorialView |
| + atYOffset:(CGFloat)yOffset |
| + inContainer:(NSView*)container |
| + displayLock:(bool)displayLock; |
| + |
| // Builds the profile chooser view. |
| - (NSView*)buildProfileChooserView; |
| @@ -1258,6 +1270,91 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); |
| } |
| +// Builds the fast user switcher view in |container| at |yOffset| and populates |
| +// it with the entries for every profile in |otherProfiles|. Returns the new |
| +// yOffset after adding the elements. |
| +- (void)buildFastUserSwitcherViewWithProfiles:(NSMutableArray*)otherProfiles |
| + atYOffset:(CGFloat)yOffset |
| + inContainer:(NSView*)container { |
| + // Other profiles switcher. The profiles have already been sorted |
| + // by their y-coordinate, so they can be added in the existing order. |
| + for (NSView *otherProfileView in otherProfiles) { |
|
Alexei Svitkine (slow)
2015/05/15 14:45:32
Nit: Space should go after the *, not before it.
anthonyvd
2015/05/19 20:56:03
Done.
|
| + [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| + [container addSubview:otherProfileView]; |
| + yOffset = NSMaxY([otherProfileView frame]); |
| + |
| + NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
| + 0, yOffset, kFixedMenuWidth, 0)]; |
| + [container addSubview:separator]; |
| + yOffset = NSMaxY([separator frame]); |
| + } |
| + |
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| +} |
| + |
| +- (void)buildProfileChooserViewWithProfileView:(NSView*)currentProfileView |
| + tutorialView:(NSView*)tutorialView |
| + atYOffset:(CGFloat)yOffset |
| + inContainer:(NSView*)container |
| + displayLock:(bool)displayLock { |
| + // Option buttons. |
| + NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); |
| + NSView* optionsView = [self createOptionsViewWithRect:rect |
| + displayLock:displayLock]; |
| + [container addSubview:optionsView]; |
| + rect.origin.y = NSMaxY([optionsView frame]); |
| + |
| + NSBox* separator = [self horizontalSeparatorWithFrame:rect]; |
| + [container addSubview:separator]; |
| + yOffset = NSMaxY([separator frame]); |
| + |
| + // For supervised users, add the disclaimer text. |
| + if (browser_->profile()->IsSupervised()) { |
| + yOffset += kSmallVerticalSpacing; |
| + NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView]; |
| + [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)]; |
| + [container addSubview:disclaimerContainer]; |
| + yOffset = NSMaxY([disclaimerContainer frame]); |
| + yOffset += kSmallVerticalSpacing; |
| + |
| + NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
| + 0, yOffset, kFixedMenuWidth, 0)]; |
|
Alexei Svitkine (slow)
2015/05/15 14:45:32
Nit: Make a helper function for this, since you re
anthonyvd
2015/05/19 20:56:04
Done.
|
| + [container addSubview:separator]; |
| + yOffset = NSMaxY([separator frame]); |
| + } |
| + |
| + if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
| + NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView: |
| + NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| + [container addSubview:currentProfileAccountsView]; |
| + yOffset = NSMaxY([currentProfileAccountsView frame]); |
| + |
| + NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: |
| + NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| + [container addSubview:accountsSeparator]; |
| + yOffset = NSMaxY([accountsSeparator frame]); |
| + } |
| + |
| + // Active profile card. |
| + if (currentProfileView) { |
| + yOffset += kVerticalSpacing; |
| + [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| + [container addSubview:currentProfileView]; |
| + yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
| + } |
| + |
| + if (tutorialView) { |
| + [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| + [container addSubview:tutorialView]; |
| + yOffset = NSMaxY([tutorialView frame]); |
| + //TODO(mlerman): update UMA stats for the new tutorials. |
| + } else { |
| + tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| + } |
| + |
| + [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| +} |
| + |
| - (NSView*)buildProfileChooserView { |
| base::scoped_nsobject<NSView> container( |
| [[NSView alloc] initWithFrame:NSZeroRect]); |
| @@ -1305,80 +1402,18 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
| // overlap the bubble's rounded corners. |
| CGFloat yOffset = 1; |
| - if (!isFastProfileChooser) { |
| - // Option buttons. |
| - NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); |
| - NSView* optionsView = [self createOptionsViewWithRect:rect |
| - displayLock:displayLock]; |
| - [container addSubview:optionsView]; |
| - rect.origin.y = NSMaxY([optionsView frame]); |
| - |
| - NSBox* separator = [self horizontalSeparatorWithFrame:rect]; |
| - [container addSubview:separator]; |
| - yOffset = NSMaxY([separator frame]); |
| - } |
| - |
| - if ((viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
| - switches::IsFastUserSwitching()) || isFastProfileChooser) { |
| - // Other profiles switcher. The profiles have already been sorted |
| - // by their y-coordinate, so they can be added in the existing order. |
| - for (NSView *otherProfileView in otherProfiles.get()) { |
| - [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| - [container addSubview:otherProfileView]; |
| - yOffset = NSMaxY([otherProfileView frame]); |
| - |
| - NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
| - 0, yOffset, kFixedMenuWidth, 0)]; |
| - [container addSubview:separator]; |
| - yOffset = NSMaxY([separator frame]); |
| - } |
| - } |
| - |
| - // For supervised users, add the disclaimer text. |
| - if (browser_->profile()->IsSupervised()) { |
| - yOffset += kSmallVerticalSpacing; |
| - NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView]; |
| - [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)]; |
| - [container addSubview:disclaimerContainer]; |
| - yOffset = NSMaxY([disclaimerContainer frame]); |
| - yOffset += kSmallVerticalSpacing; |
| - |
| - NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
| - 0, yOffset, kFixedMenuWidth, 0)]; |
| - [container addSubview:separator]; |
| - yOffset = NSMaxY([separator frame]); |
| - } |
| - |
| - if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
| - NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView: |
| - NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| - [container addSubview:currentProfileAccountsView]; |
| - yOffset = NSMaxY([currentProfileAccountsView frame]); |
| - |
| - NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: |
| - NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| - [container addSubview:accountsSeparator]; |
| - yOffset = NSMaxY([accountsSeparator frame]); |
| - } |
| - |
| - // Active profile card. |
| - if (!isFastProfileChooser && currentProfileView) { |
| - yOffset += kVerticalSpacing; |
| - [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| - [container addSubview:currentProfileView]; |
| - yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
| - } |
| - |
| - if (!isFastProfileChooser && tutorialView) { |
| - [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| - [container addSubview:tutorialView]; |
| - yOffset = NSMaxY([tutorialView frame]); |
| - //TODO(mlerman): update UMA stats for the new tutorials. |
| + if (isFastProfileChooser) { |
| + [self buildFastUserSwitcherViewWithProfiles:otherProfiles.get() |
| + atYOffset:yOffset |
| + inContainer:container.get()]; |
| } else { |
| - tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| + [self buildProfileChooserViewWithProfileView:currentProfileView |
| + tutorialView:tutorialView |
| + atYOffset:yOffset |
| + inContainer:container.get() |
| + displayLock:displayLock]; |
| } |
| - [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| return container.autorelease(); |
| } |