| 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 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const CGFloat kDefaultBookmarkWidth = 150.0; | 35 const CGFloat kDefaultBookmarkWidth = 150.0; |
| 36 const CGFloat kBookmarkVerticalPadding = 2.0; | 36 const CGFloat kBookmarkVerticalPadding = 2.0; |
| 37 const CGFloat kBookmarkHorizontalPadding = 1.0; | 37 const CGFloat kBookmarkHorizontalPadding = 1.0; |
| 38 | 38 |
| 39 const CGFloat kNoBookmarksHorizontalOffset = 5.0; | 39 const CGFloat kNoBookmarksHorizontalOffset = 5.0; |
| 40 const CGFloat kNoBookmarksVerticalOffset = 20.0; | 40 const CGFloat kNoBookmarksVerticalOffset = 20.0; |
| 41 const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; | 41 const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 // The interface for an object which can open URLs for a bookmark. | |
| 46 @protocol BookmarkURLOpener | |
| 47 - (void)openBookmarkURL:(const GURL&)url | |
| 48 disposition:(WindowOpenDisposition)disposition; | |
| 49 @end | |
| 50 | |
| 51 // A controller for the bookmark bar in the browser window. Handles showing | 45 // A controller for the bookmark bar in the browser window. Handles showing |
| 52 // and hiding based on the preference in the given profile. | 46 // and hiding based on the preference in the given profile. |
| 53 @interface BookmarkBarController : | 47 @interface BookmarkBarController : |
| 54 NSViewController<BookmarkBarToolbarViewController> { | 48 NSViewController<BookmarkBarToolbarViewController> { |
| 55 @private | 49 @private |
| 56 Browser* browser_; // weak; owned by its window | 50 Browser* browser_; // weak; owned by its window |
| 57 BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the | 51 BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the |
| 58 // top-level Browser object. | 52 // top-level Browser object. |
| 59 | 53 |
| 60 // Our initial view width, which is applied in awakeFromNib. | 54 // Our initial view width, which is applied in awakeFromNib. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 // BookmarkModelObserver) | 78 // BookmarkModelObserver) |
| 85 scoped_ptr<BookmarkBarBridge> bridge_; | 79 scoped_ptr<BookmarkBarBridge> bridge_; |
| 86 | 80 |
| 87 // Delegate that is alerted about whether it should be compressed because | 81 // Delegate that is alerted about whether it should be compressed because |
| 88 // it's right next to us. | 82 // it's right next to us. |
| 89 id<ToolbarCompressable> compressDelegate_; // weak | 83 id<ToolbarCompressable> compressDelegate_; // weak |
| 90 | 84 |
| 91 // Delegate that can resize us. | 85 // Delegate that can resize us. |
| 92 id<ViewResizer> resizeDelegate_; // weak | 86 id<ViewResizer> resizeDelegate_; // weak |
| 93 | 87 |
| 94 // Delegate that can open URLs for us. | |
| 95 id<BookmarkURLOpener> urlDelegate_; // weak | |
| 96 | |
| 97 // Lets us get TabSelectedAt notifications. | 88 // Lets us get TabSelectedAt notifications. |
| 98 scoped_ptr<TabStripModelObserverBridge> tabObserver_; | 89 scoped_ptr<TabStripModelObserverBridge> tabObserver_; |
| 99 | 90 |
| 100 IBOutlet BookmarkBarView* buttonView_; | 91 IBOutlet BookmarkBarView* buttonView_; |
| 101 IBOutlet MenuButton* offTheSideButton_; // aka the chevron | 92 IBOutlet MenuButton* offTheSideButton_; // aka the chevron |
| 102 IBOutlet NSMenu* buttonContextMenu_; | 93 IBOutlet NSMenu* buttonContextMenu_; |
| 103 | 94 |
| 104 // "Other bookmarks" button on the right side. | 95 // "Other bookmarks" button on the right side. |
| 105 scoped_nsobject<NSButton> otherBookmarksButton_; | 96 scoped_nsobject<NSButton> otherBookmarksButton_; |
| 106 } | 97 } |
| 107 | 98 |
| 108 // Initializes the bookmark bar controller with the given browser | 99 // Initializes the bookmark bar controller with the given browser |
| 109 // profile and delegates. | 100 // profile and delegates. |
| 110 - (id)initWithBrowser:(Browser*)browser | 101 - (id)initWithBrowser:(Browser*)browser |
| 111 initialWidth:(float)initialWidth | 102 initialWidth:(float)initialWidth |
| 112 compressDelegate:(id<ToolbarCompressable>)compressDelegate | 103 compressDelegate:(id<ToolbarCompressable>)compressDelegate |
| 113 resizeDelegate:(id<ViewResizer>)resizeDelegate | 104 resizeDelegate:(id<ViewResizer>)resizeDelegate; |
| 114 urlDelegate:(id<BookmarkURLOpener>)urlDelegate; | |
| 115 | 105 |
| 116 // Returns the backdrop to the bookmark bar. | 106 // Returns the backdrop to the bookmark bar. |
| 117 - (BackgroundGradientView*)backgroundGradientView; | 107 - (BackgroundGradientView*)backgroundGradientView; |
| 118 | 108 |
| 119 // Tell the bar to show itself if needed (e.g. if the kShowBookmarkBar | 109 // Tell the bar to show itself if needed (e.g. if the kShowBookmarkBar |
| 120 // is set). Called once after the controller is first created. | 110 // is set). Called once after the controller is first created. |
| 121 - (void)showIfNeeded; | 111 - (void)showIfNeeded; |
| 122 | 112 |
| 123 // Update the visible state of the bookmark bar based on the current value of | 113 // Update the visible state of the bookmark bar based on the current value of |
| 124 // -[BookmarkBarController isAlwaysVisible]. | 114 // -[BookmarkBarController isAlwaysVisible]. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 152 - (IBAction)openFolderMenuFromButton:(id)sender; | 142 - (IBAction)openFolderMenuFromButton:(id)sender; |
| 153 // From a context menu over the button, ... | 143 // From a context menu over the button, ... |
| 154 - (IBAction)openBookmarkInNewForegroundTab:(id)sender; | 144 - (IBAction)openBookmarkInNewForegroundTab:(id)sender; |
| 155 - (IBAction)openBookmarkInNewWindow:(id)sender; | 145 - (IBAction)openBookmarkInNewWindow:(id)sender; |
| 156 - (IBAction)openBookmarkInIncognitoWindow:(id)sender; | 146 - (IBAction)openBookmarkInIncognitoWindow:(id)sender; |
| 157 - (IBAction)editBookmark:(id)sender; | 147 - (IBAction)editBookmark:(id)sender; |
| 158 - (IBAction)copyBookmark:(id)sender; | 148 - (IBAction)copyBookmark:(id)sender; |
| 159 - (IBAction)deleteBookmark:(id)sender; | 149 - (IBAction)deleteBookmark:(id)sender; |
| 160 // From a context menu over the bar, ... | 150 // From a context menu over the bar, ... |
| 161 - (IBAction)openAllBookmarks:(id)sender; | 151 - (IBAction)openAllBookmarks:(id)sender; |
| 152 - (IBAction)openAllBookmarksNewWindow:(id)sender; |
| 153 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender; |
| 162 // Or from a context menu over either the bar or a button. | 154 // Or from a context menu over either the bar or a button. |
| 163 - (IBAction)addPage:(id)sender; | 155 - (IBAction)addPage:(id)sender; |
| 164 - (IBAction)addFolder:(id)sender; | 156 - (IBAction)addFolder:(id)sender; |
| 165 | 157 |
| 166 @end | 158 @end |
| 167 | 159 |
| 168 // Redirects from BookmarkBarBridge, the C++ object which glues us to | 160 // Redirects from BookmarkBarBridge, the C++ object which glues us to |
| 169 // the rest of Chromium. Internal to BookmarkBarController. | 161 // the rest of Chromium. Internal to BookmarkBarController. |
| 170 @interface BookmarkBarController(BridgeRedirect) | 162 @interface BookmarkBarController(BridgeRedirect) |
| 171 - (void)loaded:(BookmarkModel*)model; | 163 - (void)loaded:(BookmarkModel*)model; |
| 172 - (void)beingDeleted:(BookmarkModel*)model; | 164 - (void)beingDeleted:(BookmarkModel*)model; |
| 173 - (void)nodeMoved:(BookmarkModel*)model | 165 - (void)nodeMoved:(BookmarkModel*)model |
| 174 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex | 166 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex |
| 175 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex; | 167 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex; |
| 176 - (void)nodeAdded:(BookmarkModel*)model | 168 - (void)nodeAdded:(BookmarkModel*)model |
| 177 parent:(const BookmarkNode*)oldParent index:(int)index; | 169 parent:(const BookmarkNode*)oldParent index:(int)index; |
| 178 - (void)nodeRemoved:(BookmarkModel*)model | 170 - (void)nodeRemoved:(BookmarkModel*)model |
| 179 parent:(const BookmarkNode*)oldParent index:(int)index; | 171 parent:(const BookmarkNode*)oldParent index:(int)index; |
| 180 - (void)nodeChanged:(BookmarkModel*)model | 172 - (void)nodeChanged:(BookmarkModel*)model |
| 181 node:(const BookmarkNode*)node; | 173 node:(const BookmarkNode*)node; |
| 182 - (void)nodeFavIconLoaded:(BookmarkModel*)model | 174 - (void)nodeFavIconLoaded:(BookmarkModel*)model |
| 183 node:(const BookmarkNode*)node; | 175 node:(const BookmarkNode*)node; |
| 184 - (void)nodeChildrenReordered:(BookmarkModel*)model | 176 - (void)nodeChildrenReordered:(BookmarkModel*)model |
| 185 node:(const BookmarkNode*)node; | 177 node:(const BookmarkNode*)node; |
| 186 @end | 178 @end |
| 187 | 179 |
| 188 | 180 |
| 189 // These APIs should only be used by unit tests (or used internally). | 181 // These APIs should only be used by unit tests (or used internally). |
| 190 @interface BookmarkBarController(InternalOrTestingAPI) | 182 @interface BookmarkBarController(InternalOrTestingAPI) |
| 191 // Set the delegate for a unit test. | 183 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; |
| 192 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate; | |
| 193 - (NSCell*)cellForBookmarkNode:(const BookmarkNode*)node; | 184 - (NSCell*)cellForBookmarkNode:(const BookmarkNode*)node; |
| 194 - (void)clearBookmarkBar; | 185 - (void)clearBookmarkBar; |
| 195 - (BookmarkBarView*)buttonView; | 186 - (BookmarkBarView*)buttonView; |
| 196 - (NSArray*)buttons; | 187 - (NSArray*)buttons; |
| 197 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; | 188 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; |
| 198 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; | 189 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; |
| 199 - (void)frameDidChange; | 190 - (void)frameDidChange; |
| 200 - (BOOL)offTheSideButtonIsHidden; | 191 - (BOOL)offTheSideButtonIsHidden; |
| 201 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node; | 192 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node; |
| 202 - (int64)nodeIdFromMenuTag:(int32)tag; | 193 - (int64)nodeIdFromMenuTag:(int32)tag; |
| 203 - (int32)menuTagFromNodeId:(int64)menuid; | 194 - (int32)menuTagFromNodeId:(int64)menuid; |
| 204 - (void)buildOffTheSideMenu; | 195 - (void)buildOffTheSideMenu; |
| 205 - (NSMenu*)offTheSideMenu; | 196 - (NSMenu*)offTheSideMenu; |
| 206 - (NSButton*)offTheSideButton; | 197 - (NSButton*)offTheSideButton; |
| 207 - (NSButton*)otherBookmarksButton; | 198 - (NSButton*)otherBookmarksButton; |
| 208 @end | 199 @end |
| 209 | 200 |
| 210 #endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ | 201 #endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_CONTROLLER_H_ |
| OLD | NEW |