From b3c33d463366d2725ec4d669b98dc468a751c541 Mon Sep 17 00:00:00 2001 From: "munjal@chromium.org" Date: Fri, 26 Jun 2009 22:29:20 +0000 Subject: Make bookmark model public interface use const BookmarkNode* instead of BookmarkNode*. This helps in making the BookmarkNode class setters public also without worrying about someone inadvertently changing BookmarkNode properties directly for bookmark model bookmarks. Change all the call sites to reflect this. BUG=none TEST=none Review URL: http://codereview.chromium.org/146116 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19428 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/bookmark_bar_controller.mm | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'chrome/browser/cocoa/bookmark_bar_controller.mm') diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index ad92820..e3a4bed 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -143,15 +143,14 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; // TODO(jrg): add an openBookmarkInBackground() for ctrl-click which // has a different disposition. - (void)openBookmark:(id)sender { - BookmarkNode* node = static_cast([[[sender cell] - representedObject] - pointerValue]); + const BookmarkNode* node = static_cast( + [[[sender cell]representedObject]pointerValue]); DCHECK(node); [delegate_ openBookmarkURL:node->GetURL() disposition:CURRENT_TAB]; } // Return an autoreleased NSCell suitable for a bookmark button. -- (NSCell *)cellForBookmarkNode:(BookmarkNode*)node frame:(NSRect)frame { +- (NSCell *)cellForBookmarkNode:(const BookmarkNode*)node frame:(NSRect)frame { NSString* title = base::SysWideToNSString(node->GetTitle()); NSButtonCell *cell = [[[BookmarkButtonCell alloc] initTextCell:nil] autorelease]; @@ -212,9 +211,9 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; // TODO(jrg): write a "build bar" so there is a nice spot for things // like the contextual menu which is invoked when not over a // bookmark. On Safari that menu has a "new folder" option. -- (void)addNodesToBar:(BookmarkNode*)node { +- (void)addNodesToBar:(const BookmarkNode*)node { for (int i = 0; i < node->GetChildCount(); i++) { - BookmarkNode* child = node->GetChild(i); + const BookmarkNode* child = node->GetChild(i); NSRect frame = [self frameForBookmarkAtIndex:i]; NSButton* button = [[[NSButton alloc] initWithFrame:frame] @@ -255,7 +254,7 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; if ((barIsVisible_ == NO) || !model->IsLoaded()) return; // Else brute force nuke and build. - BookmarkNode* node = model->GetBookmarkBarNode(); + const BookmarkNode* node = model->GetBookmarkBarNode(); [self clearBookmarkBar]; [self addNodesToBar:node]; } @@ -266,32 +265,32 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; // TODO(jrg): for now this is brute force. - (void)nodeMoved:(BookmarkModel*)model - oldParent:(BookmarkNode*)oldParent oldIndex:(int)oldIndex - newParent:(BookmarkNode*)newParent newIndex:(int)newIndex { + oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex + newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex { [self loaded:model]; } // TODO(jrg): for now this is brute force. - (void)nodeAdded:(BookmarkModel*)model - parent:(BookmarkNode*)oldParent index:(int)index { + parent:(const BookmarkNode*)oldParent index:(int)index { [self loaded:model]; } // TODO(jrg): for now this is brute force. - (void)nodeChanged:(BookmarkModel*)model - node:(BookmarkNode*)node { + node:(const BookmarkNode*)node { [self loaded:model]; } // TODO(jrg): linear searching is bad. // Need a BookmarkNode-->NSCell mapping. - (void)nodeFavIconLoaded:(BookmarkModel*)model - node:(BookmarkNode*)node { + node:(const BookmarkNode*)node { NSArray* views = [bookmarkBarView_ subviews]; for (NSButton* button in views) { NSButtonCell* cell = [button cell]; void* pointer = [[cell representedObject] pointerValue]; - BookmarkNode* cellnode = static_cast(pointer); + const BookmarkNode* cellnode = static_cast(pointer); if (cellnode == node) { NSImage* image = gfx::SkBitmapToNSImage(bookmarkModel_->GetFavIcon(node)); if (image) { @@ -305,7 +304,7 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; // TODO(jrg): for now this is brute force. - (void)nodeChildrenReordered:(BookmarkModel*)model - node:(BookmarkNode*)node { + node:(const BookmarkNode*)node { [self loaded:model]; } -- cgit v1.1