OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Controller (MVC) for the bookmark menu. | 5 // Controller (MVC) for the bookmark menu. |
6 // All bookmark menu item commands get directed here. | 6 // All bookmark menu item commands get directed here. |
7 // Unfortunately there is already a C++ class named BookmarkMenuController. | 7 // Unfortunately there is already a C++ class named BookmarkMenuController. |
8 | 8 |
9 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ | 9 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ |
10 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ | 10 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #import <Cocoa/Cocoa.h> | 13 #import <Cocoa/Cocoa.h> |
14 | 14 |
15 #import "base/mac/cocoa_protocols.h" | 15 #import "base/mac/cocoa_protocols.h" |
16 #include "webkit/glue/window_open_disposition.h" | 16 #include "webkit/glue/window_open_disposition.h" |
17 | 17 |
18 class BookmarkNode; | 18 class BookmarkNode; |
19 class BookmarkMenuBridge; | 19 class BookmarkMenuBridge; |
| 20 @protocol BookmarkMenuDelegate; |
20 | 21 |
21 @interface BookmarkMenuCocoaController : NSObject<NSMenuDelegate> { | 22 @interface BookmarkMenuCocoaController : NSObject<NSMenuDelegate> { |
22 @private | 23 @private |
23 BookmarkMenuBridge* bridge_; // weak; owns me | 24 BookmarkMenuBridge* bridge_; // weak; owns me |
24 NSMenu *menu_; | 25 NSMenu* menu_; |
| 26 id<BookmarkMenuDelegate> delegate_; |
25 } | 27 } |
26 | 28 |
27 // The Bookmarks menu | |
28 @property(nonatomic, readonly) NSMenu* menu; | 29 @property(nonatomic, readonly) NSMenu* menu; |
| 30 @property(nonatomic, assign) id<BookmarkMenuDelegate> delegate; |
29 | 31 |
30 // Return an autoreleased string to be used as a menu title for the | 32 // Return an autoreleased string to be used as a menu title for the |
31 // given bookmark node. | 33 // given bookmark node. |
32 + (NSString*)menuTitleForNode:(const BookmarkNode*)node; | 34 + (NSString*)menuTitleForNode:(const BookmarkNode*)node; |
33 | 35 |
34 // Make a relevant tooltip string for node. | 36 // Make a relevant tooltip string for node. |
35 + (NSString*)tooltipForNode:(const BookmarkNode*)node; | 37 + (NSString*)tooltipForNode:(const BookmarkNode*)node; |
36 | 38 |
37 - (id)initWithBridge:(BookmarkMenuBridge *)bridge | 39 - (id)initWithBridge:(BookmarkMenuBridge *)bridge |
38 andMenu:(NSMenu*)menu; | 40 andMenu:(NSMenu*)menu; |
39 | 41 |
40 // Called by any Bookmark menu item. | 42 // Called by any Bookmark menu item. |
41 // The menu item's tag is the bookmark ID. | 43 // The menu item's tag is the bookmark ID. |
42 - (IBAction)openBookmarkMenuItem:(id)sender; | 44 - (IBAction)openBookmarkMenuItem:(id)sender; |
43 - (IBAction)openAllBookmarks:(id)sender; | 45 - (IBAction)openAllBookmarks:(id)sender; |
44 - (IBAction)openAllBookmarksNewWindow:(id)sender; | 46 - (IBAction)openAllBookmarksNewWindow:(id)sender; |
45 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender; | 47 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender; |
46 | 48 |
47 @end // BookmarkMenuCocoaController | 49 @end // BookmarkMenuCocoaController |
48 | 50 |
| 51 //////////////////////////////////////////////////////////////////////////////// |
| 52 |
| 53 // This protocol is used to forward relevant methods from NSMenuDelegate to |
| 54 // some other object. |
| 55 @protocol BookmarkMenuDelegate <NSObject> |
| 56 @optional |
| 57 |
| 58 - (void)bookmarkMenuWillOpen:(BookmarkMenuCocoaController*)controller; |
| 59 - (void)bookmarkMenuDidClose:(BookmarkMenuCocoaController*)controller; |
| 60 |
| 61 @end |
| 62 |
| 63 //////////////////////////////////////////////////////////////////////////////// |
49 | 64 |
50 @interface BookmarkMenuCocoaController (ExposedForUnitTests) | 65 @interface BookmarkMenuCocoaController (ExposedForUnitTests) |
51 - (const BookmarkNode*)nodeForIdentifier:(int)identifier; | 66 - (const BookmarkNode*)nodeForIdentifier:(int)identifier; |
52 - (void)openURLForNode:(const BookmarkNode*)node; | 67 - (void)openURLForNode:(const BookmarkNode*)node; |
53 - (void)openAll:(NSInteger)tag | 68 - (void)openAll:(NSInteger)tag |
54 withDisposition:(WindowOpenDisposition)disposition; | 69 withDisposition:(WindowOpenDisposition)disposition; |
55 @end // BookmarkMenuCocoaController (ExposedForUnitTests) | 70 @end // BookmarkMenuCocoaController (ExposedForUnitTests) |
56 | 71 |
57 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ | 72 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ |
OLD | NEW |