Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 15932008: Add managed user avatar menu for mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #import "base/memory/scoped_nsobject.h" 10 #import "base/memory/scoped_nsobject.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 buttonHeight)]; 345 buttonHeight)];
346 346
347 // Actually place the badge *above* |maxY|, by +2 to miss the divider. 347 // Actually place the badge *above* |maxY|, by +2 to miss the divider.
348 CGFloat badgeXOffset = -kAvatarRightOffset; 348 CGFloat badgeXOffset = -kAvatarRightOffset;
349 CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth]; 349 CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth];
350 NSPoint origin = 350 NSPoint origin =
351 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset, 351 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset,
352 maxY + badgeYOffset); 352 maxY + badgeYOffset);
353 [avatarButton setFrameOrigin:origin]; 353 [avatarButton setFrameOrigin:origin];
354 [avatarButton setHidden:NO]; // Make sure it's shown. 354 [avatarButton setHidden:NO]; // Make sure it's shown.
355
356 NSTextField* avatarLabel = [avatarButtonController_ labelView];
357 if (avatarLabel) {
358 CGFloat labelHeight = NSHeight([avatarLabel frame]);
359 origin =
360 NSMakePoint(origin.x - NSWidth([avatarLabel frame]) + badgeXOffset,
361 maxY + badgeYOffset + (buttonHeight - labelHeight) / 2);
362 [avatarLabel setFrameOrigin:origin];
363 [avatarLabel setHidden:NO];
364 }
355 } 365 }
356 366
357 // Calculate the right indentation. The default indentation built into the 367 // Calculate the right indentation. The default indentation built into the
358 // tabstrip leaves enough room for the fullscreen button or presentation mode 368 // tabstrip leaves enough room for the fullscreen button or presentation mode
359 // toggle button on Lion. On non-Lion systems, the right indent needs to be 369 // toggle button on Lion. On non-Lion systems, the right indent needs to be
360 // adjusted to make room for the new tab button when an avatar is present. 370 // adjusted to make room for the new tab button when an avatar is present.
361 CGFloat rightIndent = 0; 371 CGFloat rightIndent = 0;
362 if (base::mac::IsOSLionOrLater()) { 372 if (base::mac::IsOSLionOrLater()) {
363 FramedBrowserWindow* window = 373 FramedBrowserWindow* window =
364 static_cast<FramedBrowserWindow*>([self window]); 374 static_cast<FramedBrowserWindow*>([self window]);
365 DCHECK([window isKindOfClass:[FramedBrowserWindow class]]); 375 DCHECK([window isKindOfClass:[FramedBrowserWindow class]]);
366 rightIndent += -[window fullScreenButtonOriginAdjustment].x; 376 rightIndent += -[window fullScreenButtonOriginAdjustment].x;
367 } else if ([self shouldShowAvatar]) { 377 } else if ([self shouldShowAvatar]) {
368 rightIndent += kAvatarTabStripShrink; 378 rightIndent += kAvatarTabStripShrink;
379 if ([avatarButtonController_ labelView]) {
380 rightIndent += NSWidth([[avatarButtonController_ labelView] frame]) +
381 kAvatarRightOffset;
382 }
369 } 383 }
370 [tabStripController_ setRightIndentForControls:rightIndent]; 384 [tabStripController_ setRightIndentForControls:rightIndent];
371 385
372 // Go ahead and layout the tabs. 386 // Go ahead and layout the tabs.
373 [tabStripController_ layoutTabsWithoutAnimation]; 387 [tabStripController_ layoutTabsWithoutAnimation];
374 388
375 return maxY; 389 return maxY;
376 } 390 }
377 391
378 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX 392 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt. 594 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt.
581 [contentView setAutoresizesSubviews:YES]; 595 [contentView setAutoresizesSubviews:YES];
582 [destWindow setContentView:contentView]; 596 [destWindow setContentView:contentView];
583 597
584 // Move the incognito badge if present. 598 // Move the incognito badge if present.
585 if ([self shouldShowAvatar]) { 599 if ([self shouldShowAvatar]) {
586 [[avatarButtonController_ view] removeFromSuperview]; 600 [[avatarButtonController_ view] removeFromSuperview];
587 [[avatarButtonController_ view] setHidden:YES]; // Will be shown in layout. 601 [[avatarButtonController_ view] setHidden:YES]; // Will be shown in layout.
588 [[[destWindow contentView] superview] addSubview: 602 [[[destWindow contentView] superview] addSubview:
589 [avatarButtonController_ view]]; 603 [avatarButtonController_ view]];
604 if ([avatarButtonController_ labelView]) {
605 [[avatarButtonController_ labelView] removeFromSuperview];
606 [[avatarButtonController_ labelView] setHidden:YES];
607 [[[destWindow contentView] superview]
608 addSubview:[avatarButtonController_ labelView]];
609 }
590 } 610 }
591 611
592 // Add the tab strip after setting the content view and moving the incognito 612 // Add the tab strip after setting the content view and moving the incognito
593 // badge (if any), so that the tab strip will be on top (in the z-order). 613 // badge (if any), so that the tab strip will be on top (in the z-order).
594 if ([self hasTabStrip]) 614 if ([self hasTabStrip])
595 [[[destWindow contentView] superview] addSubview:tabStripView]; 615 [[[destWindow contentView] superview] addSubview:tabStripView];
596 616
597 [sourceWindow setWindowController:nil]; 617 [sourceWindow setWindowController:nil];
598 [self setWindow:destWindow]; 618 [self setWindow:destWindow];
599 [destWindow setWindowController:self]; 619 [destWindow setWindowController:self];
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 relativeTo:[bookmarkBarController_ view]]; 1027 relativeTo:[bookmarkBarController_ view]];
1008 } else { 1028 } else {
1009 [contentView cr_ensureSubview:floatingBarBackingView_ 1029 [contentView cr_ensureSubview:floatingBarBackingView_
1010 isPositioned:NSWindowBelow 1030 isPositioned:NSWindowBelow
1011 relativeTo:[bookmarkBarController_ view]]; 1031 relativeTo:[bookmarkBarController_ view]];
1012 } 1032 }
1013 } 1033 }
1014 } 1034 }
1015 1035
1016 @end // @implementation BrowserWindowController(Private) 1036 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698