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; | |
21 | 20 |
22 @interface BookmarkMenuCocoaController : NSObject<NSMenuDelegate> { | 21 @interface BookmarkMenuCocoaController : NSObject<NSMenuDelegate> { |
23 @private | 22 @private |
24 BookmarkMenuBridge* bridge_; // weak; owns me | 23 BookmarkMenuBridge* bridge_; // weak; owns me |
25 NSMenu* menu_; | 24 NSMenu *menu_; |
26 id<BookmarkMenuDelegate> delegate_; | |
27 } | 25 } |
28 | 26 |
| 27 // The Bookmarks menu |
29 @property(nonatomic, readonly) NSMenu* menu; | 28 @property(nonatomic, readonly) NSMenu* menu; |
30 @property(nonatomic, assign) id<BookmarkMenuDelegate> delegate; | |
31 | 29 |
32 // Return an autoreleased string to be used as a menu title for the | 30 // Return an autoreleased string to be used as a menu title for the |
33 // given bookmark node. | 31 // given bookmark node. |
34 + (NSString*)menuTitleForNode:(const BookmarkNode*)node; | 32 + (NSString*)menuTitleForNode:(const BookmarkNode*)node; |
35 | 33 |
36 // Make a relevant tooltip string for node. | 34 // Make a relevant tooltip string for node. |
37 + (NSString*)tooltipForNode:(const BookmarkNode*)node; | 35 + (NSString*)tooltipForNode:(const BookmarkNode*)node; |
38 | 36 |
39 - (id)initWithBridge:(BookmarkMenuBridge *)bridge | 37 - (id)initWithBridge:(BookmarkMenuBridge *)bridge |
40 andMenu:(NSMenu*)menu; | 38 andMenu:(NSMenu*)menu; |
41 | 39 |
42 // Called by any Bookmark menu item. | 40 // Called by any Bookmark menu item. |
43 // The menu item's tag is the bookmark ID. | 41 // The menu item's tag is the bookmark ID. |
44 - (IBAction)openBookmarkMenuItem:(id)sender; | 42 - (IBAction)openBookmarkMenuItem:(id)sender; |
45 - (IBAction)openAllBookmarks:(id)sender; | 43 - (IBAction)openAllBookmarks:(id)sender; |
46 - (IBAction)openAllBookmarksNewWindow:(id)sender; | 44 - (IBAction)openAllBookmarksNewWindow:(id)sender; |
47 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender; | 45 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender; |
48 | 46 |
49 @end // BookmarkMenuCocoaController | 47 @end // BookmarkMenuCocoaController |
50 | 48 |
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 //////////////////////////////////////////////////////////////////////////////// | |
64 | 49 |
65 @interface BookmarkMenuCocoaController (ExposedForUnitTests) | 50 @interface BookmarkMenuCocoaController (ExposedForUnitTests) |
66 - (const BookmarkNode*)nodeForIdentifier:(int)identifier; | 51 - (const BookmarkNode*)nodeForIdentifier:(int)identifier; |
67 - (void)openURLForNode:(const BookmarkNode*)node; | 52 - (void)openURLForNode:(const BookmarkNode*)node; |
68 - (void)openAll:(NSInteger)tag | 53 - (void)openAll:(NSInteger)tag |
69 withDisposition:(WindowOpenDisposition)disposition; | 54 withDisposition:(WindowOpenDisposition)disposition; |
70 @end // BookmarkMenuCocoaController (ExposedForUnitTests) | 55 @end // BookmarkMenuCocoaController (ExposedForUnitTests) |
71 | 56 |
72 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ | 57 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_MENU_COCOA_CONTROLLER_H_ |
OLD | NEW |