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

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

Issue 8172011: [Mac] Properly show and hide the avatar button for the one-profile case. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 9 years, 2 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') | chrome/chrome_browser.gypi » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/prefs/scoped_user_pref_update.h" 13 #include "chrome/browser/prefs/scoped_user_pref_update.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 15 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #import "chrome/browser/ui/cocoa/browser/avatar_button.h" 17 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
18 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 18 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
19 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 19 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
20 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" 20 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
21 #import "chrome/browser/ui/cocoa/focus_tracker.h" 21 #import "chrome/browser/ui/cocoa/focus_tracker.h"
22 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 22 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
23 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 23 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
24 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 24 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
25 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" 25 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
26 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" 26 #import "chrome/browser/ui/cocoa/status_bubble_mac.h"
27 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h" 27 #import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 CGFloat rightIndent = 0; 349 CGFloat rightIndent = 0;
350 if ([self shouldShowAvatar]) 350 if ([self shouldShowAvatar])
351 rightIndent += (kAvatarTabStripShrink + possibleExtraShiftForLion); 351 rightIndent += (kAvatarTabStripShrink + possibleExtraShiftForLion);
352 [tabStripController_ setRightIndentForControls:rightIndent]; 352 [tabStripController_ setRightIndentForControls:rightIndent];
353 353
354 // Go ahead and layout the tabs. 354 // Go ahead and layout the tabs.
355 [tabStripController_ layoutTabsWithoutAnimation]; 355 [tabStripController_ layoutTabsWithoutAnimation];
356 356
357 // Now lay out incognito badge together with the tab strip. 357 // Now lay out incognito badge together with the tab strip.
358 if (avatarButton_.get()) { 358 if ([self shouldShowAvatar]) {
359 [avatarButton_ setFrameSize:NSMakeSize(tabStripHeight, 359 NSView* avatarButton = [avatarButtonController_ view];
360 tabStripHeight - 5.0)]; 360 [avatarButton setFrameSize:NSMakeSize(tabStripHeight,
361 tabStripHeight - 5.0)];
361 362
362 // Actually place the badge *above* |maxY|, by +2 to miss the divider. On 363 // Actually place the badge *above* |maxY|, by +2 to miss the divider. On
363 // Lion or later, shift the badge left to move it away from the fullscreen 364 // Lion or later, shift the badge left to move it away from the fullscreen
364 // button. 365 // button.
365 CGFloat badgeOffset = kAvatarRightOffset + possibleExtraShiftForLion; 366 CGFloat badgeOffset = kAvatarRightOffset + possibleExtraShiftForLion;
366 NSPoint origin = 367 NSPoint origin =
367 NSMakePoint(width - NSWidth([avatarButton_ frame]) - badgeOffset, 368 NSMakePoint(width - NSWidth([avatarButton frame]) - badgeOffset,
368 maxY + 2); 369 maxY + 2);
369 [avatarButton_ setFrameOrigin:origin]; 370 [avatarButton setFrameOrigin:origin];
370 [avatarButton_ setHidden:NO]; // Make sure it's shown. 371 [avatarButton setHidden:NO]; // Make sure it's shown.
371 } 372 }
372 373
373 return maxY; 374 return maxY;
374 } 375 }
375 376
376 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX 377 - (CGFloat)layoutToolbarAtMinX:(CGFloat)minX
377 maxY:(CGFloat)maxY 378 maxY:(CGFloat)maxY
378 width:(CGFloat)width { 379 width:(CGFloat)width {
379 NSView* toolbarView = [toolbarController_ view]; 380 NSView* toolbarView = [toolbarController_ view];
380 NSRect toolbarFrame = [toolbarView frame]; 381 NSRect toolbarFrame = [toolbarView frame];
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 619
619 // With this call, valgrind complains that a "Conditional jump or move depends 620 // With this call, valgrind complains that a "Conditional jump or move depends
620 // on uninitialised value(s)". The error happens in -[NSThemeFrame 621 // on uninitialised value(s)". The error happens in -[NSThemeFrame
621 // drawOverlayRect:]. I'm pretty convinced this is an Apple bug, but there is 622 // drawOverlayRect:]. I'm pretty convinced this is an Apple bug, but there is
622 // no visual impact. I have been unable to tickle it away with other window 623 // no visual impact. I have been unable to tickle it away with other window
623 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt. 624 // or view manipulation Cocoa calls. Stack added to suppressions_mac.txt.
624 [contentView setAutoresizesSubviews:YES]; 625 [contentView setAutoresizesSubviews:YES];
625 [destWindow setContentView:contentView]; 626 [destWindow setContentView:contentView];
626 627
627 // Move the incognito badge if present. 628 // Move the incognito badge if present.
628 if (avatarButton_.get()) { 629 if ([self shouldShowAvatar]) {
629 [avatarButton_ removeFromSuperview]; 630 [[avatarButtonController_ view] removeFromSuperview];
630 [avatarButton_ setHidden:YES]; // Will be shown in layout. 631 [[avatarButtonController_ view] setHidden:YES]; // Will be shown in layout.
631 [[[destWindow contentView] superview] addSubview:avatarButton_]; 632 [[[destWindow contentView] superview] addSubview:
633 [avatarButtonController_ view]];
632 } 634 }
633 635
634 // Add the tab strip after setting the content view and moving the incognito 636 // Add the tab strip after setting the content view and moving the incognito
635 // badge (if any), so that the tab strip will be on top (in the z-order). 637 // badge (if any), so that the tab strip will be on top (in the z-order).
636 if ([self hasTabStrip]) 638 if ([self hasTabStrip])
637 [[[destWindow contentView] superview] addSubview:tabStripView]; 639 [[[destWindow contentView] superview] addSubview:tabStripView];
638 640
639 [sourceWindow setWindowController:nil]; 641 [sourceWindow setWindowController:nil];
640 [self setWindow:destWindow]; 642 [self setWindow:destWindow];
641 [destWindow setWindowController:self]; 643 [destWindow setWindowController:self];
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 - (void)disableBarVisibilityUpdates { 887 - (void)disableBarVisibilityUpdates {
886 // Early escape if there's nothing to do. 888 // Early escape if there's nothing to do.
887 if (!barVisibilityUpdatesEnabled_) 889 if (!barVisibilityUpdatesEnabled_)
888 return; 890 return;
889 891
890 barVisibilityUpdatesEnabled_ = NO; 892 barVisibilityUpdatesEnabled_ = NO;
891 [presentationModeController_ cancelAnimationAndTimers]; 893 [presentationModeController_ cancelAnimationAndTimers];
892 } 894 }
893 895
894 @end // @implementation BrowserWindowController(Private) 896 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698