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

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: Add unit test. 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
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // Set left indentation based on fullscreen mode status. 335 // Set left indentation based on fullscreen mode status.
336 [tabStripController_ setLeftIndentForControls:(fullscreen ? 0 : 336 [tabStripController_ setLeftIndentForControls:(fullscreen ? 0 :
337 [[tabStripController_ class] defaultLeftIndentForControls])]; 337 [[tabStripController_ class] defaultLeftIndentForControls])];
338 338
339 // Lay out the icognito/avatar badge because calculating the indentation on 339 // Lay out the icognito/avatar badge because calculating the indentation on
340 // the right depends on it. 340 // the right depends on it.
341 if ([self shouldShowAvatar]) { 341 if ([self shouldShowAvatar]) {
342 NSView* avatarButton = [avatarButtonController_ view]; 342 NSView* avatarButton = [avatarButtonController_ view];
343 CGFloat buttonHeight = std::min( 343 CGFloat buttonHeight = std::min(
344 static_cast<CGFloat>(profiles::kAvatarIconHeight), tabStripHeight); 344 static_cast<CGFloat>(profiles::kAvatarIconHeight), tabStripHeight);
345 [avatarButton setFrameSize:NSMakeSize(profiles::kAvatarIconWidth, 345 [avatarButton setFrameSize:NSMakeSize(NSWidth([avatarButton frame]),
346 buttonHeight)]; 346 buttonHeight)];
347 347
348 // Actually place the badge *above* |maxY|, by +2 to miss the divider. 348 // Actually place the badge *above* |maxY|, by +2 to miss the divider.
349 CGFloat badgeXOffset = -kAvatarRightOffset; 349 CGFloat badgeXOffset = -kAvatarRightOffset;
350 CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth]; 350 CGFloat badgeYOffset = 2 * [[avatarButton superview] cr_lineWidth];
351 NSPoint origin = 351 NSPoint origin =
352 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset, 352 NSMakePoint(width - NSWidth([avatarButton frame]) + badgeXOffset,
353 maxY + badgeYOffset); 353 maxY + badgeYOffset);
354 [avatarButton setFrameOrigin:origin]; 354 [avatarButton setFrameOrigin:origin];
355 [avatarButton setHidden:NO]; // Make sure it's shown. 355 [avatarButton setHidden:NO]; // Make sure it's shown.
356 } 356 }
357 357
358 // Calculate the right indentation. The default indentation built into the 358 // Calculate the right indentation. The default indentation built into the
359 // tabstrip leaves enough room for the fullscreen button or presentation mode 359 // tabstrip leaves enough room for the fullscreen button or presentation mode
360 // toggle button on Lion. On non-Lion systems, the right indent needs to be 360 // toggle button on Lion. On non-Lion systems, the right indent needs to be
361 // adjusted to make room for the new tab button when an avatar is present. 361 // adjusted to make room for the new tab button when an avatar is present.
362 CGFloat rightIndent = 0; 362 CGFloat rightIndent = 0;
363 if (base::mac::IsOSLionOrLater()) { 363 if (base::mac::IsOSLionOrLater()) {
364 FramedBrowserWindow* window = 364 FramedBrowserWindow* window =
365 static_cast<FramedBrowserWindow*>([self window]); 365 static_cast<FramedBrowserWindow*>([self window]);
366 DCHECK([window isKindOfClass:[FramedBrowserWindow class]]); 366 DCHECK([window isKindOfClass:[FramedBrowserWindow class]]);
367 rightIndent += -[window fullScreenButtonOriginAdjustment].x; 367 rightIndent += -[window fullScreenButtonOriginAdjustment].x;
368 } else if ([self shouldShowAvatar]) { 368 } else if ([self shouldShowAvatar]) {
369 rightIndent += kAvatarTabStripShrink; 369 rightIndent += kAvatarTabStripShrink;
370 if ([avatarButtonController_ labelView]) {
371 rightIndent += NSWidth([[avatarButtonController_ labelView] frame]) +
372 kAvatarRightOffset;
373 }
370 } 374 }
371 [tabStripController_ setRightIndentForControls:rightIndent]; 375 [tabStripController_ setRightIndentForControls:rightIndent];
372 376
373 // Go ahead and layout the tabs. 377 // Go ahead and layout the tabs.
374 [tabStripController_ layoutTabsWithoutAnimation]; 378 [tabStripController_ layoutTabsWithoutAnimation];
375 379
376 return maxY; 380 return maxY;
377 } 381 }
378 382
379 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX 383 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1035
1032 - (void)updateAllowOverlappingViews:(BOOL)inPresentationMode { 1036 - (void)updateAllowOverlappingViews:(BOOL)inPresentationMode {
1033 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 1037 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
1034 if (!contents) 1038 if (!contents)
1035 return; 1039 return;
1036 contents->GetView()->SetAllowOverlappingViews( 1040 contents->GetView()->SetAllowOverlappingViews(
1037 [self shouldAllowOverlappingViews:inPresentationMode]); 1041 [self shouldAllowOverlappingViews:inPresentationMode]);
1038 } 1042 }
1039 1043
1040 @end // @implementation BrowserWindowController(Private) 1044 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698