Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Unified Diff: chrome/browser/cocoa/tab_contents_controller.mm

Issue 46078: Mac bookmark work. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/tab_contents_controller.h ('k') | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
//--------------------------------------------------------------------------
« no previous file with comments | « chrome/browser/cocoa/tab_contents_controller.h ('k') | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698