| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COCOA_BOOKMARK_BAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/scoped_nsobject.h" | 10 #include "base/scoped_nsobject.h" |
| 11 #include "chrome/browser/cocoa/bookmark_bar_bridge.h" | 11 #include "chrome/browser/cocoa/bookmark_bar_bridge.h" |
| 12 #include "webkit/glue/window_open_disposition.h" | 12 #include "webkit/glue/window_open_disposition.h" |
| 13 | 13 |
| 14 @class BookmarkBarStateController; | 14 @class BookmarkBarStateController; |
| 15 class BookmarkModel; | 15 class BookmarkModel; |
| 16 class BookmarkNode; | 16 class BookmarkNode; |
| 17 @class BookmarkBarView; | 17 @class BookmarkBarView; |
| 18 class Profile; | 18 class Profile; |
| 19 class PrefService; | 19 class PrefService; |
| 20 | 20 |
| 21 // The interface for an object which can open URLs for a bookmark. | 21 // The interface for an object which can open URLs for a bookmark. |
| 22 @protocol BookmarkURLOpener | 22 @protocol BookmarkURLOpener |
| 23 - (void)openBookmarkURL:(const GURL&)url | 23 - (void)openBookmarkURL:(const GURL&)url |
| 24 disposition:(WindowOpenDisposition)disposition; | 24 disposition:(WindowOpenDisposition)disposition; |
| 25 @end | 25 @end |
| 26 | 26 |
| 27 | 27 |
| 28 // A controller for the bookmark bar in the browser window. Handles showing | 28 // A controller for the bookmark bar in the browser window. Handles showing |
| 29 // and hiding based on the preference in the given profile. | 29 // and hiding based on the preference in the given profile. |
| 30 @interface BookmarkBarController : NSObject { | 30 @interface BookmarkBarController : NSViewController { |
| 31 @private | 31 @private |
| 32 BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the | 32 BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the |
| 33 // top-level Browser object. | 33 // top-level Browser object. |
| 34 PrefService* preferences_; // (ditto) | 34 PrefService* preferences_; // (ditto) |
| 35 | 35 |
| 36 // Currently these two are always the same when not in fullscreen | 36 // Currently these two are always the same when not in fullscreen |
| 37 // mode, but they mean slightly different things. | 37 // mode, but they mean slightly different things. |
| 38 // contentAreaHasOffset_ is an implementation detail of bookmark bar | 38 // contentAreaHasOffset_ is an implementation detail of bookmark bar |
| 39 // show state. | 39 // show state. |
| 40 BOOL contentViewHasOffset_; | 40 BOOL contentViewHasOffset_; |
| 41 BOOL barShouldBeShown_; | 41 BOOL barShouldBeShown_; |
| 42 | 42 |
| 43 // If the bar is disabled, we hide it and ignore show/hide commands. | 43 // If the bar is disabled, we hide it and ignore show/hide commands. |
| 44 // Set when using fullscreen mode. | 44 // Set when using fullscreen mode. |
| 45 BOOL barIsEnabled_; | 45 BOOL barIsEnabled_; |
| 46 | 46 |
| 47 // The view of the bookmark bar itself. | 47 NSView* parentView_; // weak; our parent view |
| 48 // Owned by the toolbar view, its parent view. | |
| 49 BookmarkBarView* bookmarkBarView_; // weak | |
| 50 | |
| 51 NSView* webContentView_; // weak; where the web goes | 48 NSView* webContentView_; // weak; where the web goes |
| 52 | 49 |
| 53 // Bridge from Chrome-style C++ notifications (e.g. derived from | 50 // Bridge from Chrome-style C++ notifications (e.g. derived from |
| 54 // BookmarkModelObserver) | 51 // BookmarkModelObserver) |
| 55 scoped_ptr<BookmarkBarBridge> bridge_; | 52 scoped_ptr<BookmarkBarBridge> bridge_; |
| 56 | 53 |
| 57 // Delegate which can open URLs for us. | 54 // Delegate which can open URLs for us. |
| 58 id<BookmarkURLOpener> delegate_; // weak | 55 id<BookmarkURLOpener> delegate_; // weak |
| 56 |
| 57 IBOutlet NSMenu* buttonContextMenu_; |
| 59 } | 58 } |
| 60 | 59 |
| 61 // Initializes the controller with the given browser profile and | 60 // Initializes the bookmark bar controller with the given browser |
| 62 // content view. We use |webContentView| as the view for the bookmark | 61 // profile, parent view (the toolbar), web content view, and delegate. |
| 63 // bar view and for geometry management. |delegate| is used for | 62 // |delegate| is used for opening URLs. |
| 64 // opening URLs. |view| is expected to be hidden. | |
| 65 - (id)initWithProfile:(Profile*)profile | 63 - (id)initWithProfile:(Profile*)profile |
| 66 view:(BookmarkBarView*)view | 64 parentView:(NSView*)parentView |
| 67 webContentView:(NSView*)webContentView | 65 webContentView:(NSView*)webContentView |
| 68 delegate:(id<BookmarkURLOpener>)delegate; | 66 delegate:(id<BookmarkURLOpener>)delegate; |
| 69 | 67 |
| 70 // Returns whether or not the bookmark bar is visible. | 68 // Returns whether or not the bookmark bar is visible. |
| 71 - (BOOL)isBookmarkBarVisible; | 69 - (BOOL)isBookmarkBarVisible; |
| 72 | 70 |
| 73 // Toggle the state of the bookmark bar. | 71 // Toggle the state of the bookmark bar. |
| 74 - (void)toggleBookmarkBar; | 72 - (void)toggleBookmarkBar; |
| 75 | 73 |
| 76 // Turn on or off the bookmark bar and prevent or reallow its | 74 // Turn on or off the bookmark bar and prevent or reallow its |
| 77 // appearance. On disable, toggle off if shown. On enable, show only | 75 // appearance. On disable, toggle off if shown. On enable, show only |
| 78 // if needed. For fullscreen mode. | 76 // if needed. For fullscreen mode. |
| 79 - (void)setBookmarkBarEnabled:(BOOL)enabled; | 77 - (void)setBookmarkBarEnabled:(BOOL)enabled; |
| 80 | 78 |
| 79 // Actions for opening bookmarks. From a button, ... |
| 80 - (IBAction)openBookmark:(id)sender; |
| 81 // ... or from a context menu over the button. |
| 82 - (IBAction)openBookmarkInNewForegroundTab:(id)sender; |
| 83 - (IBAction)openBookmarkInNewWindow:(id)sender; |
| 84 - (IBAction)openBookmarkInIncognitoWindow:(id)sender; |
| 85 - (IBAction)deleteBookmark:(id)sender; |
| 86 |
| 81 @end | 87 @end |
| 82 | 88 |
| 83 // Redirects from BookmarkBarBridge, the C++ object which glues us to | 89 // Redirects from BookmarkBarBridge, the C++ object which glues us to |
| 84 // the rest of Chromium. Internal to BookmarkBarController. | 90 // the rest of Chromium. Internal to BookmarkBarController. |
| 85 @interface BookmarkBarController(BridgeRedirect) | 91 @interface BookmarkBarController(BridgeRedirect) |
| 86 - (void)loaded:(BookmarkModel*)model; | 92 - (void)loaded:(BookmarkModel*)model; |
| 87 - (void)beingDeleted:(BookmarkModel*)model; | 93 - (void)beingDeleted:(BookmarkModel*)model; |
| 88 - (void)nodeMoved:(BookmarkModel*)model | 94 - (void)nodeMoved:(BookmarkModel*)model |
| 89 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex | 95 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex |
| 90 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex; | 96 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex; |
| 91 - (void)nodeAdded:(BookmarkModel*)model | 97 - (void)nodeAdded:(BookmarkModel*)model |
| 92 parent:(const BookmarkNode*)oldParent index:(int)index; | 98 parent:(const BookmarkNode*)oldParent index:(int)index; |
| 99 - (void)nodeRemoved:(BookmarkModel*)model |
| 100 parent:(const BookmarkNode*)oldParent index:(int)index; |
| 93 - (void)nodeChanged:(BookmarkModel*)model | 101 - (void)nodeChanged:(BookmarkModel*)model |
| 94 node:(const BookmarkNode*)node; | 102 node:(const BookmarkNode*)node; |
| 95 - (void)nodeFavIconLoaded:(BookmarkModel*)model | 103 - (void)nodeFavIconLoaded:(BookmarkModel*)model |
| 96 node:(const BookmarkNode*)node; | 104 node:(const BookmarkNode*)node; |
| 97 - (void)nodeChildrenReordered:(BookmarkModel*)model | 105 - (void)nodeChildrenReordered:(BookmarkModel*)model |
| 98 node:(const BookmarkNode*)node; | 106 node:(const BookmarkNode*)node; |
| 99 @end | 107 @end |
| 100 | 108 |
| 101 | 109 |
| 102 // These APIs should only be used by unit tests (or used internally). | 110 // These APIs should only be used by unit tests (or used internally). |
| 103 @interface BookmarkBarController(TestingAPI) | 111 @interface BookmarkBarController(TestingAPI) |
| 104 // Access to the bookmark bar's view represented by this controller. | |
| 105 - (NSView*)view; | |
| 106 // Set the delegate for a unit test. | 112 // Set the delegate for a unit test. |
| 107 - (void)setDelegate:(id<BookmarkURLOpener>)delegate; | 113 - (void)setDelegate:(id<BookmarkURLOpener>)delegate; |
| 108 // Action for our bookmark buttons. | |
| 109 - (void)openBookmark:(id)sender; | |
| 110 @end | 114 @end |
| 111 | 115 |
| 112 #endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ | 116 #endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ |
| OLD | NEW |