Chromium Code Reviews| 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 9ea3ec27efa1d77d4ed54e048f90c1d6c4b48803..0a65b961729e0dfaec97f3f3ec0ab3657ba60de1 100644 |
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
| @@ -32,22 +32,33 @@ const int kHierarchyButtonXMargin = 4; |
| + (id)buttonCellForNode:(const BookmarkNode*)node |
| menuController:(BookmarkContextMenuCocoaController*)menuController |
| - cellText:(NSString*)cellText |
| - cellImage:(NSImage*)cellImage { |
| + text:(NSString*)text |
| + image:(NSImage*)image { |
| id buttonCell = |
| [[[BookmarkButtonCell alloc] initForNode:node |
| menuController:menuController |
| - cellText:cellText |
| - cellImage:cellImage] |
| + text:text |
| + image:image] |
| + autorelease]; |
| + return buttonCell; |
| +} |
| + |
| ++ (id)buttonCellWithMenuController:(BookmarkContextMenuCocoaController*)menuController |
| + text:(NSString*)text |
| + image:(NSImage*)image { |
| + id buttonCell = |
| + [[[BookmarkButtonCell alloc] initWithMenuController:menuController |
| + text:text |
| + image:image] |
| autorelease]; |
| return buttonCell; |
| } |
| - (id)initForNode:(const BookmarkNode*)node |
| menuController:(BookmarkContextMenuCocoaController*)menuController |
| - cellText:(NSString*)cellText |
| - cellImage:(NSImage*)cellImage { |
| - if ((self = [super initTextCell:cellText])) { |
| + text:(NSString*)text |
| + image:(NSImage*)image { |
| + if ((self = [super initTextCell:text])) { |
| menuController_ = menuController; |
| [self configureBookmarkButtonCell]; |
| [self setTextColor:[NSColor blackColor]]; |
| @@ -55,7 +66,7 @@ const int kHierarchyButtonXMargin = 4; |
| if (node) { |
| NSString* title = base::SysUTF16ToNSString(node->GetTitle()); |
| - [self setBookmarkCellText:title image:cellImage]; |
| + [self setBookmarkCellText:title image:image]; |
| } else { |
| [self setEmpty:YES]; |
| [self setBookmarkCellText:l10n_util::GetNSString(IDS_MENU_EMPTY_SUBMENU) |
| @@ -66,11 +77,25 @@ const int kHierarchyButtonXMargin = 4; |
| return self; |
| } |
| +- (id)initWithMenuController:(BookmarkContextMenuCocoaController*)menuController |
| + text:(NSString*)text |
| + image:(NSImage*)image { |
| + if ((self = [super initTextCell:text])) { |
| + menuController_ = menuController; |
| + [self configureBookmarkButtonCell]; |
| + [self setTextColor:[NSColor blackColor]]; |
| + [self setBookmarkNode:NULL]; |
| + [self setBookmarkCellText:text image:image]; |
| + // 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 |
| - menuController:nil |
| - cellText:string |
| - cellImage:nil]; |
| + return [self initForNode:nil menuController:nil text:string image:nil]; |
| } |
| // Used by the off-the-side menu, the only case where a |
| @@ -161,7 +186,12 @@ const int kHierarchyButtonXMargin = 4; |
| if (empty_) |
| return nil; |
| + // If node is NULL, this is a custom button, the menu does not represent |
| + // anything. |
|
Alexei Svitkine (slow)
2013/03/11 14:31:04
Hmm, my other refactoring CL didn't actually remov
beaudoin
2013/03/11 21:02:51
Done.
|
| const BookmarkNode* node = [self bookmarkNode]; |
| + if (!node) |
| + return nil; |
| + |
| if (node->parent() && node->parent()->type() == BookmarkNode::FOLDER) { |
| content::RecordAction(UserMetricsAction("BookmarkBarFolder_CtxMenu")); |
| } else { |