1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_CONTEXT_MENU_COCOA_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_CONTEXT_MENU_COCOA_CONTROLLER_H_ 7 8 #import <Cocoa/Cocoa.h> 9 10 #include "base/basictypes.h" 11 #include "base/mac/scoped_nsobject.h" 12 #include "base/memory/scoped_ptr.h" 13 14 @class BookmarkBarController; 15 class BookmarkContextMenuController; 16 class BookmarkContextMenuDelegateBridge; 17 class BookmarkModel; 18 class BookmarkNode; 19 @class MenuController; 20 21 // A controller to manage bookmark bar context menus. One instance of this 22 // class exists per bookmark bar controller, used for all of its context menus 23 // (including those for items in bookmark bar folder drop downs). 24 @interface BookmarkContextMenuCocoaController : NSObject { 25 @private 26 // Bookmark bar controller, used for retrieving the Browser, Profile and 27 // NSWindow when instantiating the BookmarkContextMenuController. Weak, owns 28 // us. 29 BookmarkBarController* bookmarkBarController_; 30 31 // Helper for receiving C++ callbacks. 32 scoped_ptr<BookmarkContextMenuDelegateBridge> bridge_; 33 34 // The current |bookmarkNode_| for which |bookmarkContextMenuController_| and 35 // |menuController_| are initialized. Weak, owned by the BookmarkModel. 36 const BookmarkNode* bookmarkNode_; 37 38 // The cross-platform BookmarkContextMenuController, containing the logic for 39 // which items and corresponding actions exist in the menu. 40 scoped_ptr<BookmarkContextMenuController> bookmarkContextMenuController_; 41 42 // Controller responsible for creating a Cocoa NSMenu from the cross-platform 43 // SimpleMenuModel owned by the |bookmarkContextMenuController_|. 44 base::scoped_nsobject<MenuController> menuController_; 45 } 46 47 // Initializes the BookmarkContextMenuCocoaController for the given bookmark 48 // bar |controller|. 49 - (id)initWithBookmarkBarController:(BookmarkBarController*)controller; 50 51 // Returns an NSMenu customized for |node|. Works under the assumption that 52 // only one menu should ever be shown at a time, and thus caches the last 53 // returned menu and re-creates it if a menu for a different node is requested. 54 // Passing in a NULL |node| will return the menu for "empty" placeholder. 55 - (NSMenu*)menuForBookmarkNode:(const BookmarkNode*)node; 56 57 // Returns an NSMenu customized for the bookmark bar. 58 - (NSMenu*)menuForBookmarkBar; 59 60 // Closes the menu, if it's currently open. 61 - (void)cancelTracking; 62 63 @end 64 65 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_CONTEXT_MENU_COCOA_CONTROLLER_H_ 66