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