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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm

Issue 12550006: Mac: Add a shortcut to open the Apps page from the bookmark bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No longer touching model or views. Created 7 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
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"));

Powered by Google App Engine
This is Rietveld 408576698