summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 20:12:00 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-06 20:12:00 +0000
commit4c466fc30a47516af8d0c26e708d69f5ffb07897 (patch)
tree9223c3bbecc37faaafd43a1f941261f301149f09
parentae64106c168910e52e47709682948b8e0031ce25 (diff)
downloadchromium_src-4c466fc30a47516af8d0c26e708d69f5ffb07897.zip
chromium_src-4c466fc30a47516af8d0c26e708d69f5ffb07897.tar.gz
chromium_src-4c466fc30a47516af8d0c26e708d69f5ffb07897.tar.bz2
[Mac] Remove ProfileMenuButton now that AvatarButton exists.
BUG=88056 TEST=--multi-profiles while signed into sync and you don't get a strange UI. Review URL: http://codereview.chromium.org/7313007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91592 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/nibs/BrowserWindow.xib93
-rw-r--r--chrome/browser/ui/cocoa/profile_menu_button.h44
-rw-r--r--chrome/browser/ui/cocoa/profile_menu_button.mm363
-rw-r--r--chrome/browser/ui/cocoa/profile_menu_button_unittest.mm77
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_strip_controller.h11
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm107
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
8 files changed, 8 insertions, 690 deletions
diff --git a/chrome/app/nibs/BrowserWindow.xib b/chrome/app/nibs/BrowserWindow.xib
index 939ead0..3e8053c 100644
--- a/chrome/app/nibs/BrowserWindow.xib
+++ b/chrome/app/nibs/BrowserWindow.xib
@@ -12,8 +12,8 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="106"/>
<integer value="89"/>
+ <integer value="56"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -49,7 +49,7 @@
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="1006">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -58,13 +58,10 @@
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{750, 600}</string>
<reference key="NSSuperview" ref="1006"/>
- <reference key="NSWindow"/>
<string key="NSClassName">FastResizeView</string>
</object>
</object>
<string key="NSFrameSize">{750, 600}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
@@ -74,30 +71,6 @@
<int key="NSvFlags">266</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSButton" id="1069275088">
- <reference key="NSNextResponder" ref="1029219716"/>
- <int key="NSvFlags">-2147483383</int>
- <string key="NSFrame">{{375, 11}, {100, 26}}</string>
- <reference key="NSSuperview" ref="1029219716"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="88631848">
- <int key="NSCellFlags">-2080244224</int>
- <int key="NSCellFlags2">134217728</int>
- <string key="NSContents"/>
- <object class="NSFont" key="NSSupport" id="944571928">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">1044</int>
- </object>
- <reference key="NSControlView" ref="1069275088"/>
- <int key="NSButtonFlags">139215103</int>
- <int key="NSButtonFlags2">134</int>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">400</int>
- <int key="NSPeriodicInterval">75</int>
- </object>
- </object>
<object class="NSButton" id="131944810">
<reference key="NSNextResponder" ref="1029219716"/>
<int key="NSvFlags">-2147483356</int>
@@ -108,7 +81,11 @@
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents"/>
- <reference key="NSSupport" ref="944571928"/>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">1044</int>
+ </object>
<reference key="NSControlView" ref="131944810"/>
<int key="NSButtonFlags">138690815</int>
<int key="NSButtonFlags2">134</int>
@@ -182,14 +159,6 @@
</object>
<int key="connectionID">90</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">profileMenuButton</string>
- <reference key="source" ref="1029219716"/>
- <reference key="destination" ref="1069275088"/>
- </object>
- <int key="connectionID">108</int>
- </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -243,7 +212,6 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="131944810"/>
- <reference ref="1069275088"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">TabBar</string>
@@ -275,20 +243,6 @@
</object>
<reference key="parent" ref="1006"/>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">106</int>
- <reference key="object" ref="1069275088"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="88631848"/>
- </object>
- <reference key="parent" ref="1029219716"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">107</int>
- <reference key="object" ref="88631848"/>
- <reference key="parent" ref="1069275088"/>
- </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -306,11 +260,6 @@
<string>1.editorWindowContentRectSynchronizationRect</string>
<string>1.windowTemplate.hasMinSize</string>
<string>1.windowTemplate.minSize</string>
- <string>106.CustomClassName</string>
- <string>106.IBPluginDependency</string>
- <string>106.IBViewBoundsToFrameTransform</string>
- <string>107.CustomClassName</string>
- <string>107.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>2.IBViewIntegration.shadowBlurRadius</string>
<string>2.IBViewIntegration.shadowColor</string>
@@ -339,15 +288,8 @@
<boolean value="NO"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
- <boolean value="YES"/>
+ <boolean value="NO"/>
<string>{400, 250}</string>
- <string>ProfileMenuButton</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <object class="NSAffineTransform">
- <bytes key="NSTransformStruct">P4AAAL+AAABDk4AAwcgAAA</bytes>
- </object>
- <string>ClickHoldButtonCell</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<real value="0.0"/>
<object class="NSColor">
@@ -435,25 +377,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">ClickHoldButtonCell</string>
- <string key="superclassName">ImageButtonCell</string>
- <object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">clickHoldTarget_</string>
- <string key="NS.object.0">id</string>
- </object>
- <object class="NSMutableDictionary" key="toOneOutletInfosByName">
- <string key="NS.key.0">clickHoldTarget_</string>
- <object class="IBToOneOutletInfo" key="NS.object.0">
- <string key="name">clickHoldTarget_</string>
- <string key="candidateClassName">id</string>
- </object>
- </object>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/ui/cocoa/clickhold_button_cell.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">FastResizeView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/chrome/browser/ui/cocoa/profile_menu_button.h b/chrome/browser/ui/cocoa/profile_menu_button.h
deleted file mode 100644
index 59b59e2..0000000
--- a/chrome/browser/ui/cocoa/profile_menu_button.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_COCOA_PROFILE_MENU_BUTTON_H_
-#define CHROME_BROWSER_UI_COCOA_PROFILE_MENU_BUTTON_H_
-#pragma once
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/memory/scoped_nsobject.h"
-#include "base/memory/scoped_ptr.h"
-#import "chrome/browser/ui/cocoa/menu_button.h"
-#import "chrome/browser/ui/cocoa/menu_controller.h"
-
-class ProfileMenuModel;
-
-// PopUp button that shows the multiprofile menu.
-@interface ProfileMenuButton : MenuButton {
- @private
- BOOL shouldShowProfileDisplayName_;
- scoped_nsobject<NSTextFieldCell> textFieldCell_;
-
- scoped_nsobject<NSImage> cachedTabImage_;
- // Cache the various button states when creating |cachedTabImage_|. If
- // any of these states change then the cached image is invalidated.
- BOOL cachedTabImageIsPressed_;
-
- // The popup menu and its model.
- scoped_nsobject<MenuController> menu_;
- scoped_ptr<ProfileMenuModel> profile_menu_model_;
-}
-
-@property(assign,nonatomic) BOOL shouldShowProfileDisplayName;
-@property(assign,nonatomic) NSString* profileDisplayName;
-
-// Gets the size of the control that would display all its contents.
-- (NSSize)desiredControlSize;
-// Gets the minimum size that the control should be resized to.
-- (NSSize)minControlSize;
-
-@end
-
-#endif // CHROME_BROWSER_UI_COCOA_PROFILE_MENU_BUTTON_H_
diff --git a/chrome/browser/ui/cocoa/profile_menu_button.mm b/chrome/browser/ui/cocoa/profile_menu_button.mm
deleted file mode 100644
index 7d81117..0000000
--- a/chrome/browser/ui/cocoa/profile_menu_button.mm
+++ /dev/null
@@ -1,363 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "chrome/browser/ui/cocoa/profile_menu_button.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "chrome/browser/ui/profile_menu_model.h"
-#import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h"
-
-namespace {
-
-const CGFloat kTabWidth = 24;
-const CGFloat kTabHeight = 13;
-const CGFloat kTabArrowWidth = 7;
-const CGFloat kTabArrowHeight = 4;
-const CGFloat kTabRoundRectRadius = 5;
-const CGFloat kTabDisplayNameMarginY = 3;
-
-NSColor* GetWhiteWithAlpha(CGFloat alpha) {
- return [NSColor colorWithCalibratedWhite:1.0 alpha:alpha];
-}
-
-NSColor* GetBlackWithAlpha(CGFloat alpha) {
- return [NSColor colorWithCalibratedWhite:0.0 alpha:alpha];
-}
-
-} // namespace
-
-@interface ProfileMenuButton (Private)
-- (void)commonInit;
-- (NSPoint)popUpMenuPosition;
-- (NSImage*)tabImage;
-- (NSRect)textFieldRect;
-- (NSBezierPath*)tabPathWithRect:(NSRect)rect
- radius:(CGFloat)radius;
-- (NSBezierPath*)downArrowPathWithRect:(NSRect)rect;
-- (NSImage*)tabImageWithSize:(NSSize)tabSize
- fillColor:(NSColor*)fillColor
- isPressed:(BOOL)isPressed;
-@end
-
-@implementation ProfileMenuButton
-
-@synthesize shouldShowProfileDisplayName = shouldShowProfileDisplayName_;
-
-- (void)commonInit {
- textFieldCell_.reset(
- [[GTMFadeTruncatingTextFieldCell alloc] initTextCell:@""]);
- [textFieldCell_ setBackgroundStyle:NSBackgroundStyleRaised];
- [textFieldCell_ setAlignment:NSRightTextAlignment];
- [textFieldCell_ setFont:[NSFont systemFontOfSize:
- [NSFont smallSystemFontSize]]];
-
- [self setOpenMenuOnClick:YES];
-
- profile_menu_model_.reset(new ProfileMenuModel);
- menu_.reset([[MenuController alloc] initWithModel:profile_menu_model_.get()
- useWithPopUpButtonCell:NO]);
-}
-
-- (id)initWithFrame:(NSRect)frame {
- if ((self = [super initWithFrame:frame]))
- [self commonInit];
- return self;
-}
-
-- (id)initWithCoder:(NSCoder*)decoder {
- if ((self = [super initWithCoder:decoder]))
- [self commonInit];
- return self;
-}
-
-- (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [super dealloc];
-}
-
-- (NSString*)profileDisplayName {
- return [textFieldCell_ stringValue];
-}
-
-- (void)setProfileDisplayName:(NSString*)name {
- if (![[textFieldCell_ stringValue] isEqual:name]) {
- [textFieldCell_ setStringValue:name];
- [self setNeedsDisplay:YES];
- }
-}
-
-- (void)setShouldShowProfileDisplayName:(BOOL)flag {
- shouldShowProfileDisplayName_ = flag;
- [self setNeedsDisplay:YES];
-}
-
-- (BOOL)isFlipped {
- return NO;
-}
-
-- (void)viewWillMoveToWindow:(NSWindow*)newWindow {
- if ([self window] == newWindow)
- return;
-
- if ([self window]) {
- [[NSNotificationCenter defaultCenter]
- removeObserver:self
- name:NSWindowDidBecomeMainNotification
- object:[self window]];
- [[NSNotificationCenter defaultCenter]
- removeObserver:self
- name:NSWindowDidResignMainNotification
- object:[self window]];
- }
-
- if (newWindow) {
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(onWindowFocusChanged:)
- name:NSWindowDidBecomeMainNotification
- object:newWindow];
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(onWindowFocusChanged:)
- name:NSWindowDidResignMainNotification
- object:newWindow];
- }
-}
-
-- (void)onWindowFocusChanged:(NSNotification*)note {
- [self setNeedsDisplay:YES];
-}
-
-- (NSRect)tabRect {
- NSRect bounds = [self bounds];
- NSRect tabRect;
- tabRect.size.width = kTabWidth;
- tabRect.size.height = kTabHeight;
- tabRect.origin.x = NSMaxX(bounds) - NSWidth(tabRect);
- tabRect.origin.y = NSMaxY(bounds) - NSHeight(tabRect);
- return tabRect;
-}
-
-- (NSRect)textFieldRect {
- NSRect bounds = [self bounds];
- NSSize desiredSize = [textFieldCell_ cellSize];
-
- NSRect textRect = bounds;
- textRect.size.height = std::min(desiredSize.height, NSHeight(bounds));
-
- // For some reason there's always a 2 pixel gap on the right side of the
- // text field. Fix it by moving the text field to the right by 2 pixels.
- textRect.origin.x += 2;
-
- return textRect;
-}
-
-- (NSView*)hitTest:(NSPoint)aPoint {
- NSView* probe = [super hitTest:aPoint];
- if (probe != self)
- return probe;
-
- NSPoint viewPoint = [self convertPoint:aPoint fromView:[self superview]];
- BOOL isFlipped = [self isFlipped];
- if (NSMouseInRect(viewPoint, [self tabRect], isFlipped))
- return self;
- else
- return nil;
-}
-
-- (NSBezierPath*)tabPathWithRect:(NSRect)rect
- radius:(CGFloat)radius {
- const NSRect innerRect = NSInsetRect(rect, radius, radius);
- NSBezierPath* path = [NSBezierPath bezierPath];
-
- // Top left
- [path moveToPoint:NSMakePoint(NSMinX(rect), NSMaxY(rect))];
-
- // Bottom left
- [path lineToPoint:NSMakePoint(NSMinX(rect), NSMinY(innerRect))];
- [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect),
- NSMinY(innerRect))
- radius:radius
- startAngle:180
- endAngle:270
- clockwise:NO];
-
- // Bottom right
- [path lineToPoint:NSMakePoint(NSMaxX(innerRect), NSMinY(rect))];
- [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect),
- NSMinY(innerRect))
- radius:radius
- startAngle:270
- endAngle:360
- clockwise:NO];
-
- // Top right
- [path lineToPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect))];
-
- [path closePath];
- return path;
-}
-
-- (NSBezierPath*)downArrowPathWithRect:(NSRect)rect {
- NSBezierPath* path = [NSBezierPath bezierPath];
-
- // Top left
- [path moveToPoint:NSMakePoint(NSMinX(rect), NSMaxY(rect))];
-
- // Bottom middle
- [path lineToPoint:NSMakePoint(NSMidX(rect), NSMinY(rect))];
-
- // Top right
- [path lineToPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect))];
-
- [path closePath];
- return path;
-}
-
-- (NSImage*)tabImageWithSize:(NSSize)tabSize
- fillColor:(NSColor*)fillColor
- isPressed:(BOOL)isPressed {
- NSImage* image = [[[NSImage alloc] initWithSize:tabSize] autorelease];
- [image lockFocus];
-
- // White shadow for inset look
- [[NSGraphicsContext currentContext] saveGraphicsState];
- scoped_nsobject<NSShadow> tabShadow([[NSShadow alloc] init]);
- [tabShadow.get() setShadowOffset:NSMakeSize(0, -1)];
- [tabShadow setShadowBlurRadius:0];
- [tabShadow.get() setShadowColor:GetWhiteWithAlpha(0.6)];
- [tabShadow set];
-
- // Gray outline
- NSRect tabRect = NSMakeRect(0, 1, tabSize.width, tabSize.height - 1);
- NSBezierPath* outlinePath = [self tabPathWithRect:tabRect
- radius:kTabRoundRectRadius];
- [[NSColor colorWithCalibratedWhite:0.44 alpha:1.0] set];
- [outlinePath fill];
-
- [[NSGraphicsContext currentContext] restoreGraphicsState];
-
- // Fill
- NSRect fillRect = NSInsetRect(tabRect, 1, 0);
- fillRect.size.height -= 1;
- fillRect.origin.y += 1;
- NSBezierPath* fillPath = [self tabPathWithRect:fillRect
- radius:kTabRoundRectRadius - 1];
- [fillColor set];
- [fillPath fill];
-
- // Shading for fill to make the bottom of the tab slightly darker.
- scoped_nsobject<NSGradient> gradient([[NSGradient alloc]
- initWithStartingColor:GetBlackWithAlpha(isPressed ? 0.2 : 0.0)
- endingColor:GetBlackWithAlpha(0.2)]);
- [gradient drawInBezierPath:fillPath angle:270];
-
- // Highlight on top
- NSRect highlightRect = NSInsetRect(tabRect, 1, 0);
- highlightRect.size.height = 1;
- highlightRect.origin.y = NSMaxY(tabRect) - highlightRect.size.height;
- [GetWhiteWithAlpha(0.5) set];
- NSRectFillUsingOperation(highlightRect, NSCompositeSourceOver);
-
- // Arrow shadow
- [[NSGraphicsContext currentContext] saveGraphicsState];
- scoped_nsobject<NSShadow> arrowShadow([[NSShadow alloc] init]);
- [arrowShadow.get() setShadowOffset:NSMakeSize(0, -1)];
- [arrowShadow setShadowBlurRadius:0];
- [arrowShadow.get() setShadowColor:GetBlackWithAlpha(0.6)];
- [arrowShadow set];
-
- // Down arrow
- NSRect arrowRect;
- arrowRect.size.width = kTabArrowWidth;
- arrowRect.size.height = kTabArrowHeight;
- arrowRect.origin.x = NSMinX(tabRect) + roundf((NSWidth(tabRect) -
- NSWidth(arrowRect)) / 2.0);
- arrowRect.origin.y = NSMinY(tabRect) + roundf((tabRect.size.height -
- arrowRect.size.height) / 2.0);
- NSBezierPath* arrowPath = [self downArrowPathWithRect:arrowRect];
- if (isPressed)
- [[NSColor colorWithCalibratedWhite:0.8 alpha:1.0] set];
- else
- [[NSColor whiteColor] set];
- [arrowPath fill];
-
- [[NSGraphicsContext currentContext] restoreGraphicsState];
-
- [image unlockFocus];
- return image;
-}
-
-- (NSImage*)tabImage {
- BOOL isPressed = [[self cell] isHighlighted];
-
- // Invalidate the cached image if necessary.
- if (cachedTabImageIsPressed_ != isPressed) {
- cachedTabImageIsPressed_ = isPressed;
- cachedTabImage_.reset();
- }
-
- if (cachedTabImage_)
- return cachedTabImage_;
-
- // TODO: Use different colors for different profiles and tint for
- // the current browser theme.
- NSColor* fillColor = [NSColor colorWithCalibratedRed:122.0/255.0
- green:177.0/255.0
- blue:252.0/255.0
- alpha:1.0];
- NSRect tabRect = [self tabRect];
- cachedTabImage_.reset([[self tabImageWithSize:tabRect.size
- fillColor:fillColor
- isPressed:isPressed] retain]);
- return cachedTabImage_;
-}
-
-- (void)drawRect:(NSRect)rect {
- CGFloat alpha = [[self window] isMainWindow] ? 1.0 : 0.5;
- [[self tabImage] drawInRect:[self tabRect]
- fromRect:NSZeroRect
- operation:NSCompositeSourceOver
- fraction:alpha];
-
- if (shouldShowProfileDisplayName_) {
- NSColor* textColor = [[self window] isMainWindow] ?
- GetBlackWithAlpha(0.6) : GetBlackWithAlpha(0.4);
- if (![[textFieldCell_ textColor] isEqual:textColor])
- [textFieldCell_ setTextColor:textColor];
- [textFieldCell_ drawWithFrame:[self textFieldRect] inView:self];
- }
-}
-
-- (NSSize)desiredControlSize {
- NSSize size = [self tabRect].size;
-
- if (shouldShowProfileDisplayName_) {
- NSSize textFieldSize = [textFieldCell_ cellSize];
- size.width = std::max(size.width, textFieldSize.width);
- size.height += textFieldSize.height + kTabDisplayNameMarginY;
- }
-
- size.width = ceil(size.width);
- size.height = ceil(size.height);
- return size;
-}
-
-- (NSSize)minControlSize {
- return [self tabRect].size;
-}
-
-// Overridden from MenuButton.
-- (NSMenu*)attachedMenu {
- return [menu_.get() menu];
-}
-
-// Overridden from MenuButton.
-- (NSRect)menuRect {
- return [self tabRect];
-}
-
-@end
diff --git a/chrome/browser/ui/cocoa/profile_menu_button_unittest.mm b/chrome/browser/ui/cocoa/profile_menu_button_unittest.mm
deleted file mode 100644
index 5c713fb..0000000
--- a/chrome/browser/ui/cocoa/profile_menu_button_unittest.mm
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import <Cocoa/Cocoa.h>
-
-#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
-#import "chrome/browser/ui/cocoa/profile_menu_button.h"
-#import "chrome/browser/ui/cocoa/test_event_utils.h"
-#import "testing/gtest_mac.h"
-
-class ProfileMenuButtonTest : public CocoaTest {
- public:
- ProfileMenuButtonTest() {
- scoped_nsobject<ProfileMenuButton> button([[ProfileMenuButton alloc]
- initWithFrame:NSMakeRect(50, 50, 100, 100)]);
- button_ = button.get();
- [[test_window() contentView] addSubview:button_];
- }
-
- ProfileMenuButton* button_;
-};
-
-
-TEST_F(ProfileMenuButtonTest, ControlSize) {
- scoped_nsobject<ProfileMenuButton> button([[ProfileMenuButton alloc]
- initWithFrame:NSZeroRect]);
-
- NSSize minSize = [button minControlSize];
- EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize]));
-
- [button setProfileDisplayName:@"Test"];
- EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize]));
- EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize]));
-
- [button setShouldShowProfileDisplayName:YES];
- EXPECT_TRUE(NSEqualSizes(minSize, [button minControlSize]));
- EXPECT_GT([button desiredControlSize].height, minSize.height);
- EXPECT_GT([button desiredControlSize].width, minSize.width);
-
- [button setShouldShowProfileDisplayName:NO];
- EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize]));
- EXPECT_TRUE(NSEqualSizes(minSize, [button desiredControlSize]));
-}
-
-// Tests display, add/remove.
-TEST_VIEW(ProfileMenuButtonTest, button_);
-
-TEST_F(ProfileMenuButtonTest, HitTest) {
- NSRect mouseRect = NSInsetRect([button_ frame], 1, 1);
- NSPoint topRight = NSMakePoint(NSMaxX(mouseRect), NSMaxY(mouseRect));
- NSPoint bottomRight = NSMakePoint(NSMaxX(mouseRect), NSMinY(mouseRect));
- NSPoint outsidePoint = NSOffsetRect(mouseRect, -10, -10).origin;
-
- // Without profile display name. Only topRight should hit.
- EXPECT_NSEQ([button_ hitTest:topRight], button_);
- EXPECT_NSEQ([button_ hitTest:bottomRight], NULL);
- EXPECT_NSEQ([button_ hitTest:outsidePoint], NULL);
-
- // With profile display name. The profile display name should not hit.
- [button_ setProfileDisplayName:@"Test"];
- [button_ setShouldShowProfileDisplayName:YES];
- EXPECT_NSEQ([button_ hitTest:topRight], button_);
- EXPECT_NSEQ([button_ hitTest:bottomRight], NULL);
- EXPECT_NSEQ([button_ hitTest:outsidePoint], NULL);
-}
-
-// Test drawing, mostly to ensure nothing leaks or crashes.
-TEST_F(ProfileMenuButtonTest, Display) {
- // With profile display name.
- [button_ display];
-
- // With profile display name.
- [button_ setProfileDisplayName:@"Test"];
- [button_ setShouldShowProfileDisplayName:YES];
- [button_ display];
-}
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.h b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.h
index 6d969f0..96d0df4 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.h
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.h
@@ -18,7 +18,6 @@
@class CrTrackingArea;
@class NewTabButton;
-@class ProfileMenuButton;
@class TabContentsController;
@class TabView;
@class TabStripDragController;
@@ -31,10 +30,6 @@ class TabStripModel;
class TabContents;
class ToolbarModel;
-namespace TabStripControllerInternal {
-class NotificationBridge;
-} // namespace TabStripControllerInternal
-
// The interface for the tab strip controller's delegate.
// Delegating TabStripModelObserverBridge's events (in lieu of directly
// subscribing to TabStripModelObserverBridge events, as TabStripController
@@ -78,8 +73,6 @@ class NotificationBridge;
NSView* switchView_; // weak
scoped_nsobject<NSView> dragBlockingView_; // avoid bad window server drags
NewTabButton* newTabButton_; // weak, obtained from the nib.
- ProfileMenuButton* profileMenuButton_; // weak, obtained from the nib.
- BOOL hasUpdatedProfileMenuButtonXOffset_;
// The controller that manages all the interactions of dragging tabs.
scoped_nsobject<TabStripDragController> dragController_;
@@ -157,10 +150,6 @@ class NotificationBridge;
// Is the mouse currently inside the strip;
BOOL mouseInside_;
- // Used for monitoring the profile name pref.
- scoped_ptr<TabStripControllerInternal::NotificationBridge>
- notificationBridge_;
-
// Helper for performing tab selection as a result of dragging over a tab.
scoped_ptr<HoverTabSelector> hoverTabSelector_;
}
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index 200e28c..6ad6d41 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -32,7 +32,6 @@
#import "chrome/browser/ui/cocoa/constrained_window_mac.h"
#import "chrome/browser/ui/cocoa/image_button_cell.h"
#import "chrome/browser/ui/cocoa/new_tab_button.h"
-#import "chrome/browser/ui/cocoa/profile_menu_button.h"
#import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h"
#import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
@@ -272,39 +271,6 @@ private:
@end
-namespace TabStripControllerInternal {
-
-// Bridges C++ notifications back to the TabStripController.
-class NotificationBridge : public NotificationObserver {
- public:
- explicit NotificationBridge(TabStripController* controller,
- PrefService* prefService)
- : controller_(controller) {
- DCHECK(prefService);
- usernamePref_.Init(prefs::kGoogleServicesUsername, prefService, this);
- }
-
- // Overridden from NotificationObserver:
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK_EQ(NotificationType::PREF_CHANGED, type.value);
- std::string* name = Details<std::string>(details).ptr();
- if (prefs::kGoogleServicesUsername == *name) {
- [controller_ updateProfileMenuButton];
- [controller_ layoutTabsWithAnimation:NO regenerateSubviews:NO];
- }
- }
-
- private:
- TabStripController* controller_; // weak, owns us
-
- // The Google services user name associated with this BrowserView's profile.
- StringPrefMember usernamePref_;
-};
-
-} // namespace TabStripControllerInternal
-
#pragma mark -
// In general, there is a one-to-one correspondence between TabControllers,
@@ -384,14 +350,6 @@ class NotificationBridge : public NotificationObserver {
[newTabButton_ setAction:@selector(commandDispatch:)];
[newTabButton_ setTag:IDC_NEW_TAB];
- profileMenuButton_ = [view profileMenuButton];
- [self addSubviewToPermanentList:profileMenuButton_];
- [self updateProfileMenuButton];
- // Register pref observers for profile name.
- notificationBridge_.reset(
- new TabStripControllerInternal::NotificationBridge(
- self, browser_->profile()->GetPrefs()));
-
// Set the images from code because Cocoa fails to find them in our sub
// bundle during tests.
[[newTabButton_ cell] setImageID:IDR_NEWTAB_BUTTON
@@ -1081,49 +1039,6 @@ class NotificationBridge : public NotificationObserver {
}
}
- if (profileMenuButton_ && ![profileMenuButton_ isHidden]) {
- CGFloat maxX;
- if ([newTabButton_ isHidden]) {
- maxX = std::max(offset, NSMaxX(placeholderFrame_) - kTabOverlap);
- } else {
- maxX = NSMaxX(newTabTargetFrame_);
- }
- NSRect profileMenuButtonFrame = [profileMenuButton_ frame];
- NSSize minSize = [profileMenuButton_ minControlSize];
-
- // Make room for the full screen button if necessary.
- if (!hasUpdatedProfileMenuButtonXOffset_) {
- hasUpdatedProfileMenuButtonXOffset_ = YES;
- if ([[profileMenuButton_ window]
- respondsToSelector:@selector(toggleFullScreen:)]) {
- NSButton* fullscreenButton = [[profileMenuButton_ window]
- standardWindowButton:NSWindowFullScreenButton];
- if (fullscreenButton) {
- profileMenuButtonFrame.origin.x = NSMinX([fullscreenButton frame]) -
- NSWidth(profileMenuButtonFrame) - kProfileMenuButtonOffset;
- }
- }
- }
-
- // TODO(sail): Animate this.
- CGFloat availableWidth = NSMaxX(profileMenuButtonFrame) - maxX -
- kProfileMenuButtonOffset;
- if (availableWidth > minSize.width) {
- [profileMenuButton_ setShouldShowProfileDisplayName:YES];
- } else {
- [profileMenuButton_ setShouldShowProfileDisplayName:NO];
- }
-
- NSSize desiredSize = [profileMenuButton_ desiredControlSize];
- NSRect rect;
- rect.size.width = std::min(desiredSize.width,
- std::max(availableWidth, minSize.width));
- rect.size.height = desiredSize.height;
- rect.origin.y = NSMaxY(profileMenuButtonFrame) - rect.size.height;
- rect.origin.x = NSMaxX(profileMenuButtonFrame) - rect.size.width;
- [profileMenuButton_ setFrame:rect];
- }
-
[dragBlockingView_ setFrame:enclosingRect];
// Mark that we've successfully completed layout of at least one tab.
@@ -2125,26 +2040,4 @@ class NotificationBridge : public NotificationObserver {
}
}
-- (BOOL)shouldShowProfileMenuButton {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles))
- return NO;
- if (browser_->profile()->IsOffTheRecord())
- return NO;
- return (!browser_->profile()->GetPrefs()->GetString(
- prefs::kGoogleServicesUsername).empty());
-}
-
-- (void)updateProfileMenuButton {
- if (![self shouldShowProfileMenuButton]) {
- [profileMenuButton_ setHidden:YES];
- return;
- }
-
- std::string profileName = browser_->profile()->GetPrefs()->GetString(
- prefs::kGoogleServicesUsername);
- [profileMenuButton_ setProfileDisplayName:
- [NSString stringWithUTF8String:profileName.c_str()]];
- [profileMenuButton_ setHidden:NO];
-}
-
@end
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 9d86595..4e64348 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2526,8 +2526,6 @@
'browser/ui/cocoa/omnibox/omnibox_view_mac.mm',
'browser/ui/cocoa/page_info_bubble_controller.h',
'browser/ui/cocoa/page_info_bubble_controller.mm',
- 'browser/ui/cocoa/profile_menu_button.h',
- 'browser/ui/cocoa/profile_menu_button.mm',
'browser/ui/cocoa/repost_form_warning_mac.h',
'browser/ui/cocoa/repost_form_warning_mac.mm',
'browser/ui/cocoa/restart_browser.h',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 75ae733..fdf19ae 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1776,7 +1776,6 @@
'browser/ui/cocoa/omnibox/omnibox_popup_view_mac_unittest.mm',
'browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm',
'browser/ui/cocoa/page_info_bubble_controller_unittest.mm',
- 'browser/ui/cocoa/profile_menu_button_unittest.mm',
'browser/ui/cocoa/rwhvm_editcommand_helper_unittest.mm',
'browser/ui/cocoa/status_bubble_mac_unittest.mm',
'browser/ui/cocoa/status_icons/status_icon_mac_unittest.mm',