Index: chrome/browser/cocoa/tab_contents_controller.mm |
=================================================================== |
--- chrome/browser/cocoa/tab_contents_controller.mm (revision 11933) |
+++ chrome/browser/cocoa/tab_contents_controller.mm (working copy) |
@@ -6,6 +6,7 @@ |
#import "base/sys_string_conversions.h" |
#import "chrome/app/chrome_dll_resource.h" |
+#import "chrome/browser/bookmarks/bookmark_model.h" |
#import "chrome/browser/command_updater.h" |
#import "chrome/browser/location_bar.h" |
#import "chrome/browser/tab_contents/tab_contents.h" |
@@ -30,6 +31,7 @@ |
@interface TabContentsController(Private) |
- (void)updateToolbarCommandStatus; |
+- (void)applyContentsBoxOffset:(BOOL)apply; |
@end |
// A C++ bridge class that handles listening for updates to commands and |
@@ -78,7 +80,8 @@ |
bundle:(NSBundle*)bundle |
contents:(TabContents*)contents |
commands:(CommandUpdater*)commands |
- toolbarModel:(ToolbarModel*)toolbarModel { |
+ toolbarModel:(ToolbarModel*)toolbarModel |
+ bookmarkModel:(BookmarkModel*)bookmarkModel { |
if ((self = [super initWithNibName:name bundle:bundle])) { |
commands_ = commands; |
if (commands_) |
@@ -86,6 +89,7 @@ |
locationBarBridge_ = new LocationBarBridge(self); |
contents_ = contents; |
toolbarModel_ = toolbarModel; |
+ bookmarkModel_ = bookmarkModel; |
} |
return self; |
} |
@@ -100,6 +104,7 @@ |
- (void)awakeFromNib { |
[contentsBox_ setContentView:contents_->GetNativeView()]; |
+ [self applyContentsBoxOffset:YES]; |
// Provide a starting point since we won't get notifications if the state |
// doesn't change between tabs. |
@@ -234,6 +239,47 @@ |
[goButton_ setImage:[NSImage imageNamed:imageName]]; |
} |
+- (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 |
//-------------------------------------------------------------------------- |