[Mac] Show context menu on empty BMB item.

This matches other platforms.

Fixed at altitude 12000 meters.

BUG=110939
TEST=See bug.

Review URL: https://chromiumcodereview.appspot.com/23522055

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223650 0039d316-1c4b-4281-b951-d872f2087c98
parent 13c534ff
......@@ -920,9 +920,9 @@ TEST_F(BookmarkBarControllerTest, Cell) {
EXPECT_EQ(node, [[cell representedObject] pointerValue]);
EXPECT_TRUE([cell menu]);
// Empty cells have no menu.
// Empty cells still have a menu.
cell = [bar_ cellForBookmarkNode:nil];
EXPECT_FALSE([cell menu]);
EXPECT_TRUE([cell menu]);
// Even empty cells have a title (of "(empty)")
EXPECT_TRUE([cell title]);
......
......@@ -262,7 +262,7 @@ using content::UserMetricsAction;
}
- (NSMenu*)menu {
return [[controller_ menuController] menuForBookmarkNode:NULL];
return [[controller_ menuController] menuForBookmarkBar];
}
- (void)setController:(id)controller {
......
......@@ -183,9 +183,6 @@ const int kHierarchyButtonXMargin = 4;
}
- (NSMenu*)menu {
if (empty_)
return nil;
// If node is NULL, this is a custom button, the menu does not represent
// anything.
const BookmarkNode* node = [self bookmarkNode];
......
......@@ -51,9 +51,12 @@ class BookmarkNode;
// Returns an NSMenu customized for |node|. Works under the assumption that
// only one menu should ever be shown at a time, and thus caches the last
// returned menu and re-creates it if a menu for a different node is requested.
// Passing in a NULL |node| will return the menu for the bookmark bar itself.
// Passing in a NULL |node| will return the menu for "empty" placeholder.
- (NSMenu*)menuForBookmarkNode:(const BookmarkNode*)node;
// Returns an NSMenu customized for the bookmark bar.
- (NSMenu*)menuForBookmarkBar;
// Closes the menu, if it's currently open.
- (void)cancelTracking;
......
......@@ -62,12 +62,12 @@ class BookmarkContextMenuDelegateBridge :
if (bookmarkNode_ == bookmarkModel->other_node()) {
nodes.push_back(bookmarkNode_);
parent = bookmarkModel->bookmark_bar_node();
} else if (bookmarkNode_ != bookmarkModel->bookmark_bar_node()) {
nodes.push_back(bookmarkNode_);
parent = bookmarkNode_->parent();
} else {
} else if (bookmarkNode_ == bookmarkModel->bookmark_bar_node()) {
parent = bookmarkModel->bookmark_bar_node();
nodes.push_back(parent);
} else if (bookmarkNode_) {
nodes.push_back(bookmarkNode_);
parent = bookmarkNode_->parent();
}
Browser* browser = [bookmarkBarController_ browser];
......@@ -82,21 +82,23 @@ class BookmarkContextMenuDelegateBridge :
useWithPopUpButtonCell:NO]);
}
- (NSMenu*)menuForBookmarkNode:(const BookmarkNode*)node {
- (BookmarkModel*)bookmarkModel {
// Depending on timing, the model may not yet have been loaded.
BookmarkModel* bookmarkModel = [bookmarkBarController_ bookmarkModel];
if (!bookmarkModel || !bookmarkModel->loaded())
return nil;
return bookmarkModel;
}
- (NSMenu*)menuForBookmarkNode:(const BookmarkNode*)node {
BookmarkModel* bookmarkModel = [self bookmarkModel];
// This may be called before the BMB view has been added to the window. In
// that case, simply return nil so that BookmarkContextMenuController doesn't
// get created with a nil window.
if (![bookmarkBarController_ browserWindow])
if (!bookmarkModel || ![bookmarkBarController_ browserWindow])
return nil;
if (!node)
node = bookmarkModel->bookmark_bar_node();
// Rebuild the menu if it's for a different node than the last request.
if (!menuController_ || node != bookmarkNode_) {
bookmarkNode_ = node;
......@@ -105,6 +107,14 @@ class BookmarkContextMenuDelegateBridge :
return [menuController_ menu];
}
- (NSMenu*)menuForBookmarkBar {
BookmarkModel* bookmarkModel = [self bookmarkModel];
if (!bookmarkModel)
return nil;
return [self menuForBookmarkNode:bookmarkModel->bookmark_bar_node()];
}
- (void)willExecuteCommand:(int)command {
// Some items should not close currently-open sub-folder menus.
switch (command) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment