diff options
25 files changed, 640 insertions, 240 deletions
diff --git a/chrome/app/nibs/BookmarkBar.xib b/chrome/app/nibs/BookmarkBar.xib index 32db393..0b9c9078 100644 --- a/chrome/app/nibs/BookmarkBar.xib +++ b/chrome/app/nibs/BookmarkBar.xib @@ -8,10 +8,9 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="75"/> + <integer value="18"/> <integer value="1"/> <integer value="4"/> - <integer value="18"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -37,26 +36,6 @@ <object class="NSCustomObject" id="1004"> <string key="NSClassName">NSApplication</string> </object> - <object class="NSMenu" id="190917733"> - <string key="NSTitle"/> - <object class="NSMutableArray" key="NSMenuItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMenuItem" id="582055256"> - <reference key="NSMenu" ref="190917733"/> - <string key="NSTitle"/> - <string key="NSKeyEquiv"/> - <int key="NSMnemonicLoc">2147483647</int> - <object class="NSCustomResource" key="NSOnImage" id="932677134"> - <string key="NSClassName">NSImage</string> - <string key="NSResourceName">NSMenuCheckmark</string> - </object> - <object class="NSCustomResource" key="NSMixedImage" id="126584967"> - <string key="NSClassName">NSImage</string> - <string key="NSResourceName">NSMenuMixedState</string> - </object> - </object> - </object> - </object> <object class="NSCustomView" id="620641226"> <reference key="NSNextResponder"/> <int key="NSvFlags">-2147483358</int> @@ -134,7 +113,27 @@ </object> <string key="NSFrameSize">{600, 144}</string> <reference key="NSSuperview"/> - <string key="NSClassName">NSView</string> + <string key="NSClassName">BookmarkBarToolbarView</string> + </object> + <object class="NSMenu" id="190917733"> + <string key="NSTitle"/> + <object class="NSMutableArray" key="NSMenuItems"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMenuItem" id="582055256"> + <reference key="NSMenu" ref="190917733"/> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <object class="NSCustomResource" key="NSOnImage" id="932677134"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSMenuCheckmark</string> + </object> + <object class="NSCustomResource" key="NSMixedImage" id="126584967"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSMenuMixedState</string> + </object> + </object> + </object> </object> <object class="NSMenu" id="183701277"> <string key="NSTitle"/> @@ -373,14 +372,6 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">view</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="620641226"/> - </object> - <int key="connectionID">3</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> <string key="label">buttonContextMenu_</string> <reference key="source" ref="1001"/> <reference key="destination" ref="672481054"/> @@ -619,6 +610,22 @@ </object> <int key="connectionID">91</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">controller_</string> + <reference key="source" ref="620641226"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">92</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">view</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="620641226"/> + </object> + <int key="connectionID">93</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -1005,12 +1012,20 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">91</int> + <int key="maxID">93</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> + <string key="className">BackgroundGradientView</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/background_gradient_view.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">BookmarkBarController</string> <string key="superclassName">NSViewController</string> <object class="NSMutableDictionary" key="actions"> @@ -1050,6 +1065,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <string>buttonContextMenu_</string> <string>buttonView_</string> + <string>compressDelegate_</string> <string>offTheSideButton_</string> <string>resizeDelegate_</string> <string>urlDelegate_</string> @@ -1058,6 +1074,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <string>NSMenu</string> <string>BookmarkBarView</string> + <string>id</string> <string>MenuButton</string> <string>id</string> <string>id</string> @@ -1069,6 +1086,18 @@ </object> </object> <object class="IBPartialClassDescription"> + <string key="className">BookmarkBarToolbarView</string> + <string key="superclassName">BackgroundGradientView</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">controller_</string> + <string key="NS.object.0">id</string> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/bookmark_bar_toolbar_view.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">BookmarkBarView</string> <string key="superclassName">NSView</string> <object class="NSMutableDictionary" key="outlets"> diff --git a/chrome/browser/cocoa/bookmark_bar_bridge.h b/chrome/browser/cocoa/bookmark_bar_bridge.h index 269bbad..9c09e4a 100644 --- a/chrome/browser/cocoa/bookmark_bar_bridge.h +++ b/chrome/browser/cocoa/bookmark_bar_bridge.h @@ -19,7 +19,8 @@ class Browser; class BookmarkBarBridge : public BookmarkModelObserver { public: - BookmarkBarBridge(BookmarkBarController* controller, BookmarkModel* model); + BookmarkBarBridge(BookmarkBarController* controller, + BookmarkModel* model); virtual ~BookmarkBarBridge(); // Overridden from BookmarkModelObserver @@ -46,7 +47,7 @@ class BookmarkBarBridge : public BookmarkModelObserver { private: BookmarkBarController* controller_; // weak; owns me - BookmarkModel *model_; // weak; it is owned by a Profile. + BookmarkModel* model_; // weak; it is owned by a Profile. DISALLOW_COPY_AND_ASSIGN(BookmarkBarBridge); }; diff --git a/chrome/browser/cocoa/bookmark_bar_bridge.mm b/chrome/browser/cocoa/bookmark_bar_bridge.mm index 5fd6fe9..e7ace5b 100644 --- a/chrome/browser/cocoa/bookmark_bar_bridge.mm +++ b/chrome/browser/cocoa/bookmark_bar_bridge.mm @@ -9,7 +9,8 @@ BookmarkBarBridge::BookmarkBarBridge(BookmarkBarController* controller, BookmarkModel* model) - : controller_(controller), model_(model) { + : controller_(controller), + model_(model) { model_->AddObserver(this); // Bookmark loading is async; it may may not have happened yet. diff --git a/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm b/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm index 38a872d..627775a 100644 --- a/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm @@ -33,9 +33,10 @@ typedef std::pair<GURL,WindowOpenDisposition> OpenInfo; @implementation FakeBookmarkBarController -- (id)initWithProfile:(Profile*)profile { - if ((self = [super initWithProfile:profile +- (id)initWithBrowser:(Browser*)browser { + if ((self = [super initWithBrowser:browser initialWidth:100 // arbitrary + compressDelegate:nil resizeDelegate:nil urlDelegate:self])) { callbacks_.reset([[NSMutableArray alloc] init]); @@ -99,8 +100,9 @@ class BookmarkBarBridgeTest : public PlatformTest { // Call all the callbacks; make sure they are all redirected to the objc object. TEST_F(BookmarkBarBridgeTest, TestRedirect) { - Profile *profile = browser_test_helper_.profile(); - BookmarkModel *model = profile->GetBookmarkModel(); + Browser* browser = browser_test_helper_.browser(); + Profile* profile = browser_test_helper_.profile(); + BookmarkModel* model = profile->GetBookmarkModel(); scoped_nsobject<NSView> parentView([[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)]); @@ -110,7 +112,7 @@ TEST_F(BookmarkBarBridgeTest, TestRedirect) { [[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)]); scoped_nsobject<FakeBookmarkBarController> - controller([[FakeBookmarkBarController alloc] initWithProfile:profile]); + controller([[FakeBookmarkBarController alloc] initWithBrowser:browser]); EXPECT_TRUE(controller.get()); scoped_ptr<BookmarkBarBridge> bridge(new BookmarkBarBridge(controller.get(), model)); diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index 1efcc92..87b13a3 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -11,16 +11,21 @@ #include "base/scoped_nsobject.h" #include "base/scoped_ptr.h" #include "chrome/browser/cocoa/bookmark_bar_bridge.h" +#include "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" #include "webkit/glue/window_open_disposition.h" +@class BackgroundGradientView; @class BookmarkBarStateController; class BookmarkModel; class BookmarkNode; @class BookmarkBarView; +class Browser; +@protocol ToolbarCompressable; class GURL; @class MenuButton; class Profile; class PrefService; +@class ToolbarController; @protocol ViewResizer; // The interface for an object which can open URLs for a bookmark. @@ -29,12 +34,19 @@ class PrefService; disposition:(WindowOpenDisposition)disposition; @end +// An interface to allow mocking of a BookmarkBarController by the +// BookmarkBarToolbarView. +@protocol BookmarkBarFloating +// Returns true if the bookmark bar should be drawn as if it's a disconnected +// bookmark bar on the New Tag Page. +- (BOOL)drawAsFloatingBar; +@end // A controller for the bookmark bar in the browser window. Handles showing // and hiding based on the preference in the given profile. -@interface BookmarkBarController : NSViewController { +@interface BookmarkBarController : NSViewController<BookmarkBarFloating> { @private - Profile* profile_; // weak + Browser* browser_; // weak; owned by its window BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the // top-level Browser object. @@ -55,19 +67,23 @@ class PrefService; // Set when using fullscreen mode. BOOL barIsEnabled_; - // Set to YES when the user elects to always show the bookmark bar. - BOOL barShouldBeShown_; - // Bridge from Chrome-style C++ notifications (e.g. derived from // BookmarkModelObserver) scoped_ptr<BookmarkBarBridge> bridge_; + // Delegate that is alerted about whether it should be compressed because + // it's right next to us. + id<ToolbarCompressable> compressDelegate_; // weak + // Delegate that can resize us. id<ViewResizer> resizeDelegate_; // weak // Delegate that can open URLs for us. id<BookmarkURLOpener> urlDelegate_; // weak + // Lets us get TabSelectedAt notifications. + scoped_ptr<TabStripModelObserverBridge> tabObserver_; + IBOutlet BookmarkBarView* buttonView_; IBOutlet MenuButton* offTheSideButton_; IBOutlet NSMenu* buttonContextMenu_; @@ -75,26 +91,42 @@ class PrefService; // Initializes the bookmark bar controller with the given browser // profile and delegates. -- (id)initWithProfile:(Profile*)profile +- (id)initWithBrowser:(Browser*)browser initialWidth:(float)initialWidth + compressDelegate:(id<ToolbarCompressable>)compressDelegate resizeDelegate:(id<ViewResizer>)resizeDelegate urlDelegate:(id<BookmarkURLOpener>)urlDelegate; +// Returns the backdrop to the bookmark bar. +- (BackgroundGradientView*)backgroundGradientView; + // Tell the bar to show itself if needed (e.g. if the kShowBookmarkBar // is set). Called once after the controller is first created. - (void)showIfNeeded; -// Returns whether or not the bookmark bar is visible. -- (BOOL)isBookmarkBarVisible; - -// Toggle the state of the bookmark bar. -- (void)toggleBookmarkBar; +// Update the visible state of the bookmark bar based on the current value of +// -[BookmarkBarController isAlwaysVisible]. +- (void)updateVisibility; // Turn on or off the bookmark bar and prevent or reallow its // appearance. On disable, toggle off if shown. On enable, show only // if needed. For fullscreen mode. - (void)setBookmarkBarEnabled:(BOOL)enabled; +// Returns YES if the bookmarks bar is currently visible, either because the +// user has asked for it to always be visible, or because the current tab is the +// New Tab page. +- (BOOL)isVisible; + +// Returns true if the bookmark bar needs to be shown currently because a tab +// that requires it is selected. The bookmark bar will have a different +// appearance when it is shown if isAlwaysVisible returns NO. +- (BOOL)isNewTabPage; + +// Returns true if the bookmark bar is visible for all tabs. (This corresponds +// to the user having selected "Always show the bookmark bar") +- (BOOL)isAlwaysVisible; + // Actions for manipulating bookmarks. // From a button, ... - (IBAction)openBookmark:(id)sender; diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 9de155a..9b3ef1e 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -19,8 +19,10 @@ #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" #import "chrome/browser/cocoa/event_utils.h" #import "chrome/browser/cocoa/menu_button.h" +#import "chrome/browser/cocoa/toolbar_controller.h" #import "chrome/browser/cocoa/view_resizer.h" #include "chrome/browser/profile.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "grit/generated_resources.h" @@ -45,13 +47,17 @@ - (void)addFolderNode:(const BookmarkNode*)node toMenu:(NSMenu*)menu; - (void)tagEmptyMenu:(NSMenu*)menu; - (void)clearMenuTagMap; +- (int)preferredHeight; @end namespace { -// Our height, when opened. +// Our height, when opened in "always visible" mode. const int kBookmarkBarHeight = 28; +// Our height, when visible in "new tab page" mode. +const int kNTPBookmarkBarHeight = 40; + // Magic numbers from Cole const CGFloat kDefaultBookmarkWidth = 150.0; const CGFloat kBookmarkVerticalPadding = 2.0; @@ -61,18 +67,22 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; @implementation BookmarkBarController -- (id)initWithProfile:(Profile*)profile +- (id)initWithBrowser:(Browser*)browser initialWidth:(float)initialWidth + compressDelegate:(id<ToolbarCompressable>)compressDelegate resizeDelegate:(id<ViewResizer>)resizeDelegate urlDelegate:(id<BookmarkURLOpener>)urlDelegate { if ((self = [super initWithNibName:@"BookmarkBar" bundle:mac_util::MainAppBundle()])) { - profile_ = profile; + browser_ = browser; initialWidth_ = initialWidth; - bookmarkModel_ = profile->GetBookmarkModel(); + bookmarkModel_ = browser_->profile()->GetBookmarkModel(); buttons_.reset([[NSMutableArray alloc] init]); + compressDelegate_ = compressDelegate; resizeDelegate_ = resizeDelegate; urlDelegate_ = urlDelegate; + tabObserver_.reset( + new TabStripModelObserverBridge(browser_->tabstrip_model(), self)); } return self; } @@ -110,8 +120,13 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; DCHECK([offTheSideButton_ attachedMenu]); } +// Method is the same as [self view], but is provided to be explicit. +- (BackgroundGradientView*)backgroundGradientView { + return (BackgroundGradientView*)[self view]; +} + - (void)showIfNeeded { - if (profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) + if (browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) [self showBookmarkBar:YES immediately:YES]; } @@ -140,50 +155,48 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; [self checkHideOffTheSideButton]; } -// Show or hide the bar based on the value of |show|. Handles -// animating the resize of the content view. if |immediately| is YES, -// make changes immediately instead of using an animator. If the bar -// is disabled, do absolutely nothing. The routine which enables the -// bar will show it if relevant using other mechanisms (the pref) to -// determine desired state. +// Show or hide the bar based on the value of |show|. Handles animating the +// resize of the content view. if |immediately| is YES, make changes +// immediately instead of using an animator. The routine which enables the bar +// will show it if relevant using other mechanisms (the pref) to determine +// desired state. - (void)showBookmarkBar:(BOOL)show immediately:(BOOL)immediately { - if (barIsEnabled_ && (barShouldBeShown_ != show)) { - if ([self view]) { - [[self view] setHidden:show ? NO : YES]; - [resizeDelegate_ resizeView:[self view] - newHeight:(show ? kBookmarkBarHeight : 0)]; - } - barShouldBeShown_ = show; - if (show) { - [self loaded:bookmarkModel_]; - } - } -} + BOOL compressed = [self isAlwaysVisible]; + [compressDelegate_ setShouldBeCompressed:compressed]; -- (BOOL)isBookmarkBarVisible { - return barShouldBeShown_; + CGFloat height = show ? [self preferredHeight] : 0; + [resizeDelegate_ resizeView:[self view] newHeight:height]; + [[self view] setHidden:show ? NO : YES]; } // We don't change a preference; we only change visibility. // Preference changing (global state) is handled in -// BrowserWindowCocoa::ToggleBookmarkBar(). -- (void)toggleBookmarkBar { - [self showBookmarkBar:!barShouldBeShown_ immediately:YES]; +// BrowserWindowCocoa::ToggleBookmarkBar(). We simply update the visibility of +// the bar based on the current value of the pref. +- (void)updateVisibility { + [self showBookmarkBar:[self isVisible] immediately:YES]; } - (void)setBookmarkBarEnabled:(BOOL)enabled { - if (enabled) { - // Enabling the bar; set enabled then show if needed. - barIsEnabled_ = YES; - if (profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) - [self showBookmarkBar:YES immediately:YES]; - } else { - // Disabling the bar; hide if visible. - if ([self isBookmarkBarVisible]) { - [self showBookmarkBar:NO immediately:YES]; - } - barIsEnabled_ = NO; - } + barIsEnabled_ = enabled ? YES : NO; + [self updateVisibility]; +} + +- (BOOL)isVisible { + return ([self isAlwaysVisible] && barIsEnabled_) || [self isNewTabPage]; +} + +- (BOOL)isNewTabPage { + return browser_ && browser_->GetSelectedTabContents() && + browser_->GetSelectedTabContents()->ShouldShowBookmarkBar(); +} + +- (BOOL)isAlwaysVisible { + return browser_ && browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); +} + +- (BOOL)drawAsFloatingBar { + return ![self isAlwaysVisible] && [self isNewTabPage]; } // Return nil if menuItem has no delegate. @@ -228,6 +241,27 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; menuTagMap_.clear(); } +- (int)preferredHeight { + return [self isAlwaysVisible] ? kBookmarkBarHeight : kNTPBookmarkBarHeight; +} + +- (void)selectTabWithContents:(TabContents*)newContents + previousContents:(TabContents*)oldContents + atIndex:(NSInteger)index + userGesture:(bool)wasUserGesture { + // We need selectTabWithContents: for when we change from a tab that is the + // new tab page to a tab that isn't. + [self updateVisibility]; +} + +- (void)tabChangedWithContents:(TabContents*)contents + atIndex:(NSInteger)index + loadingOnly:(BOOL)loading { + // We need tabChangedWithContents: for when the user clicks a bookmark from + // the bookmark bar on the new tab page. + [self updateVisibility]; +} + // Recursively add the given bookmark node and all its children to // menu, one menu item per node. - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu { @@ -382,7 +416,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; // for the other platforms but can't find a way to trigger it in the // UI. BookmarkEditor::Show([[[self view] window] contentView], - profile_, + browser_->profile(), node->GetParent(), node, BookmarkEditor::SHOW_TREE, @@ -433,7 +467,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; if (!parent) parent = bookmarkModel_->GetBookmarkBarNode(); BookmarkEditor::Show([[[self view] window] contentView], - profile_, + browser_->profile(), parent, nil, BookmarkEditor::SHOW_TREE, @@ -447,7 +481,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; BookmarkNameFolderController* controller = [[BookmarkNameFolderController alloc] initWithParentWindow:[[self view] window] - profile:profile_ + profile:browser_->profile() node:node]; [controller runAsModalSheet]; @@ -610,8 +644,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; // TODO(jrg): for now this is brute force. - (void)loaded:(BookmarkModel*)model { DCHECK(model == bookmarkModel_); - // Do nothing if not active or too early - if ((barShouldBeShown_ == NO) || !model->IsLoaded()) + if (!model->IsLoaded()) return; // Else brute force nuke and build. const BookmarkNode* node = model->GetBookmarkBarNode(); diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index bc72e65..5da3d0a 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -10,8 +10,10 @@ #import "chrome/browser/cocoa/bookmark_bar_view.h" #include "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" +#import "chrome/browser/cocoa/toolbar_compressable.h" #include "chrome/browser/cocoa/test_event_utils.h" #import "chrome/browser/cocoa/view_resizer_pong.h" +#include "chrome/common/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -76,6 +78,33 @@ @end +// A BookmarkBarController that always beleives that it's on the new tab page. +@interface AlwaysNewTabPageBookmarkBarController : BookmarkBarController { +} +@end + +@implementation AlwaysNewTabPageBookmarkBarController +-(BOOL)isNewTabPage { + return YES; +} +@end + +@interface CompressablePong : NSObject<ToolbarCompressable> { +@private + BOOL compressed_; +} +@property (readonly) BOOL compressed; +@end + +@implementation CompressablePong + +@synthesize compressed = compressed_; + +- (void)setShouldBeCompressed:(BOOL)compressed { + compressed_ = compressed; +} + +@end namespace { @@ -86,12 +115,14 @@ class BookmarkBarControllerTest : public PlatformTest { public: BookmarkBarControllerTest() { resizeDelegate_.reset([[ViewResizerPong alloc] init]); + compressDelegate_.reset([[CompressablePong alloc] init]); NSRect parent_frame = NSMakeRect(0, 0, 800, 50); parent_view_.reset([[NSView alloc] initWithFrame:parent_frame]); [parent_view_ setHidden:YES]; bar_.reset( - [[BookmarkBarController alloc] initWithProfile:helper_.profile() + [[BookmarkBarController alloc] initWithBrowser:helper_.browser() initialWidth:NSWidth(parent_frame) + compressDelegate:compressDelegate_.get() resizeDelegate:resizeDelegate_.get() urlDelegate:nil]); @@ -118,10 +149,9 @@ class BookmarkBarControllerTest : public PlatformTest { [[[bar view] superview] setFrame:frame]; // make sure it's open so certain things aren't no-ops - [bar toggleBookmarkBar]; + helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); } - // Return a menu item that points to the right URL. NSMenuItem* ItemForBookmarkBarMenu(GURL& gurl) { node_.reset(new BookmarkNode(gurl)); @@ -140,6 +170,7 @@ class BookmarkBarControllerTest : public PlatformTest { scoped_nsobject<NSView> parent_view_; BrowserTestHelper helper_; scoped_nsobject<ViewResizerPong> resizeDelegate_; + scoped_nsobject<CompressablePong> compressDelegate_; scoped_nsobject<BookmarkBarController> bar_; scoped_nsobject<NSMenu> menu_; scoped_nsobject<NSMenuItem> menu_item_; @@ -147,45 +178,77 @@ class BookmarkBarControllerTest : public PlatformTest { scoped_ptr<BookmarkNode> node_; }; -TEST_F(BookmarkBarControllerTest, ShowHide) { - // The test class opens the bar by default since many actions are - // no-ops with it closed. Set back to closed as a baseline. - if ([bar_ isBookmarkBarVisible]) - [bar_ toggleBookmarkBar]; - - // Start hidden. - EXPECT_FALSE([bar_ isBookmarkBarVisible]); - EXPECT_TRUE([[bar_ view] isHidden]); +TEST_F(BookmarkBarControllerTest, ShowWhenShowBookmarkBarTrue) { + helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); + [bar_ updateVisibility]; - // Show and hide it by toggling. - [bar_ toggleBookmarkBar]; - EXPECT_TRUE([bar_ isBookmarkBarVisible]); + EXPECT_TRUE([bar_ isVisible]); EXPECT_FALSE([[bar_ view] isHidden]); EXPECT_GT([resizeDelegate_ height], 0); EXPECT_GT([[bar_ view] frame].size.height, 0); +} + +TEST_F(BookmarkBarControllerTest, HideWhenShowBookmarkBarFalse) { + helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); + [bar_ updateVisibility]; - [bar_ toggleBookmarkBar]; - EXPECT_FALSE([bar_ isBookmarkBarVisible]); + EXPECT_FALSE([bar_ isVisible]); EXPECT_TRUE([[bar_ view] isHidden]); EXPECT_EQ(0, [resizeDelegate_ height]); EXPECT_EQ(0, [[bar_ view] frame].size.height); } +TEST_F(BookmarkBarControllerTest, HideWhenShowBookmarkBarTrueButDisabled) { + helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); + [bar_ setBookmarkBarEnabled:NO]; + [bar_ updateVisibility]; + + EXPECT_FALSE([bar_ isVisible]); + EXPECT_TRUE([[bar_ view] isHidden]); + EXPECT_EQ(0, [resizeDelegate_ height]); + EXPECT_EQ(0, [[bar_ view] frame].size.height); +} + +TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { + helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); + + scoped_nsobject<BookmarkBarControllerTogglePong> bar; + bar.reset( + [[AlwaysNewTabPageBookmarkBarController alloc] + initWithBrowser:helper_.browser() + initialWidth:100 // arbitrary + compressDelegate:compressDelegate_.get() + resizeDelegate:resizeDelegate_.get() + urlDelegate:nil]); + InstallAndToggleBar(bar.get()); + + [bar setBookmarkBarEnabled:NO]; + [bar updateVisibility]; + + EXPECT_TRUE([bar isVisible]); + EXPECT_FALSE([[bar view] isHidden]); + EXPECT_GT([resizeDelegate_ height], 0); + EXPECT_GT([[bar view] frame].size.height, 0); +} + // Make sure we're watching for frame change notifications. TEST_F(BookmarkBarControllerTest, FrameChangeNotification) { scoped_nsobject<BookmarkBarControllerTogglePong> bar; bar.reset( [[BookmarkBarControllerTogglePong alloc] - initWithProfile:helper_.profile() + initWithBrowser:helper_.browser() initialWidth:100 // arbitrary + compressDelegate:compressDelegate_.get() resizeDelegate:resizeDelegate_.get() urlDelegate:nil]); InstallAndToggleBar(bar.get()); - EXPECT_GT([bar toggles], 0); + // Send a frame did change notification for the pong's view. + [[NSNotificationCenter defaultCenter] + postNotificationName:NSViewFrameDidChangeNotification + object:[bar view]]; - // Hard to force toggles -- simple whacking the frame is inadequate. - // TODO(jrg): find a way to set frame, force a toggle, and verify it. + EXPECT_GT([bar toggles], 0); } // Confirm off the side button only enabled when reasonable. diff --git a/chrome/browser/cocoa/bookmark_bar_toolbar_view.h b/chrome/browser/cocoa/bookmark_bar_toolbar_view.h new file mode 100644 index 0000000..2808cc5 --- /dev/null +++ b/chrome/browser/cocoa/bookmark_bar_toolbar_view.h @@ -0,0 +1,25 @@ +// Copyright (c) 2009 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. + +// The BookmarkBarToolbarView is responsible for drawing the background of the +// BookmarkBar's toolbar in either of its two display modes - permanently +// attached (slimline with a stroke at the bottom edge) or New Tab Page style +// (padded with a round rect border and the New Tab Page theme behind). + +#ifndef CHROME_BROWSER_COCOA_BOOKMARK_BAR_TOOLBAR_VIEW_H_ +#define CHROME_BROWSER_COCOA_BOOKMARK_BAR_TOOLBAR_VIEW_H_ + +#import <Cocoa/Cocoa.h> + +#import "chrome/browser/cocoa/background_gradient_view.h" + +@protocol BookmarkBarFloating; + +@interface BookmarkBarToolbarView : BackgroundGradientView { + @private + IBOutlet id<BookmarkBarFloating> controller_; +} +@end + +#endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_TOOLBAR_VIEW_H_ diff --git a/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm b/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm new file mode 100644 index 0000000..e40607b --- /dev/null +++ b/chrome/browser/cocoa/bookmark_bar_toolbar_view.mm @@ -0,0 +1,21 @@ +// Copyright (c) 2009 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/cocoa/bookmark_bar_toolbar_view.h" + +#import "chrome/browser/cocoa/bookmark_bar_controller.h" + +@implementation BookmarkBarToolbarView + +- (void)drawRect:(NSRect)rect { + if ([controller_ drawAsFloatingBar]) { + // TODO(erg): Deal with themes. http://crbug.com/17625 + [[NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0] set]; + NSRectFill(rect); + } else { + [super drawRect:rect]; + } +} + +@end // @implementation BookmarkBarToolbarView diff --git a/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm b/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm new file mode 100644 index 0000000..8a2d6ef --- /dev/null +++ b/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm @@ -0,0 +1,70 @@ +// Copyright (c) 2009 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> + +#include "base/scoped_nsobject.h" +#import "chrome/browser/cocoa/bookmark_bar_controller.h" +#import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" + +// Allows us to inject our fake controller below. +@interface BookmarkBarToolbarView (TestingAPI) +-(void)setController:(id<BookmarkBarFloating>)controller; +@end + +@implementation BookmarkBarToolbarView (TestingAPI) +-(void)setController:(id<BookmarkBarFloating>)controller { + controller_ = controller; +} +@end + +// Allows us to control which way the view is rendered. +@interface DrawFloatingFakeController : + NSObject<BookmarkBarFloating> { + BOOL drawAsFloating_; +} +@property(assign) BOOL drawAsFloatingBar; +@end + +@implementation DrawFloatingFakeController +@synthesize drawAsFloatingBar = drawAsFloating_; +@end + +class BookmarkBarToolbarViewTest : public PlatformTest { + public: + BookmarkBarToolbarViewTest() { + controller_.reset([[DrawFloatingFakeController alloc] init]); + NSRect frame = NSMakeRect(0, 0, 100, 30); + view_.reset([[BookmarkBarToolbarView alloc] initWithFrame:frame]); + [cocoa_helper_.contentView() addSubview:view_.get()]; + [view_.get() setController:controller_.get()]; + } + + CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + scoped_nsobject<DrawFloatingFakeController> controller_; + scoped_nsobject<BookmarkBarToolbarView> view_; +}; + +// Test adding/removing from the view hierarchy, mostly to ensure nothing +// leaks or crashes. +TEST_F(BookmarkBarToolbarViewTest, AddRemove) { + EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); + [view_.get() removeFromSuperview]; + EXPECT_FALSE([view_ superview]); +} + +// Test drawing (part 1), mostly to ensure nothing leaks or crashes. +TEST_F(BookmarkBarToolbarViewTest, DisplayAsNormalBar) { + [controller_.get() setDrawAsFloatingBar:NO]; + [view_ display]; +} + +// Test drawing (part 2), mostly to ensure nothing leaks or crashes. +TEST_F(BookmarkBarToolbarViewTest, DisplayAsDisconnectedBar) { + [controller_.get() setDrawAsFloatingBar:YES]; + [view_ display]; +} diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 3afae7e..33809ad 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -333,7 +333,7 @@ void BrowserWindowCocoa::Observe(NotificationType type, // Only the key window gets a direct toggle from the menu. // Other windows hear about it from the notification. case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: - [controller_ toggleBookmarkBar]; + [controller_ updateBookmarkBarVisibility]; break; default: NOTREACHED(); // we don't ask for anything else! diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index b4700b4..76223de 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -67,6 +67,7 @@ class TabStripModelObserverBridge; scoped_ptr<StatusBubble> statusBubble_; scoped_nsobject<DownloadShelfController> downloadShelfController_; scoped_nsobject<ExtensionShelfController> extensionShelfController_; + scoped_nsobject<BookmarkBarController> bookmarkBarController_; scoped_nsobject<BookmarkBubbleController> bookmarkBubbleController_; scoped_nsobject<GTMTheme> theme_; BOOL ownsBrowser_; // Only ever NO when testing @@ -113,7 +114,8 @@ class TabStripModelObserverBridge; - (BOOL)isBookmarkBarVisible; -- (void)toggleBookmarkBar; +// Called after the visibility perf changed. +- (void)updateBookmarkBarVisibility; - (BOOL)isDownloadShelfVisible; diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 43ffa11..542d5d2 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -181,8 +181,7 @@ willPositionSheet:(NSWindow*)sheet commands:browser->command_updater() profile:browser->profile() browser:browser - resizeDelegate:self - bookmarkDelegate:self]); + resizeDelegate:self]); // If we are a pop-up, we have a titlebar and no toolbar. if (!browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) && browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR)) { @@ -190,6 +189,26 @@ willPositionSheet:(NSWindow*)sheet } [[[self window] contentView] addSubview:[toolbarController_ view]]; + // Create a sub-controller for the bookmark bar. + bookmarkBarController_.reset( + [[BookmarkBarController alloc] + initWithBrowser:browser_.get() + initialWidth:NSWidth([[[self window] contentView] frame]) + compressDelegate:toolbarController_.get() + resizeDelegate:self + urlDelegate:self]); + + // Add bookmark bar to the view hierarchy. This also triggers the + // nib load. The bookmark bar is defined (in the nib) to be + // bottom-aligned to it's parent view (among other things), so + // position and resize properties don't need to be set. + [[[self window] contentView] addSubview:[bookmarkBarController_ view]]; + + // We don't want to try and show the bar before it gets placed in + // it's parent view, so this step shoudn't be inside the bookmark + // bar controller's awakeFromNib. + [bookmarkBarController_ showIfNeeded]; + if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { // Create the extension shelf. extensionShelfController_.reset([[ExtensionShelfController alloc] @@ -457,12 +476,14 @@ willPositionSheet:(NSWindow*)sheet // relayout. - (void)resizeView:(NSView*)view newHeight:(float)height { // We should only ever be called for one of the following four views. - // |downloadShelfController_| may be nil. + // |downloadShelfController_| may be nil. If we are asked to size the bookmark + // bar directly, its superview must be this controller's content view. DCHECK(view); DCHECK(view == [toolbarController_ view] || view == [infoBarContainerController_ view] || + view == [extensionShelfController_ view] || view == [downloadShelfController_ view] || - view == [extensionShelfController_ view]); + view == [bookmarkBarController_ view]); // Change the height of the view and call layoutViews. We set the height here // without regard to where the view is on the screen or whether it needs to @@ -816,12 +837,11 @@ willPositionSheet:(NSWindow*)sheet } - (BOOL)isBookmarkBarVisible { - return [[toolbarController_ bookmarkBarController] isBookmarkBarVisible]; + return [bookmarkBarController_ isVisible]; } -- (void)toggleBookmarkBar { - BookmarkBarController* bar = [toolbarController_ bookmarkBarController]; - [bar toggleBookmarkBar]; +- (void)updateBookmarkBarVisibility { + [bookmarkBarController_ updateVisibility]; } - (BOOL)isDownloadShelfVisible { @@ -858,8 +878,7 @@ willPositionSheet:(NSWindow*)sheet if (fullscreen) { // Disable showing of the bookmark bar. This does not toggle the // preference. - // TODO(jrg): Is this still necessary? - [[toolbarController_ bookmarkBarController] setBookmarkBarEnabled:NO]; + [bookmarkBarController_ setBookmarkBarEnabled:NO]; // Make room for more content area. [[toolbarController_ view] removeFromSuperview]; // Hide the menubar, and allow it to un-hide when moving the mouse @@ -869,8 +888,7 @@ willPositionSheet:(NSWindow*)sheet } else { SetSystemUIMode(kUIModeNormal, 0); [[[self window] contentView] addSubview:[toolbarController_ view]]; - // TODO(jrg): Is this still necessary? - [[toolbarController_ bookmarkBarController] setBookmarkBarEnabled:YES]; + [bookmarkBarController_ setBookmarkBarEnabled:YES]; } // Force a relayout. @@ -973,6 +991,7 @@ willPositionSheet:(NSWindow*)sheet // Update all the UI bits. windowShim_->UpdateTitleBar(); + #if 0 // TODO(pinkerton):Update as more things become window-specific toolbar_->SetProfile(newContents->profile()); @@ -1224,6 +1243,16 @@ willPositionSheet:(NSWindow*)sheet } [toolbarView setFrame:toolbarFrame]; + if ([bookmarkBarController_ isAlwaysVisible]) { + NSView* bookmarkBarView = [bookmarkBarController_ view]; + [bookmarkBarView setHidden:NO]; + NSRect bookmarkBarFrame = [bookmarkBarView frame]; + bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame); + bookmarkBarFrame.size.width = NSWidth(contentFrame); + [bookmarkBarView setFrame:bookmarkBarFrame]; + maxY -= NSHeight(bookmarkBarFrame); + } + // Place the infobar container in place below the toolbar. NSView* infoBarView = [infoBarContainerController_ view]; NSRect infoBarFrame = [infoBarView frame]; @@ -1232,6 +1261,23 @@ willPositionSheet:(NSWindow*)sheet [infoBarView setFrame:infoBarFrame]; maxY -= NSHeight(infoBarFrame); + if (![bookmarkBarController_ isAlwaysVisible] && + [bookmarkBarController_ isVisible]) { + NSView* bookmarkBarView = [bookmarkBarController_ view]; + [bookmarkBarView setHidden:NO]; + NSRect bookmarkBarFrame = [bookmarkBarView frame]; + bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame); + bookmarkBarFrame.size.width = NSWidth(contentFrame); + [bookmarkBarView setFrame:bookmarkBarFrame]; + maxY -= NSHeight(bookmarkBarFrame); + } + + if (![bookmarkBarController_ isVisible]) { + // If the bookmark bar is not visible in either mode, we need to hide it + // otherwise it'll render over other elements. + [[bookmarkBarController_ view] setHidden:YES]; + } + // Place the extension shelf at the bottom of the view, if it exists. if (extensionShelfController_.get()) { NSView* extensionView = [extensionShelfController_ view]; @@ -1265,6 +1311,16 @@ willPositionSheet:(NSWindow*)sheet positionFindBarView:[infoBarContainerController_ view]]; verticalOffsetForStatusBubble_ = minY; + + // The bottom of the visible toolbar stack is the one that shows the + // divider stroke. If the bookmark bar is visible and not in new tab page + // mode, it is the bottom visible toolbar and so it must, otherwise the + // main toolbar is. + BOOL bookmarkToolbarShowsDivider = [bookmarkBarController_ isAlwaysVisible]; + [[toolbarController_ backgroundGradientView] + setShowsDivider:!bookmarkToolbarShowsDivider]; + [[bookmarkBarController_ backgroundGradientView] + setShowsDivider:bookmarkToolbarShowsDivider]; } @end diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm index f5b4d3e..5df2fdd 100644 --- a/chrome/browser/cocoa/browser_window_controller_unittest.mm +++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm @@ -25,6 +25,8 @@ // Implementations are below. - (NSView*)infoBarContainerView; - (NSView*)toolbarView; +- (NSView*)bookmarkView; +- (BOOL)bookmarkBarVisible; - (NSView*)extensionShelfView; @end @@ -37,6 +39,14 @@ return [toolbarController_ view]; } +- (NSView*)bookmarkView { + return [bookmarkBarController_ view]; +} + +- (BOOL)bookmarkBarVisible { + return [bookmarkBarController_ isVisible]; +} + - (NSView*)extensionShelfView { return [extensionShelfController_ view]; } @@ -146,7 +156,13 @@ TEST_F(BrowserWindowControllerTest, TestTheme) { TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) { EXPECT_FALSE([controller_ isBookmarkBarVisible]); - [controller_ toggleBookmarkBar]; + + // Explicitly show the bar. Can't use bookmark_utils::ToggleWhenVisible() + // because of the notification issues. + browser_helper_.profile()->GetPrefs()-> + SetBoolean(prefs::kShowBookmarkBar, true); + + [controller_ updateBookmarkBarVisibility]; EXPECT_TRUE([controller_ isBookmarkBarVisible]); } @@ -186,7 +202,16 @@ void CheckViewPositions(BrowserWindowController* controller) { EXPECT_EQ(NSMaxY(extension), NSMinY(download)); EXPECT_EQ(NSMaxY(download), NSMinY(contentArea)); EXPECT_EQ(NSMaxY(contentArea), NSMinY(infobar)); - EXPECT_EQ(NSMaxY(infobar), NSMinY(toolbar)); + + // Bookmark bar frame is random memory when hidden. + if ([controller bookmarkBarVisible]) { + NSRect bookmark = [[controller bookmarkView] frame]; + EXPECT_EQ(NSMaxY(infobar), NSMinY(bookmark)); + EXPECT_EQ(NSMaxY(bookmark), NSMinY(toolbar)); + } else { + EXPECT_EQ(NSMaxY(infobar), NSMinY(toolbar)); + } + EXPECT_EQ(NSMaxY(contentView), NSMaxY(toolbar)); } } // end namespace @@ -240,6 +265,83 @@ TEST_F(BrowserWindowControllerTest, TestResizeViews) { CheckViewPositions(controller_); } +TEST_F(BrowserWindowControllerTest, TestResizeViewsWithBookmarkBar) { + // Force a display of the bookmark bar. + browser_helper_.profile()->GetPrefs()-> + SetBoolean(prefs::kShowBookmarkBar, true); + + TabStripView* tabstrip = [controller_ tabStripView]; + NSView* contentView = [[tabstrip window] contentView]; + NSView* toolbar = [controller_ toolbarView]; + NSView* bookmark = [controller_ bookmarkView]; + NSView* infobar = [controller_ infoBarContainerView]; + NSView* extensionShelf = [controller_ extensionShelfView]; + + // We need to muck with the views a bit to put us in a consistent state before + // we start resizing. In particular, we need to move the tab strip to be + // immediately above the content area, since we layout views to be directly + // under the tab strip. We also explicitly set the contentView's frame to be + // 800x600. + [contentView setFrame:NSMakeRect(0, 0, 800, 600)]; + NSRect tabstripFrame = [tabstrip frame]; + tabstripFrame.origin.y = NSMaxY([contentView frame]); + [tabstrip setFrame:tabstripFrame]; + + // The download shelf is created lazily. Force-create it and set its initial + // height to 0. + NSView* download = [[controller_ downloadShelf] view]; + [controller_ resizeView:download newHeight:0]; + + // Force a layout and check each view's frame. + [controller_ layoutSubviews]; + CheckViewPositions(controller_); + + // Add the bookmark bar and recheck. + [controller_ resizeView:bookmark newHeight:40]; + CheckViewPositions(controller_); + + // Add an extension shelf and recheck. + [controller_ resizeView:extensionShelf newHeight:40]; + CheckViewPositions(controller_); + + // Expand the infobar to 60px and recheck + [controller_ resizeView:infobar newHeight:60]; + CheckViewPositions(controller_); + + // Expand the toolbar to 64px and recheck + [controller_ resizeView:toolbar newHeight:64]; + CheckViewPositions(controller_); + + // Add a 30px download shelf and recheck + [controller_ resizeView:download newHeight:30]; + CheckViewPositions(controller_); + + // Remove the bookmark bar and recheck + browser_helper_.profile()->GetPrefs()-> + SetBoolean(prefs::kShowBookmarkBar, false); + [controller_ resizeView:bookmark newHeight:0]; + CheckViewPositions(controller_); + + // Shrink the infobar to 0px and toolbar to 39px and recheck + [controller_ resizeView:infobar newHeight:0]; + [controller_ resizeView:toolbar newHeight:39]; + CheckViewPositions(controller_); +} + +// Make sure, by default, the bookmark bar and the toolbar are the same width. +TEST_F(BrowserWindowControllerTest, BookmarkBarIsSameWidth) { + // Set the pref to the bookmark bar is visible when the toolbar is + // first created. + browser_helper_.profile()->GetPrefs()->SetBoolean( + prefs::kShowBookmarkBar, true); + + // Make sure the bookmark bar is the same width as the toolbar + NSView* bookmarkBarView = [controller_ bookmarkView]; + NSView* toolbarView = [controller_ toolbarView]; + EXPECT_EQ([toolbarView frame].size.width, + [bookmarkBarView frame].size.width); +} + TEST_F(BrowserWindowControllerTest, TestTopLeftForBubble) { NSPoint p = [controller_ topLeftForBubble]; NSRect all = [[controller_ window] frame]; diff --git a/chrome/browser/cocoa/toolbar_compressable.h b/chrome/browser/cocoa/toolbar_compressable.h new file mode 100644 index 0000000..ddd21c4 --- /dev/null +++ b/chrome/browser/cocoa/toolbar_compressable.h @@ -0,0 +1,19 @@ +// Copyright (c) 2009 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_COCOA_TOOLBAR_COMPRESSABLE_H_ +#define CHROME_BROWSER_COCOA_TOOLBAR_COMPRESSABLE_H_ + +#include "chrome/browser/tabs/tab_strip_model.h" + +#import <Cocoa/Cocoa.h> + +// Defines a protocol that allows one view to tell another view that it should +// remove pixels from the bottom of the view. Only ToolbarController implements +// this, but it's a protocol for unit testing reasons. +@protocol ToolbarCompressable +- (void)setShouldBeCompressed:(BOOL)compressed; +@end + +#endif // CHROME_BROWSER_COCOA_TOOLBAR_COMPRESSABLE_H_ diff --git a/chrome/browser/cocoa/toolbar_controller.h b/chrome/browser/cocoa/toolbar_controller.h index 71467433..6af4241 100644 --- a/chrome/browser/cocoa/toolbar_controller.h +++ b/chrome/browser/cocoa/toolbar_controller.h @@ -10,7 +10,7 @@ #include "base/scoped_ptr.h" #include "base/scoped_nsobject.h" #import "chrome/browser/cocoa/command_observer_bridge.h" -#import "chrome/browser/cocoa/bookmark_bar_controller.h" +#import "chrome/browser/cocoa/toolbar_compressable.h" #import "chrome/browser/cocoa/delayedmenu_button.h" #import "chrome/browser/cocoa/view_resizer.h" #include "chrome/common/pref_member.h" @@ -18,6 +18,7 @@ @class AutocompleteTextField; @class AutocompleteTextFieldEditor; @class BackForwardMenuController; +@class BackgroundGradientView; class Browser; class BubblePositioner; class CommandUpdater; @@ -39,7 +40,7 @@ class ToolbarView; // the web content view. @interface ToolbarController : - NSViewController<CommandObserverProtocol, ViewResizer> { + NSViewController<CommandObserverProtocol, ToolbarCompressable> { @private ToolbarModel* toolbarModel_; // weak, one per window CommandUpdater* commands_; // weak, one per window @@ -48,9 +49,7 @@ class ToolbarView; scoped_ptr<CommandObserverBridge> commandObserver_; scoped_ptr<LocationBarViewMac> locationBarView_; scoped_nsobject<AutocompleteTextFieldEditor> autocompleteTextFieldEditor_; - scoped_nsobject<BookmarkBarController> bookmarkBarController_; id<ViewResizer> resizeDelegate_; // weak - id<BookmarkURLOpener> bookmarkBarDelegate_; // weak scoped_nsobject<BackForwardMenuController> backMenuController_; scoped_nsobject<BackForwardMenuController> forwardMenuController_; @@ -98,8 +97,7 @@ class ToolbarView; commands:(CommandUpdater*)commands profile:(Profile*)profile browser:(Browser*)browser - resizeDelegate:(id<ViewResizer>)resizeDelegate - bookmarkDelegate:(id<BookmarkURLOpener>)delegate; + resizeDelegate:(id<ViewResizer>)resizeDelegate; // Get the C++ bridge object representing the location bar for this tab. - (LocationBar*)locationBar; @@ -110,6 +108,9 @@ class ToolbarView; // returns nil if we don't want to override the custom field editor for |obj|. - (id)customFieldEditorForObject:(id)obj; +// Returns the backdrop to the toolbar. +- (BackgroundGradientView*)backgroundGradientView; + // Make the location bar the first responder, if possible. - (void)focusLocationBar; @@ -132,9 +133,6 @@ class ToolbarView; // [self view]. - (void)setHasToolbar:(BOOL)toolbar; -// Return the bookmark bar controller. -- (BookmarkBarController*)bookmarkBarController; - // The bookmark bubble (when you click the star) needs to know where to go. // Somewhere near the star button seems like a good start. - (NSRect)starButtonInWindowCoordinates; diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index c36d9e1..ed726f8 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -36,7 +36,7 @@ static NSString* const kStarredImageName = @"starred.pdf"; static const float kBaseToolbarHeight = 36.0; // Overlap (in pixels) between the toolbar and the bookmark bar. -static const float kBookmarkBarOverlap = 7.0; +static const float kBookmarkBarOverlap = 6.0; @interface ToolbarController(Private) - (void)initCommandStatus:(CommandUpdater*)commands; @@ -90,8 +90,7 @@ class PrefObserverBridge : public NotificationObserver { commands:(CommandUpdater*)commands profile:(Profile*)profile browser:(Browser*)browser - resizeDelegate:(id<ViewResizer>)resizeDelegate - bookmarkDelegate:(id<BookmarkURLOpener>)delegate { + resizeDelegate:(id<ViewResizer>)resizeDelegate { DCHECK(model && commands && profile); if ((self = [super initWithNibName:@"Toolbar" bundle:mac_util::MainAppBundle()])) { @@ -100,7 +99,6 @@ class PrefObserverBridge : public NotificationObserver { profile_ = profile; browser_ = browser; resizeDelegate_ = resizeDelegate; - bookmarkBarDelegate_ = delegate; hasToolbar_ = YES; // Register for notificaotions about state changes for the toolbar buttons @@ -146,24 +144,6 @@ class PrefObserverBridge : public NotificationObserver { [self showOptionalHomeButton]; [self showOptionalPageWrenchButtons]; - // Create a sub-controller for the bookmark bar. - bookmarkBarController_.reset([[BookmarkBarController alloc] - initWithProfile:profile_ - initialWidth:NSWidth([[self view] frame]) - resizeDelegate:self - urlDelegate:bookmarkBarDelegate_]); - - // Add bookmark bar to the view hierarchy. This also triggers the - // nib load. The bookmark bar is defined (in the nib) to be - // bottom-aligned to it's parent view (among other things), so - // position and resize properties don't need to be set. - [[self view] addSubview:[bookmarkBarController_ view]]; - - // We don't want to try and show the bar before it gets placed in - // it's parent view, so this step shoudn't be inside the bookmark - // bar controller's awakeFromNib. - [bookmarkBarController_ showIfNeeded]; - // Create the controllers for the back/forward menus. backMenuController_.reset([[BackForwardMenuController alloc] initWithBrowser:browser_ @@ -235,22 +215,6 @@ class PrefObserverBridge : public NotificationObserver { [self mouseMoved:event]; } -- (void)resizeView:(NSView*)view newHeight:(float)height { - DCHECK(view == [bookmarkBarController_ view]); - - // The bookmark bar is always rooted at the bottom of the toolbar view, with - // width equal to the toolbar's width. The toolbar view is resized to - // accomodate the new bookmark bar height. - NSRect frame = NSMakeRect(0, 0, [[self view] bounds].size.width, height); - [view setFrame:frame]; - - float newToolbarHeight = kBaseToolbarHeight + height - kBookmarkBarOverlap; - if (newToolbarHeight < kBaseToolbarHeight) - newToolbarHeight = kBaseToolbarHeight; - - [resizeDelegate_ resizeView:[self view] newHeight:newToolbarHeight]; -} - - (LocationBar*)locationBar { return locationBarView_.get(); } @@ -349,14 +313,8 @@ class PrefObserverBridge : public NotificationObserver { return locationBar_; } -- (BookmarkBarController*)bookmarkBarController { - // Browser has a FEATURE_BOOKMARKBAR but it is ignored by Safari - // when using window.open(); the logic seems to be "if no toolbar, - // no bookmark bar". - // TODO(jrg): investigate non-Mac Chrome behavior and possibly expand this. - if (hasToolbar_ == NO) - return nil; - return bookmarkBarController_.get(); +- (BackgroundGradientView*)backgroundGradientView { + return (BackgroundGradientView*)[super view]; } - (id)customFieldEditorForObject:(id)obj { @@ -467,6 +425,14 @@ class PrefObserverBridge : public NotificationObserver { fromView:starButton_]; } +- (void)setShouldBeCompressed:(BOOL)compressed { + CGFloat newToolbarHeight = kBaseToolbarHeight; + if (compressed) + newToolbarHeight -= kBookmarkBarOverlap; + + [resizeDelegate_ resizeView:[self view] newHeight:newToolbarHeight]; +} + - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm index fbcb0af..b27eafd 100644 --- a/chrome/browser/cocoa/toolbar_controller_unittest.mm +++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm @@ -60,8 +60,7 @@ class ToolbarControllerTest : public PlatformTest { commands:browser->command_updater() profile:helper_.profile() browser:browser - resizeDelegate:resizeDelegate_.get() - bookmarkDelegate:nil]); + resizeDelegate:resizeDelegate_.get()]); EXPECT_TRUE([bar_ view]); NSView* parent = [cocoa_helper_.window() contentView]; [parent addSubview:[bar_ view]]; @@ -94,19 +93,12 @@ TEST_F(ToolbarControllerTest, InitialState) { CompareState(updater, [bar_ toolbarViews]); } -// Make sure awakeFromNib created a bookmarkBarController -TEST_F(ToolbarControllerTest, AwakeFromNibCreatesBMBController) { - EXPECT_TRUE([bar_ bookmarkBarController]); -} - // Make sure a "titlebar only" toolbar works TEST_F(ToolbarControllerTest, TitlebarOnly) { NSView* view = [bar_ view]; - EXPECT_TRUE([bar_ bookmarkBarController]); [bar_ setHasToolbar:NO]; EXPECT_NE(view, [bar_ view]); - EXPECT_FALSE([bar_ bookmarkBarController]); // Simulate a popup going fullscreen and back. NSView* superview = [view superview]; @@ -118,7 +110,6 @@ TEST_F(ToolbarControllerTest, TitlebarOnly) { [bar_ setHasToolbar:YES]; EXPECT_EQ(view, [bar_ view]); - EXPECT_TRUE([bar_ bookmarkBarController]); // Leave it off to make sure that's fine [bar_ setHasToolbar:NO]; @@ -240,31 +231,6 @@ TEST_F(ToolbarControllerTest, DontToggleWhenNoToolbar) { EXPECT_TRUE(NSEqualRects(locationBarFrame, newLocationBarFrame)); } -// Make sure, by default, the bookmark bar is the full width of the -// toolbar. -TEST_F(ToolbarControllerTest, BookmarkBarIsFullWidth) { - // Set the pref to the bookmark bar is visible when the toolbar is - // first created. - helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); - - // Create a new bar (after the pref is set) - Browser* browser = helper_.browser(); - bar_.reset( - [[ToolbarController alloc] initWithModel:browser->toolbar_model() - commands:browser->command_updater() - profile:helper_.profile() - browser:browser - resizeDelegate:resizeDelegate_.get() - bookmarkDelegate:nil]); - EXPECT_TRUE([bar_ view]); - - // Make sure the bookmark bar is the same width as the toolbar - NSView* bookmarkBarView = [[bar_ bookmarkBarController] view]; - EXPECT_EQ([[bar_ view] frame].size.width, - [bookmarkBarView frame].size.width); - EXPECT_TRUE([bookmarkBarView isDescendantOf:[bar_ view]]); -} - TEST_F(ToolbarControllerTest, StarButtonInWindowCoordinates) { NSRect star = [bar_ starButtonInWindowCoordinates]; NSRect all = [[[bar_ view] window] frame]; @@ -329,4 +295,14 @@ TEST_F(ToolbarControllerTest, PopulateEncodingMenu) { EXPECT_NE(0, [encodings numberOfItems]); } +TEST_F(ToolbarControllerTest, CorrectHeightWhenCompressed) { + [bar_ setShouldBeCompressed:YES]; + EXPECT_EQ(30.0, [resizeDelegate_ height]); +} + +TEST_F(ToolbarControllerTest, CorrectHeightWhenUnompressed) { + [bar_ setShouldBeCompressed:NO]; + EXPECT_EQ(36.0, [resizeDelegate_ height]); +} + } // namespace diff --git a/chrome/browser/dom_ui/dom_ui_unittest.cc b/chrome/browser/dom_ui/dom_ui_unittest.cc index 665c7c5..712a2df 100644 --- a/chrome/browser/dom_ui/dom_ui_unittest.cc +++ b/chrome/browser/dom_ui/dom_ui_unittest.cc @@ -29,7 +29,7 @@ class DOMUITest : public RenderViewHostTestHarness { // Check the things the pending DOM UI should have set. EXPECT_FALSE(contents->ShouldDisplayURL()); EXPECT_FALSE(contents->ShouldDisplayFavIcon()); - EXPECT_TRUE(contents->IsBookmarkBarAlwaysVisible()); + EXPECT_TRUE(contents->ShouldShowBookmarkBar()); EXPECT_TRUE(contents->FocusLocationBarByDefault()); // Now commit the load. @@ -39,7 +39,7 @@ class DOMUITest : public RenderViewHostTestHarness { // The same flags should be set as before now that the load has committed. EXPECT_FALSE(contents->ShouldDisplayURL()); EXPECT_FALSE(contents->ShouldDisplayFavIcon()); - EXPECT_TRUE(contents->IsBookmarkBarAlwaysVisible()); + EXPECT_TRUE(contents->ShouldShowBookmarkBar()); EXPECT_TRUE(contents->FocusLocationBarByDefault()); // Start a pending navigation to a regular page. @@ -50,7 +50,7 @@ class DOMUITest : public RenderViewHostTestHarness { // should reflect the old one (bookmark bar) until it has committed. EXPECT_TRUE(contents->ShouldDisplayURL()); EXPECT_TRUE(contents->ShouldDisplayFavIcon()); - EXPECT_TRUE(contents->IsBookmarkBarAlwaysVisible()); + EXPECT_TRUE(contents->ShouldShowBookmarkBar()); EXPECT_FALSE(contents->FocusLocationBarByDefault()); // Commit the regular page load. Note that we must send it to the "pending" @@ -70,7 +70,7 @@ class DOMUITest : public RenderViewHostTestHarness { // The state should now reflect a regular page. EXPECT_TRUE(contents->ShouldDisplayURL()); EXPECT_TRUE(contents->ShouldDisplayFavIcon()); - EXPECT_FALSE(contents->IsBookmarkBarAlwaysVisible()); + EXPECT_FALSE(contents->ShouldShowBookmarkBar()); EXPECT_FALSE(contents->FocusLocationBarByDefault()); } @@ -112,7 +112,7 @@ TEST_F(DOMUITest, DOMUIToDOMUI) { // The flags should be the same as the non-pending state. EXPECT_FALSE(contents()->ShouldDisplayURL()); EXPECT_FALSE(contents()->ShouldDisplayFavIcon()); - EXPECT_TRUE(contents()->IsBookmarkBarAlwaysVisible()); + EXPECT_TRUE(contents()->ShouldShowBookmarkBar()); EXPECT_TRUE(contents()->FocusLocationBarByDefault()); } @@ -125,14 +125,14 @@ TEST_F(DOMUITest, StandardToDOMUI) { // The state should now reflect the default. EXPECT_TRUE(contents()->ShouldDisplayURL()); EXPECT_TRUE(contents()->ShouldDisplayFavIcon()); - EXPECT_FALSE(contents()->IsBookmarkBarAlwaysVisible()); + EXPECT_FALSE(contents()->ShouldShowBookmarkBar()); EXPECT_FALSE(contents()->FocusLocationBarByDefault()); // Commit the load, the state should be the same. rvh()->SendNavigate(1, std_url); EXPECT_TRUE(contents()->ShouldDisplayURL()); EXPECT_TRUE(contents()->ShouldDisplayFavIcon()); - EXPECT_FALSE(contents()->IsBookmarkBarAlwaysVisible()); + EXPECT_FALSE(contents()->ShouldShowBookmarkBar()); EXPECT_FALSE(contents()->FocusLocationBarByDefault()); // The sync service must be created to host the sync NTP advertisement. @@ -143,7 +143,7 @@ TEST_F(DOMUITest, StandardToDOMUI) { controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK); EXPECT_FALSE(contents()->ShouldDisplayURL()); EXPECT_TRUE(contents()->ShouldDisplayFavIcon()); - EXPECT_FALSE(contents()->IsBookmarkBarAlwaysVisible()); + EXPECT_FALSE(contents()->ShouldShowBookmarkBar()); EXPECT_TRUE(contents()->FocusLocationBarByDefault()); // Committing DOM UI is tested above. diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index ab74be7..eee1b7f 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -326,7 +326,7 @@ bool BookmarkBarGtk::IsAnimating() { bool BookmarkBarGtk::OnNewTabPage() { return (browser_ && browser_->GetSelectedTabContents() && - browser_->GetSelectedTabContents()->IsBookmarkBarAlwaysVisible()); + browser_->GetSelectedTabContents()->ShouldShowBookmarkBar()); } void BookmarkBarGtk::Loaded(BookmarkModel* model) { diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index d9a43ca..7013294 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1290,7 +1290,7 @@ void BrowserWindowGtk::MaybeShowBookmarkBar(TabContents* contents, show_bar = true; } - if (show_bar && contents && !contents->IsBookmarkBarAlwaysVisible()) { + if (show_bar && contents && !contents->ShouldShowBookmarkBar()) { PrefService* prefs = contents->profile()->GetPrefs(); show_bar = prefs->GetBoolean(prefs::kShowBookmarkBar) && !IsFullscreen(); } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index f220074..315934e 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -977,7 +977,7 @@ void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate, infobar_delegates_.push_back(new_delegate); } -bool TabContents::IsBookmarkBarAlwaysVisible() { +bool TabContents::ShouldShowBookmarkBar() { // See GetDOMUIForCurrentState() comment for more info. This case is very // similar, but for non-first loads, we want to use the committed entry. This // is so the bookmarks bar disappears at the same time the page does. @@ -1996,12 +1996,12 @@ void TabContents::DidNavigate(RenderViewHost* rvh, int extra_invalidate_flags = 0; if (PageTransition::IsMainFrame(params.transition)) { - bool was_bookmark_bar_visible = IsBookmarkBarAlwaysVisible(); + bool was_bookmark_bar_visible = ShouldShowBookmarkBar(); bool was_extension_shelf_visible = IsExtensionShelfAlwaysVisible(); render_manager_.DidNavigateMainFrame(rvh); - if (was_bookmark_bar_visible != IsBookmarkBarAlwaysVisible()) + if (was_bookmark_bar_visible != ShouldShowBookmarkBar()) extra_invalidate_flags |= INVALIDATE_BOOKMARK_BAR; if (was_extension_shelf_visible != IsExtensionShelfAlwaysVisible()) extra_invalidate_flags |= INVALIDATE_EXTENSION_SHELF; diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index f892775..3a09eb5 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -109,7 +109,7 @@ class TabContents : public PageNavigator, // changed. INVALIDATE_LOAD = 1 << 2, // The loading state has changed. INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed. - INVALIDATE_BOOKMARK_BAR = 1 << 4, // State of IsBookmarkBarAlwaysVisible + INVALIDATE_BOOKMARK_BAR = 1 << 4, // State of ShouldShowBookmarkBar // changed. INVALIDATE_EXTENSION_SHELF = 1 << 5, // State of // IsExtensionShelfAlwaysVisible @@ -436,8 +436,8 @@ class TabContents : public PageNavigator, // Toolbars and such --------------------------------------------------------- - // Returns whether the bookmark bar should be visible. - virtual bool IsBookmarkBarAlwaysVisible(); + // Returns true if a Bookmark Bar should be shown for this tab. + virtual bool ShouldShowBookmarkBar(); // Returns whether the extension shelf should be visible. virtual bool IsExtensionShelfAlwaysVisible(); diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 586422a..fd9282a 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -753,7 +753,7 @@ bool BookmarkBarView::IsAlwaysShown() const { bool BookmarkBarView::OnNewTabPage() const { return (browser_ && browser_->GetSelectedTabContents() && - browser_->GetSelectedTabContents()->IsBookmarkBarAlwaysVisible()); + browser_->GetSelectedTabContents()->ShouldShowBookmarkBar()); } int BookmarkBarView::GetToolbarOverlap(bool return_max) { diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index b4fcb82..ddc61f7 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -964,6 +964,8 @@ 'browser/cocoa/bookmark_bar_controller.mm', 'browser/cocoa/bookmark_bar_view.h', 'browser/cocoa/bookmark_bar_view.mm', + 'browser/cocoa/bookmark_bar_toolbar_view.h', + 'browser/cocoa/bookmark_bar_toolbar_view.mm', 'browser/cocoa/bookmark_bubble_controller.h', 'browser/cocoa/bookmark_bubble_controller.mm', 'browser/cocoa/bookmark_bubble_view.h', @@ -1117,6 +1119,7 @@ 'browser/cocoa/throbber_view.mm', 'browser/cocoa/toolbar_button_cell.h', 'browser/cocoa/toolbar_button_cell.mm', + 'browser/cocoa/toolbar_compressable.h', 'browser/cocoa/toolbar_controller.h', 'browser/cocoa/toolbar_controller.mm', 'browser/cocoa/toolbar_view.h', @@ -4230,6 +4233,7 @@ 'browser/cocoa/blocked_popup_container_controller_unittest.mm', 'browser/cocoa/bookmark_bar_bridge_unittest.mm', 'browser/cocoa/bookmark_bar_controller_unittest.mm', + 'browser/cocoa/bookmark_bar_toolbar_view_unittest.mm', 'browser/cocoa/bookmark_bar_view_unittest.mm', 'browser/cocoa/bookmark_bubble_controller_unittest.mm', 'browser/cocoa/bookmark_bubble_view_unittest.mm', |