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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h

Issue 7465090: [Mac] Replace the custom bookmark menus with native NSMenus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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_menu_bridge.h
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h
index 5fd4f626993b6ee989a29fb1efeec6aa93dc818a..a45205e3c54b76dfccfc1f0c962f6dc303bae135 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h
@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// C++ controller for the bookmark menu; one per AppController (which
-// means there is only one). When bookmarks are changed, this class
-// takes care of updating Cocoa bookmark menus. This is not named
-// BookmarkMenuController to help avoid confusion between languages.
-// This class needs to be C++, not ObjC, since it derives from
-// BookmarkModelObserver.
+
+// C++ class that connects a BookmarkNode (or the entire model) to a Cocoa class
+// that manages an NSMenu. Commonly this is for the main menu and that instance
+// is owned by the AppController. This is also used by the folder menus on the
+// bookmark bar.
//
-// Most Chromium Cocoa menu items are static from a nib (e.g. New
-// Tab), but may be enabled/disabled under certain circumstances
+// In the main menu case, most Chromium Cocoa menu items are static from a nib
+// (e.g. New Tab), but may be enabled/disabled under certain circumstances
// (e.g. Cut and Paste). In addition, most Cocoa menu items have
// firstResponder: as a target. Unusually, bookmark menu items are
// created dynamically. They also have a target of
@@ -37,7 +36,14 @@ class Profile;
class BookmarkMenuBridge : public BookmarkModelObserver,
public MainMenuItem {
public:
+ // Constructor for the main menu which lists all bookmarks.
BookmarkMenuBridge(Profile* profile, NSMenu* menu);
+
+ // Constructor for a submenu.
+ BookmarkMenuBridge(const BookmarkNode* root_node,
+ Profile* profile,
+ NSMenu* menu);
+
virtual ~BookmarkMenuBridge();
// BookmarkModelObserver:
@@ -75,6 +81,7 @@ class BookmarkMenuBridge : public BookmarkModelObserver,
// I wish I had a "friend @class" construct.
BookmarkModel* GetBookmarkModel();
Profile* GetProfile();
+ BookmarkMenuCocoaController* controller() { return controller_.get(); }
protected:
// Rebuilds the bookmark content of supplied menu.
@@ -84,7 +91,7 @@ class BookmarkMenuBridge : public BookmarkModelObserver,
void ClearBookmarkMenu(NSMenu* menu);
// Mark the bookmark menu as being invalid.
- void InvalidateMenu() { menuIsValid_ = false; }
+ void InvalidateMenu() { menu_is_valid_ = false; }
// Helper for adding the node as a submenu to the menu with the
// given title.
@@ -134,10 +141,13 @@ class BookmarkMenuBridge : public BookmarkModelObserver,
friend class BookmarkMenuBridgeTest;
// True iff the menu is up-to-date with the actual BookmarkModel.
- bool menuIsValid_;
+ bool menu_is_valid_;
+
+ // The root node of the menu.
+ const BookmarkNode* root_node_;
- Profile* profile_; // weak
- BookmarkMenuCocoaController* controller_; // strong
+ Profile* profile_; // Weak.
+ scoped_nsobject<BookmarkMenuCocoaController> controller_;
// The folder image so we can use one copy for all.
scoped_nsobject<NSImage> folder_image_;

Powered by Google App Engine
This is Rietveld 408576698