summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/app_controller_mac.mm3
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h2
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm25
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h6
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm6
-rw-r--r--chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm3
6 files changed, 28 insertions, 17 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index b1acdeb..61e8e09 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -461,7 +461,8 @@ void RecordLastRunAppBundlePath() {
// Rebuild the menus with the new profile.
lastProfile_ = profile;
- bookmarkMenuBridge_.reset(new BookmarkMenuBridge(lastProfile_));
+ bookmarkMenuBridge_.reset(new BookmarkMenuBridge(lastProfile_,
+ [[[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU] submenu]));
bookmarkMenuBridge_->BuildMenu();
historyMenuBridge_.reset(new HistoryMenuBridge(lastProfile_));
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h
index 2c332e7..9e295e3 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h
@@ -37,7 +37,7 @@ class Profile;
class BookmarkMenuBridge : public BookmarkModelObserver,
public MainMenuItem {
public:
- BookmarkMenuBridge(Profile* profile);
+ BookmarkMenuBridge(Profile* profile, NSMenu* menu);
virtual ~BookmarkMenuBridge();
// BookmarkModelObserver:
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm
index 6dbf091..8ee2ffe 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.mm
@@ -21,10 +21,12 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/mac/nsimage_cache.h"
-BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile)
+BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile,
+ NSMenu *menu)
: menuIsValid_(false),
profile_(profile),
- controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this]) {
+ controller_([[BookmarkMenuCocoaController alloc] initWithBridge:this
+ andMenu:menu]) {
if (GetBookmarkModel())
ObserveBookmarkModel();
}
@@ -77,14 +79,17 @@ void BookmarkMenuBridge::UpdateMenuInternal(NSMenu* bookmark_menu,
AddNodeToMenu(barNode, bookmark_menu, !is_submenu);
}
- // Create a submenu for "other bookmarks", and fill it in.
- NSString* other_items_title =
- l10n_util::GetNSString(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME);
- [bookmark_menu addItem:[NSMenuItem separatorItem]];
- AddNodeAsSubmenu(bookmark_menu,
- model->other_node(),
- other_items_title,
- !is_submenu);
+ // If the "Other Bookmarks" folder has any content, make a submenu for it and
+ // fill it in.
+ if (!model->other_node()->empty()) {
+ NSString* other_items_title =
+ l10n_util::GetNSString(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME);
+ [bookmark_menu addItem:[NSMenuItem separatorItem]];
+ AddNodeAsSubmenu(bookmark_menu,
+ model->other_node(),
+ other_items_title,
+ !is_submenu);
+ }
menuIsValid_ = true;
}
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h
index 7a267ad..aeedcdb 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,6 +21,7 @@ class BookmarkMenuBridge;
@interface BookmarkMenuCocoaController : NSObject<NSMenuDelegate> {
@private
BookmarkMenuBridge* bridge_; // weak; owns me
+ NSMenu *menu_;
}
// The Bookmarks menu
@@ -33,7 +34,8 @@ class BookmarkMenuBridge;
// Make a relevant tooltip string for node.
+ (NSString*)tooltipForNode:(const BookmarkNode*)node;
-- (id)initWithBridge:(BookmarkMenuBridge *)bridge;
+- (id)initWithBridge:(BookmarkMenuBridge *)bridge
+ andMenu:(NSMenu*)menu;
// Called by any Bookmark menu item.
// The menu item's tag is the bookmark ID.
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm
index c100ba9..484d267 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.mm
@@ -49,10 +49,12 @@ const NSUInteger kMaximumMenuPixelsWide = 300;
return [NSString stringWithFormat:@"%@\n%@", title, url];
}
-- (id)initWithBridge:(BookmarkMenuBridge *)bridge {
+- (id)initWithBridge:(BookmarkMenuBridge *)bridge
+ andMenu:(NSMenu*)menu {
if ((self = [super init])) {
bridge_ = bridge;
DCHECK(bridge_);
+ menu_ = menu;
[[self menu] setDelegate:self];
}
return self;
@@ -64,7 +66,7 @@ const NSUInteger kMaximumMenuPixelsWide = 300;
}
- (NSMenu*)menu {
- return [[[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU] submenu];
+ return menu_;
}
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
diff --git a/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm b/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm
index f025fec..7eeff81 100644
--- a/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm
+++ b/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm
@@ -116,7 +116,8 @@ class ZoomLevelObserver : public NotificationObserver {
if (!bookmarkMenuBridge_.get()) {
bookmarkMenuBridge_.reset(
- new BookmarkMenuBridge([self wrenchMenuModel]->browser()->profile()));
+ new BookmarkMenuBridge([self wrenchMenuModel]->browser()->profile(),
+ bookmarkMenu));
}
DCHECK(bookmarkMenuBridge_.get() != NULL);