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.
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_
8 #import <Cocoa/Cocoa.h>
10 #include "base/basictypes.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
14 @
class BookmarkBarController
;
15 class BookmarkContextMenuController
;
16 class BookmarkContextMenuDelegateBridge
;
19 @
class MenuController
;
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
{
26 // Bookmark bar controller, used for retrieving the Browser, Profile and
27 // NSWindow when instantiating the BookmarkContextMenuController. Weak, owns
29 BookmarkBarController
* bookmarkBarController_
;
31 // Helper for receiving C++ callbacks.
32 scoped_ptr
<BookmarkContextMenuDelegateBridge
> bridge_
;
34 // The current |bookmarkNode_| for which |bookmarkContextMenuController_| and
35 // |menuController_| are initialized. Weak, owned by the BookmarkModel.
36 const BookmarkNode
* bookmarkNode_
;
38 // The cross-platform BookmarkContextMenuController, containing the logic for
39 // which items and corresponding actions exist in the menu.
40 scoped_ptr
<BookmarkContextMenuController
> bookmarkContextMenuController_
;
42 // Controller responsible for creating a Cocoa NSMenu from the cross-platform
43 // SimpleMenuModel owned by the |bookmarkContextMenuController_|.
44 base::scoped_nsobject
<MenuController
> menuController_
;
47 // Initializes the BookmarkContextMenuCocoaController for the given bookmark
49 - (id
)initWithBookmarkBarController
:(BookmarkBarController
*)controller
;
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
;
57 // Returns an NSMenu customized for the bookmark bar.
58 - (NSMenu
*)menuForBookmarkBar
;
60 // Closes the menu, if it's currently open.
61 - (void)cancelTracking
;
65 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_CONTEXT_MENU_COCOA_CONTROLLER_H_