| Index: chrome/browser/cocoa/tab_controller.mm | 
| diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm | 
| index c9469e0f37cac3290ed938c9397a07a77f932c64..7569cdaf1681c806a33a2f9bf380e1b35462c705 100644 | 
| --- a/chrome/browser/cocoa/tab_controller.mm | 
| +++ b/chrome/browser/cocoa/tab_controller.mm | 
| @@ -124,7 +124,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { | 
| // titleView_ under those conditions. | 
| NSRect titleFrame = [titleView_ frame]; | 
| iconTitleXOffset_ = NSMinX(titleFrame) - NSMinX(originalIconFrame_); | 
| -  titleCloseWidthOffset_ = NSMaxX([closeButton_ frame]) - NSMaxX(titleFrame); | 
| +  titleCloseWidthOffset_ = NSMinX(originalIconFrame_) - NSMinX([closeButton_ frame]); | 
|  | 
| [self internalSetSelected:selected_]; | 
| } | 
| @@ -171,6 +171,9 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { | 
| - (void)setIconView:(NSView*)iconView { | 
| [iconView_ removeFromSuperview]; | 
| iconView_ = iconView; | 
| + | 
| + | 
| +NSLog(@"original frame: %@", NSStringFromRect(originalIconFrame_)); | 
| [iconView_ setFrame:originalIconFrame_]; | 
|  | 
| // Ensure that the icon is suppressed if no icon is set or if the tab is too | 
| @@ -193,7 +196,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { | 
| // tab. We never actually do this, but it's a helpful guide for determining | 
| // how much space we have available. | 
| - (int)iconCapacity { | 
| -  CGFloat width = NSMaxX([closeButton_ frame]) - NSMinX(originalIconFrame_); | 
| +  CGFloat width = NSMaxX([titleView_ frame]) - NSMinX([closeButton_ frame]); | 
| CGFloat iconWidth = NSWidth(originalIconFrame_); | 
|  | 
| return width / iconWidth; | 
| @@ -242,32 +245,70 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { | 
|  | 
| [closeButton_ setHidden:newShowCloseButton ? NO : YES]; | 
|  | 
| -  // Adjust the title view based on changes to the icon's and close button's | 
| -  // visibility. | 
| -  NSRect titleFrame = [titleView_ frame]; | 
| +  CGFloat overlap = NSMinX([closeButton_ frame]); | 
| +  CGFloat availWidth = NSWidth([[self view] frame]) - 2*overlap; | 
| + | 
| +  if (oldShowCloseButton != newShowCloseButton) { | 
| +    // Adjust the left edge of the title view according to the presence or | 
| +    // absence of the close button. | 
| +    if (newShowCloseButton) { | 
| +      //availWidth -= titleCloseWidthOffset_; | 
| + | 
| +//      titleFrame.origin.x += titleCloseWidthOffset_; | 
| +//      titleFrame.size.width -= titleCloseWidthOffset_; | 
| +    } else { | 
| +//      titleFrame.origin.x -= titleCloseWidthOffset_; | 
| +//      titleFrame.size.width += titleCloseWidthOffset_; | 
| +    } | 
| + | 
| +//    if (newShowCloseButton) { | 
| +//      originalIconFrame_.origin.x += titleCloseWidthOffset_; | 
| +//    } else { | 
| +//      originalIconFrame_.origin.x -= titleCloseWidthOffset_; | 
| +//    } | 
| +//    [iconView_ setFrame:originalIconFrame_]; | 
| +  } | 
|  | 
| if (oldShowIcon != newShowIcon) { | 
| // Adjust the left edge of the title view according to the presence or | 
| // absence of the icon view. | 
|  | 
| if (newShowIcon) { | 
| -      titleFrame.origin.x += iconTitleXOffset_; | 
| -      titleFrame.size.width -= iconTitleXOffset_; | 
| +      //availWidth -= iconTitleXOffset_; | 
| +//      titleFrame.origin.x += iconTitleXOffset_; | 
| +//      titleFrame.size.width -= iconTitleXOffset_; | 
| } else { | 
| -      titleFrame.origin.x -= iconTitleXOffset_; | 
| -      titleFrame.size.width += iconTitleXOffset_; | 
| +//      titleFrame.origin.x -= iconTitleXOffset_; | 
| +//      titleFrame.size.width += iconTitleXOffset_; | 
| } | 
| } | 
|  | 
| -  if (oldShowCloseButton != newShowCloseButton) { | 
| -    // Adjust the right edge of the title view according to the presence or | 
| -    // absence of the close button. | 
| -    if (newShowCloseButton) | 
| -      titleFrame.size.width -= titleCloseWidthOffset_; | 
| -    else | 
| -      titleFrame.size.width += titleCloseWidthOffset_; | 
| + | 
| +  // Adjust the title view based on changes to the icon's and close button's | 
| +  // visibility. | 
| +  [titleView_ sizeToFit]; | 
| +  NSRect titleFrame = [titleView_ frame]; | 
| + | 
| +NSLog(@"r: %@", NSStringFromRect(titleFrame)); | 
| + | 
| + | 
| +  if (NSWidth(titleFrame) + titleCloseWidthOffset_ + iconTitleXOffset_ < availWidth) {  // assume close and icon are always visible for now | 
| +    // center favicon and title | 
| +    CGFloat delta = ((availWidth) - (iconTitleXOffset_ + NSWidth(titleFrame)))/2; | 
| +    originalIconFrame_.origin.x = (overlap) + delta; | 
| +    titleFrame.origin.x = originalIconFrame_.origin.x + iconTitleXOffset_; | 
| +  } else { | 
| +    // left-align favicon and title | 
| +    originalIconFrame_.origin.x = (newShowCloseButton ? NSMinX([closeButton_ frame]) : overlap) + titleCloseWidthOffset_; | 
| +    titleFrame.origin.x = originalIconFrame_.origin.x + iconTitleXOffset_; | 
| +    titleFrame.size.width = availWidth - titleCloseWidthOffset_ - iconTitleXOffset_; | 
| } | 
|  | 
| + | 
| + | 
| +NSLog(@"r: %@", NSStringFromRect(titleFrame)); | 
| + | 
| +  [iconView_ setFrame:originalIconFrame_]; | 
| [titleView_ setFrame:titleFrame]; | 
| } | 
|  | 
|  |