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

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 1308983009: [Mac] Remove extraneous Bookmarks menu from menu bar when running apps from launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer feedback Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 137a0605b44a98a3251cb5844cc57e5e4fcc572e..8794efd0007660e647bfe3dc81ee33441c143d7d 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -1580,22 +1580,30 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
if (historyMenuBridge_)
historyMenuBridge_->ResetMenu();
- // Rebuild the menus with the new profile.
+ // Rebuild the menus with the new profile. The bookmarks submenu is cached to
+ // avoid slowdowns when switching between profiles with large numbers of
+ // bookmarks. Before caching, store whether it is hidden, make the menu item
+ // visible, and restore its original hidden state after resetting the submenu.
+ // This works around an apparent AppKit bug where setting a *different* NSMenu
+ // submenu on a *hidden* menu item forces the item to become visible.
+ // See https://crbug.com/497813 for more details.
+ NSMenuItem* bookmarkItem = [[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU];
+ BOOL hidden = [bookmarkItem isHidden];
+ [bookmarkItem setHidden:NO];
lastProfile_ = profile;
auto it = profileBookmarkMenuBridgeMap_.find(profile->GetPath());
if (it == profileBookmarkMenuBridgeMap_.end()) {
- base::scoped_nsobject<NSMenu> submenu(
- [[[[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU] submenu] copy]);
+ base::scoped_nsobject<NSMenu> submenu([[bookmarkItem submenu] copy]);
bookmarkMenuBridge_ = new BookmarkMenuBridge(profile, submenu);
profileBookmarkMenuBridgeMap_[profile->GetPath()] = bookmarkMenuBridge_;
} else {
bookmarkMenuBridge_ = it->second;
}
- [[[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU] setSubmenu:
- bookmarkMenuBridge_->BookmarkMenu()];
// No need to |BuildMenu| here. It is done lazily upon menu access.
+ [bookmarkItem setSubmenu:bookmarkMenuBridge_->BookmarkMenu()];
+ [bookmarkItem setHidden:hidden];
historyMenuBridge_.reset(new HistoryMenuBridge(lastProfile_));
historyMenuBridge_->BuildMenu();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698