diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 15:23:39 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 15:23:39 +0000 |
commit | 6420421e6f15f25891c88661431ce9483ccfdba7 (patch) | |
tree | 388278f27e01d35fc3fbdbe691417ff520e49062 /chrome | |
parent | da5f6a8c64d48c97ed538bf5e28fb1e6d029c38c (diff) | |
download | chromium_src-6420421e6f15f25891c88661431ce9483ccfdba7.zip chromium_src-6420421e6f15f25891c88661431ce9483ccfdba7.tar.gz chromium_src-6420421e6f15f25891c88661431ce9483ccfdba7.tar.bz2 |
Collapse bookmark bars into a single bar per window, rather than one per tab.
Create a separate controller for the bar. Hide bar when it's not supposed to be
visible instead of just allowing it to be covered by content (it's not always
covered, which leads to drawing errors).
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/nibs/en.lproj/TabContents.xib | 46 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 49 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 111 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_state_controller.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_state_controller.mm | 17 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 16 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.h | 18 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 50 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 14 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 22 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 |
13 files changed, 198 insertions, 159 deletions
diff --git a/chrome/app/nibs/en.lproj/TabContents.xib b/chrome/app/nibs/en.lproj/TabContents.xib index 154a722..c985de4 100644 --- a/chrome/app/nibs/en.lproj/TabContents.xib +++ b/chrome/app/nibs/en.lproj/TabContents.xib @@ -2,10 +2,10 @@ <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9F33</string> + <string key="IBDocument.SystemVersion">9G55</string> <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.34</string> - <string key="IBDocument.HIToolboxVersion">352.00</string> + <string key="IBDocument.AppKitVersion">949.43</string> + <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> <integer value="94"/> @@ -55,13 +55,6 @@ <int key="NSvFlags">274</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSCustomView" id="741487837"> - <reference key="NSNextResponder" ref="675542922"/> - <int key="NSvFlags">266</int> - <string key="NSFrame">{{0, 322}, {480, 38}}</string> - <reference key="NSSuperview" ref="675542922"/> - <string key="NSClassName">ToolbarView</string> - </object> <object class="NSBox" id="753762894"> <reference key="NSNextResponder" ref="675542922"/> <int key="NSvFlags">18</int> @@ -150,14 +143,6 @@ </object> <int key="connectionID">176</int> </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">bookmarkView_</string> - <reference key="source" ref="326691890"/> - <reference key="destination" ref="741487837"/> - </object> - <int key="connectionID">194</int> - </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -199,7 +184,6 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="753762894"/> <reference ref="995989345"/> - <reference ref="741487837"/> </object> <reference key="parent" ref="886393115"/> </object> @@ -222,14 +206,6 @@ <reference key="object" ref="995989345"/> <reference key="parent" ref="675542922"/> </object> - <object class="IBObjectRecord"> - <int key="objectID">179</int> - <reference key="object" ref="741487837"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <reference key="parent" ref="675542922"/> - </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -241,7 +217,6 @@ <string>-3.IBPluginDependency</string> <string>164.IBPluginDependency</string> <string>175.IBPluginDependency</string> - <string>179.IBPluginDependency</string> <string>93.IBEditorWindowLastContentRect</string> <string>93.IBViewEditorWindowController.showingLayoutRectangles</string> <string>93.IBWindowTemplateEditedContentRect</string> @@ -258,10 +233,9 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{1032, 413}, {480, 360}}</string> + <string>{{769, 584}, {480, 360}}</string> <boolean value="YES" id="5"/> - <string>{{1032, 413}, {480, 360}}</string> + <string>{{769, 584}, {480, 360}}</string> <reference ref="5"/> <reference ref="5"/> <string>{480, 360}</string> @@ -332,13 +306,11 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>bookmarkView_</string> <string>contentsBox_</string> <string>growBox_</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>ToolbarView</string> <string>NSBox</string> <string>GrowBoxView</string> </object> @@ -348,14 +320,6 @@ <string key="minorKey">browser/cocoa/tab_contents_controller.h</string> </object> </object> - <object class="IBPartialClassDescription"> - <string key="className">ToolbarView</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/toolbar_view.h</string> - </object> - </object> </object> </object> <int key="IBDocument.localizationMode">0</int> diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h new file mode 100644 index 0000000..6c8e4c0 --- /dev/null +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -0,0 +1,49 @@ +// 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_BOOKMARK_BAR_CONTROLLER_H_ +#define CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ + +#import <Cocoa/Cocoa.h> + +#include "base/scoped_nsobject.h" + +@class BookmarkBarStateController; +class BookmarkModel; +class Profile; +@class ToolbarView; + +// A controller for the bookmark bar in the browser window. Handles showing +// and hiding based on the preference in the given profile. + +@interface BookmarkBarController : NSObject { + @private + BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the + // top-level Browser object. + + // Controller for bookmark bar state, shared among all TabContents. + scoped_nsobject<BookmarkBarStateController> bookmarkBarStateController_; + BOOL contentAreaHasOffset_; + + // TODO(jrg): write a BookmarkView + IBOutlet ToolbarView* /* BookmarkView* */ bookmarkView_; + IBOutlet NSView* contentArea_; +} + +// Initializes the controller with the given browser profile and content view. +- (id)initWithProfile:(Profile*)profile + contentArea:(NSView*)content; + +// Change the visibility state of the bookmark bar to |enable|. +- (void)showBookmarkBar:(BOOL)enable; + +// Toggle the state of the bookmark bar. +- (void)toggleBookmarkBar; + +// Returns whether or not the bookmark bar is visible. +- (BOOL)isBookmarkBarVisible; + +@end + +#endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm new file mode 100644 index 0000000..74cc215 --- /dev/null +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -0,0 +1,111 @@ +// 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_controller.h" + +#import "chrome/browser/cocoa/bookmark_bar_state_controller.h" +#import "chrome/browser/cocoa/toolbar_view.h" +#include "chrome/browser/profile.h" + +@interface BookmarkBarController(Private) +- (void)applyContentAreaOffset:(BOOL)apply; +- (void)positionBar; +@end + +@implementation BookmarkBarController + +- (id)initWithProfile:(Profile*)profile + contentArea:(NSView*)content { + if ((self = [super init])) { + bookmarkModel_ = profile->GetBookmarkModel(); + contentArea_ = content; + bookmarkBarStateController_.reset([[BookmarkBarStateController alloc] + initWithProfile:profile]); + // Create and initialize the view's position. Show it if appropriate. + // TODO(jrg): put it in a nib if necessary. + NSRect frame = NSMakeRect(0, 0, 0, 30); + bookmarkView_ = [[ToolbarView alloc] initWithFrame:frame]; + [self positionBar]; + if ([self isBookmarkBarVisible]) + [self showBookmarkBar:YES]; + [[[contentArea_ window] contentView] addSubview:bookmarkView_]; + } + return self; +} + +// Initializes the bookmark bar at the top edge of |contentArea_| and the +// view's visibility to match the pref. This doesn't move the content view at +// all, you need to call |-showBookmarkBar:| to do that. +- (void)positionBar { + NSRect contentFrame = [contentArea_ frame]; + NSRect barFrame = [bookmarkView_ frame]; + + // Hide or show bar based on initial visibility and set the resize flags. + [bookmarkView_ setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; + [bookmarkView_ setHidden:[self isBookmarkBarVisible] ? NO : YES]; + + // Position the bar at the top of the content area, within the window's + // content view (as opposed to the tab strip, which is a sibling). We'll + // slide the content area down when we need to show this strip. + contentFrame.size.height -= barFrame.size.height; + barFrame.origin.y = NSMaxY(contentFrame); + barFrame.origin.x = 0; + barFrame.size.width = contentFrame.size.width; + [bookmarkView_ setFrame:barFrame]; +} + +// Show or hide the bar based on the value of enable. Handles animating the +// resize of the content view. +- (void)showBookmarkBar:(BOOL)enable { + contentAreaHasOffset_ = enable; + [[bookmarkView_ animator] setHidden:enable ? NO : YES]; + [self applyContentAreaOffset:enable]; + + if (enable) { + // TODO(jrg): display something useful in the bookmark bar + // TODO(jrg): use a BookmarksView, not a ToolbarView + // TODO(jrg): don't draw a border around it + // TODO(jrg): ... + } +} + +// Apply a contents box offset to make (or remove) room for the +// bookmark bar. If apply==YES, always make room (the contentView_ is +// "full size"). If apply==NO we are trying to undo an offset. If no +// offset there is nothing to undo. +- (void)applyContentAreaOffset:(BOOL)apply { + if (bookmarkView_ == nil) { + // We're too early, but awakeFromNib will call me again. + return; + } + if (!contentAreaHasOffset_ && apply) { + // There is no offset to unconditionally apply. + return; + } + + int offset = [bookmarkView_ frame].size.height; + NSRect frame = [contentArea_ frame]; + if (apply) + frame.size.height -= offset; + else + frame.size.height += offset; + + // TODO(jrg): animate + [[contentArea_ animator] setFrame:frame]; + + [bookmarkView_ setNeedsDisplay:YES]; + [contentArea_ setNeedsDisplay:YES]; +} + +- (BOOL)isBookmarkBarVisible { + return [bookmarkBarStateController_ visible]; +} + +- (void)toggleBookmarkBar { + [bookmarkBarStateController_ toggleBookmarkBar]; + BOOL visible = [self isBookmarkBarVisible]; + [self showBookmarkBar:visible ? YES : NO]; +} + +@end diff --git a/chrome/browser/cocoa/bookmark_bar_state_controller.h b/chrome/browser/cocoa/bookmark_bar_state_controller.h index b3aeafd..761d907 100644 --- a/chrome/browser/cocoa/bookmark_bar_state_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_state_controller.h @@ -7,17 +7,17 @@ #import <Cocoa/Cocoa.h> -class Browser; +class Profile; // A class to manage bookmark bar state (visible or not). State is // shared among all tabs and saved in a preference. @interface BookmarkBarStateController : NSObject { @private - Browser* browser_; + Profile* profile_; BOOL visible_; } -- (id)initWithBrowser:(Browser *)browser; +- (id)initWithProfile:(Profile *)browser; // Return YES or NO reflecting visibility state of the bookmark bar. - (BOOL)visible; diff --git a/chrome/browser/cocoa/bookmark_bar_state_controller.mm b/chrome/browser/cocoa/bookmark_bar_state_controller.mm index e4c6525..69d7aa2 100644 --- a/chrome/browser/cocoa/bookmark_bar_state_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_state_controller.mm @@ -3,19 +3,18 @@ // found in the LICENSE file. #import "chrome/browser/cocoa/bookmark_bar_state_controller.h" -#import "chrome/browser/bookmarks/bookmark_utils.h" -#import "chrome/browser/browser.h" -#import "chrome/common/pref_names.h" -#import "chrome/common/pref_service.h" - +#include "chrome/browser/bookmarks/bookmark_utils.h" +#include "chrome/browser/profile.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" @implementation BookmarkBarStateController -- (id)initWithBrowser:(Browser *)browser { +- (id)initWithProfile:(Profile*)profile { if ((self = [super init])) { - browser_ = browser; + profile_ = profile; // Initial visibility state comes from our preference. - if (browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) { + if (profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) { visible_ = YES; } } @@ -29,7 +28,7 @@ // Whack and save a preference change. On Windows this call // is made from BookmarkBarView. - (void)togglePreference { - bookmark_utils::ToggleWhenVisible(browser_->profile()); + bookmark_utils::ToggleWhenVisible(profile_); } - (void)toggleBookmarkBar { diff --git a/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm index 8a86309..31ce077 100644 --- a/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm @@ -29,8 +29,8 @@ class BookmarkBarStateControllerTest : public testing::Test { TEST_F(BookmarkBarStateControllerTest, MainTest) { Browser* browser = browser_test_helper_.GetBrowser(); NoPrefSaveBBStateController *c = [[[NoPrefSaveBBStateController alloc] - initWithBrowser:browser] - autorelease]; + initWithProfile:browser->profile()] + autorelease]; EXPECT_TRUE(c); EXPECT_FALSE(c->toggled_); BOOL old_visible = [c visible]; diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index aab0345..8bc7222 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -16,6 +16,7 @@ #include "base/scoped_ptr.h" #import "chrome/browser/cocoa/tab_window_controller.h" +@class BookmarkBarController; class Browser; class BrowserWindow; class BrowserWindowCocoa; @@ -44,6 +45,7 @@ class TabStripModelObserverBridge; scoped_ptr<TabStripModelObserverBridge> tabObserver_; scoped_ptr<BrowserWindowCocoa> windowShim_; scoped_nsobject<ToolbarController> toolbarController_; + scoped_nsobject<BookmarkBarController> bookmarkController_; scoped_nsobject<TabStripController> tabStripController_; scoped_ptr<StatusBubble> statusBubble_; } diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 5be49d9..47b3ef9 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -8,6 +8,7 @@ #include "chrome/browser/tab_contents/web_contents.h" #include "chrome/browser/tab_contents/web_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" +#import "chrome/browser/cocoa/bookmark_bar_controller.h" #import "chrome/browser/cocoa/browser_window_cocoa.h" #import "chrome/browser/cocoa/browser_window_controller.h" #import "chrome/browser/cocoa/status_bubble_mac.h" @@ -78,7 +79,16 @@ const int kWindowGradientHeight = 24; initWithModel:browser->toolbar_model() commands:browser->command_updater()]); [self positionToolbar]; - [self fixWindowGradient]; + + // After we've adjusted the toolbar, create a controller for the bookmark + // bar. It will show/hide itself based on the global preference and handle + // positioning itself (if visible) above the content area, which is why + // we need to do it after we've placed the toolbar. + bookmarkController_.reset([[BookmarkBarController alloc] + initWithProfile:browser_->profile() + contentArea:[self tabContentArea]]); + + [self fixWindowGradient]; // Create the bridge for the status bubble. statusBubble_.reset(new StatusBubbleMac([self window])); @@ -302,12 +312,12 @@ const int kWindowGradientHeight = 24; } - (BOOL)isBookmarkBarVisible { - return [tabStripController_ isBookmarkBarVisible]; + return [bookmarkController_ isBookmarkBarVisible]; } - (void)toggleBookmarkBar { - [tabStripController_ toggleBookmarkBar]; + [bookmarkController_ toggleBookmarkBar]; } - (NSInteger)numberOfTabs { diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h index f4098ed..2714ab9 100644 --- a/chrome/browser/cocoa/tab_contents_controller.h +++ b/chrome/browser/cocoa/tab_contents_controller.h @@ -7,14 +7,11 @@ #include <Cocoa/Cocoa.h> -@class BookmarkView; @class GrowBoxView; -class BookmarkModel; class TabContents; class TabContentsCommandObserver; class TabStripModel; -@class ToolbarView; // A class that controls the web contents of a tab. It manages displaying the // native view for a given TabContents in |contentsBox_|. @@ -24,24 +21,14 @@ class TabStripModel; TabContentsCommandObserver* observer_; // nil if |commands_| is nil TabContents* contents_; // weak - BookmarkModel* bookmarkModel_; // weak; one per window - - // TODO(jrg): write a BookmarkView - IBOutlet ToolbarView* /* BookmarkView* */ bookmarkView_; - IBOutlet NSBox* contentsBox_; IBOutlet GrowBoxView* growBox_; - - // The contents box will have an offset if shrunk to make room for - // the bookmark bar. - BOOL contentsBoxHasOffset_; } // Create the contents of a tab represented by |contents| and loaded from the // nib given by |name|. - (id)initWithNibName:(NSString*)name - contents:(TabContents*)contents - bookmarkModel:(BookmarkModel*)bookmarkModel; + contents:(TabContents*)contents; // Take this view (toolbar and web contents) full screen - (IBAction)fullScreen:(id)sender; @@ -60,9 +47,6 @@ class TabStripModel; // in the coordinate system of the content area of this tab. - (NSRect)growBoxRect; -// Change the visibility state of the bookmark bar. -- (void)toggleBookmarkBar:(BOOL)enable; - @end #endif // CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index c72b97d..cb51275 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -8,18 +8,12 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/tab_contents/tab_contents.h" -@interface TabContentsController(Private) -- (void)applyContentsBoxOffset:(BOOL)apply; -@end - @implementation TabContentsController - (id)initWithNibName:(NSString*)name - contents:(TabContents*)contents - bookmarkModel:(BookmarkModel*)bookmarkModel { + contents:(TabContents*)contents { if ((self = [super initWithNibName:name bundle:nil])) { contents_ = contents; - bookmarkModel_ = bookmarkModel; } return self; } @@ -32,7 +26,6 @@ - (void)awakeFromNib { [contentsBox_ setContentView:contents_->GetNativeView()]; - [self applyContentsBoxOffset:YES]; } // Returns YES if the tab represented by this controller is the front-most. @@ -83,45 +76,4 @@ return localGrowBox; } -- (void)toggleBookmarkBar:(BOOL)enable { - contentsBoxHasOffset_ = enable; - [self applyContentsBoxOffset:enable]; - - if (enable) { - // TODO(jrg): display something useful in the bookmark bar - // TODO(jrg): use a BookmarksView, not a ToolbarView - // TODO(jrg): don't draw a border around it - // TODO(jrg): ... - } -} - -// Apply a contents box offset to make (or remove) room for the -// bookmark bar. If apply==YES, always make room (the contentsBox_ is -// "full size"). If apply==NO we are trying to undo an offset. If no -// offset there is nothing to undo. -- (void)applyContentsBoxOffset:(BOOL)apply { - - if (bookmarkView_ == nil) { - // We're too early, but awakeFromNib will call me again. - return; - } - if (!contentsBoxHasOffset_ && apply) { - // There is no offset to unconditionally apply. - return; - } - - int offset = [bookmarkView_ frame].size.height; - NSRect frame = [contentsBox_ frame]; - if (apply) - frame.size.height -= offset; - else - frame.size.height += offset; - - // TODO(jrg): animate - [contentsBox_ setFrame:frame]; - - [bookmarkView_ setNeedsDisplay:YES]; - [contentsBox_ setNeedsDisplay:YES]; -} - @end diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index dae7218..faa7132 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -12,11 +12,8 @@ #import "chrome/browser/cocoa/tab_controller_target.h" @class TabStripView; -@class BookmarkBarStateController; -class BookmarkModel; class Browser; -class LocationBar; class TabStripModelObserverBridge; class TabStripModel; class TabContents; @@ -41,7 +38,6 @@ class ToolbarModel; NSButton* newTabButton_; // weak, obtained from the nib. scoped_ptr<TabStripModelObserverBridge> bridge_; TabStripModel* tabModel_; // weak - BookmarkModel* bookmarkModel_; // weak, one per profile (= one per Browser*) // access to the TabContentsControllers (which own the parent view // for the toolbar and associated tab contents) given an index. This needs // to be kept in the same order as the tab strip's model as we will be @@ -50,9 +46,6 @@ class ToolbarModel; // an array of TabControllers which manage the actual tab views. As above, // this is kept in the same order as the tab strip model. scoped_nsobject<NSMutableArray> tabArray_; - - // Controller for bookmark bar state, shared among all TabContents. - scoped_nsobject<BookmarkBarStateController> bookmarkBarStateController_; } // Initialize the controller with a view and browser that contains @@ -68,13 +61,6 @@ class ToolbarModel; // in the coordinate system of the content area of the currently selected tab. - (NSRect)selectedTabGrowBoxRect; -// Return a boolean (ObjC BOOL, not C++ bool) to say if the bookmark -// bar is visible. -- (BOOL)isBookmarkBarVisible; - -// Turn on or off the bookmark bar for *ALL* tabs. -- (void)toggleBookmarkBar; - // Given a tab view in the strip, return its index. Returns -1 if not present. - (NSInteger)indexForTabView:(NSView*)view; diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 0fca35f..920438c 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -7,7 +7,6 @@ #import "base/sys_string_conversions.h" #import "chrome/app/chrome_dll_resource.h" #import "chrome/browser/browser.h" -#import "chrome/browser/cocoa/bookmark_bar_state_controller.h" #import "chrome/browser/cocoa/tab_strip_view.h" #import "chrome/browser/cocoa/tab_cell.h" #import "chrome/browser/cocoa/tab_contents_controller.h" @@ -27,12 +26,9 @@ tabView_ = view; switchView_ = switchView; tabModel_ = browser->tabstrip_model(); - bookmarkModel_ = browser->profile()->GetBookmarkModel(); bridge_.reset(new TabStripModelObserverBridge(tabModel_, self)); tabContentsArray_.reset([[NSMutableArray alloc] init]); tabArray_.reset([[NSMutableArray alloc] init]); - bookmarkBarStateController_.reset([[BookmarkBarStateController alloc] - initWithBrowser:browser]); // Take the only child view present in the nib as the new tab button. For // some reason, if the view is present in the nib apriori, it draws // correctly. If we create it in code and add it to the tab view, it draws @@ -212,11 +208,8 @@ // the new controller with |contents| so it can be looked up later. TabContentsController* contentsController = [[[TabContentsController alloc] initWithNibName:@"TabContents" - contents:contents - bookmarkModel:bookmarkModel_] + contents:contents] autorelease]; - if ([self isBookmarkBarVisible]) - [contentsController toggleBookmarkBar:YES]; [tabContentsArray_ insertObject:contentsController atIndex:index]; // Make a new tab and add it to the strip. Keep track of its controller. @@ -319,17 +312,4 @@ return [selectedController growBoxRect]; } -- (BOOL)isBookmarkBarVisible { - return [bookmarkBarStateController_ visible]; -} - -// Called from BrowserWindowController -- (void)toggleBookmarkBar { - [bookmarkBarStateController_ toggleBookmarkBar]; - BOOL visible = [self isBookmarkBarVisible]; - for (TabContentsController *controller in tabContentsArray_.get()) { - [controller toggleBookmarkBar:visible]; - } -} - @end diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 89f0d93..756f2c8 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -514,6 +514,8 @@ 'browser/chrome_thread.h', 'browser/cocoa/base_view.h', 'browser/cocoa/base_view.mm', + 'browser/cocoa/bookmark_bar_controller.h', + 'browser/cocoa/bookmark_bar_controller.mm', 'browser/cocoa/bookmark_bar_state_controller.h', 'browser/cocoa/bookmark_bar_state_controller.mm', 'browser/cocoa/bookmark_menu_bridge.h', |