Index: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
index 76678606b225246d6463ec08bbf5155149a65d82..1c94ff4d7882d1de064a8c962ff7ec3ff40b28c2 100644 |
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
@@ -43,6 +43,17 @@ const int kHierarchyButtonXMargin = 4; |
return buttonCell; |
} |
++ (id)buttonCellForContextMenu:(NSMenu*)contextMenu |
+ cellText:(NSString*)cellText |
+ cellImage:(NSImage*)cellImage { |
+ id buttonCell = |
+ [[[BookmarkButtonCell alloc] initForContextMenu:contextMenu |
+ cellText:cellText |
+ cellImage:cellImage] |
+ autorelease]; |
+ return buttonCell; |
+} |
+ |
- (id)initForNode:(const BookmarkNode*)node |
contextMenu:(NSMenu*)contextMenu |
cellText:(NSString*)cellText |
@@ -66,6 +77,23 @@ const int kHierarchyButtonXMargin = 4; |
return self; |
} |
+- (id)initForContextMenu:(NSMenu*)contextMenu |
+ cellText:(NSString*)cellText |
Alexei Svitkine (slow)
2013/03/08 19:45:48
Align the :'s
|
+ cellImage:(NSImage*)cellImage { |
+ if ((self = [super initTextCell:cellText])) { |
+ [self configureBookmarkButtonCell]; |
+ [self setTextColor:[NSColor blackColor]]; |
+ [self setBookmarkNode:NULL]; |
+ [self setBookmarkCellText:cellText image:cellImage]; |
+ [self setMenu:contextMenu]; |
+ // This is a custom button not attached to any node. It is no considered |
+ // empty even if its bookmark node is NULL. |
+ [self setEmpty:NO]; |
+ } |
+ |
+ return self; |
+} |
+ |
- (id)initTextCell:(NSString*)string { |
return [self initForNode:nil contextMenu:nil cellText:string cellImage:nil]; |
} |
@@ -161,8 +189,12 @@ const int kHierarchyButtonXMargin = 4; |
if (empty_) |
return nil; |
BookmarkMenu* menu = (BookmarkMenu*)[super menu]; |
- const BookmarkNode* node = |
- static_cast<const BookmarkNode*>([[self representedObject] pointerValue]); |
+ const BookmarkNode* node = [self bookmarkNode]; |
+ |
+ // If node is NULL, this is a custom button, the menu does not represent |
+ // anything. |
Alexei Svitkine (slow)
2013/03/08 19:45:48
Is this how the Windows implementation works? No c
|
+ if (!node) |
+ return nil; |
if (node->parent() && node->parent()->type() == BookmarkNode::FOLDER) { |
content::RecordAction(UserMetricsAction("BookmarkBarFolder_CtxMenu")); |