| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 class BookmarkNode; | 41 class BookmarkNode; |
| 42 class ManagedBookmarkService; | 42 class ManagedBookmarkService; |
| 43 | 43 |
| 44 // Magic numbers from Cole | 44 // Magic numbers from Cole |
| 45 // TODO(jrg): create an objc-friendly version of bookmark_bar_constants.h? | 45 // TODO(jrg): create an objc-friendly version of bookmark_bar_constants.h? |
| 46 | 46 |
| 47 // Used as a maximum width for buttons on the bar. | 47 // Used as a maximum width for buttons on the bar. |
| 48 const CGFloat kDefaultBookmarkWidth = 150.0; | 48 const CGFloat kDefaultBookmarkWidth = 150.0; |
| 49 | 49 |
| 50 // Horizontal frame inset for buttons in the bookmark bar. | 50 // Horizontal frame inset for buttons in the bookmark bar. |
| 51 CGFloat BookmarkHorizontalPadding(); | 51 const CGFloat kBookmarkHorizontalPadding = 1.0; |
| 52 | 52 |
| 53 // Vertical frame inset for buttons in the bookmark bar. | 53 // Vertical frame inset for buttons in the bookmark bar. |
| 54 CGFloat BookmarkVerticalPadding(); | 54 const CGFloat kBookmarkVerticalPadding = 2.0; |
| 55 | 55 |
| 56 // Left margin before the first button in the bookmark bar. | 56 // Left margin before the first button in the bookmark bar. |
| 57 CGFloat BookmarkLeftMargin(); | 57 const CGFloat kBookmarkLeftMargin = 2.0; |
| 58 | 58 |
| 59 // Right margin before the last button in the bookmark bar. | 59 // Right margin before the last button in the bookmark bar. |
| 60 CGFloat BookmarkRightMargin(); | 60 const CGFloat kBookmarkRightMargin = 2.0; |
| 61 | 61 |
| 62 // Used as a min/max width for buttons on menus (not on the bar). | 62 // Used as a min/max width for buttons on menus (not on the bar). |
| 63 const CGFloat kBookmarkMenuButtonMinimumWidth = 100.0; | 63 const CGFloat kBookmarkMenuButtonMinimumWidth = 100.0; |
| 64 const CGFloat kBookmarkMenuButtonMaximumWidth = 485.0; | 64 const CGFloat kBookmarkMenuButtonMaximumWidth = 485.0; |
| 65 | 65 |
| 66 // The minimum separation between a folder menu and the edge of the screen. | 66 // The minimum separation between a folder menu and the edge of the screen. |
| 67 // If the menu gets closer to the edge of the screen (either right or left) | 67 // If the menu gets closer to the edge of the screen (either right or left) |
| 68 // then it is pops up in the opposite direction. | 68 // then it is pops up in the opposite direction. |
| 69 // (See -[BookmarkBarFolderController childFolderWindowLeftForWidth:]). | 69 // (See -[BookmarkBarFolderController childFolderWindowLeftForWidth:]). |
| 70 const CGFloat kBookmarkHorizontalScreenPadding = 8.0; | 70 const CGFloat kBookmarkHorizontalScreenPadding = 8.0; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // node from the item. When adding items in, we start with seedId_. | 189 // node from the item. When adding items in, we start with seedId_. |
| 190 int32_t seedId_; | 190 int32_t seedId_; |
| 191 std::map<int32_t, int64_t> menuTagMap_; | 191 std::map<int32_t, int64_t> menuTagMap_; |
| 192 | 192 |
| 193 // Our bookmark buttons, ordered from L-->R. | 193 // Our bookmark buttons, ordered from L-->R. |
| 194 base::scoped_nsobject<NSMutableArray> buttons_; | 194 base::scoped_nsobject<NSMutableArray> buttons_; |
| 195 | 195 |
| 196 // The folder image so we can use one copy for all buttons | 196 // The folder image so we can use one copy for all buttons |
| 197 base::scoped_nsobject<NSImage> folderImage_; | 197 base::scoped_nsobject<NSImage> folderImage_; |
| 198 | 198 |
| 199 // The Material Design Incognito folder image so we can use one copy for all | |
| 200 // buttons | |
| 201 base::scoped_nsobject<NSImage> folderImageWhite_; | |
| 202 | |
| 203 // The default image, so we can use one copy for all buttons. | 199 // The default image, so we can use one copy for all buttons. |
| 204 base::scoped_nsobject<NSImage> defaultImage_; | 200 base::scoped_nsobject<NSImage> defaultImage_; |
| 205 | 201 |
| 206 // If the bar is disabled, we hide it and ignore show/hide commands. | 202 // If the bar is disabled, we hide it and ignore show/hide commands. |
| 207 // Set when using fullscreen mode. | 203 // Set when using fullscreen mode. |
| 208 BOOL barIsEnabled_; | 204 BOOL barIsEnabled_; |
| 209 | 205 |
| 210 // Bridge from Chrome-style C++ notifications (e.g. derived from | 206 // Bridge from Chrome-style C++ notifications (e.g. derived from |
| 211 // BookmarkModelObserver) | 207 // BookmarkModelObserver) |
| 212 std::unique_ptr<BookmarkBarBridge> bridge_; | 208 std::unique_ptr<BookmarkBarBridge> bridge_; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 - (CGFloat)toolbarDividerOpacity; | 356 - (CGFloat)toolbarDividerOpacity; |
| 361 | 357 |
| 362 // Updates the sizes and positions of the subviews. | 358 // Updates the sizes and positions of the subviews. |
| 363 // TODO(viettrungluu): I'm not convinced this should be public, but I currently | 359 // TODO(viettrungluu): I'm not convinced this should be public, but I currently |
| 364 // need it for animations. Try not to propagate its use. | 360 // need it for animations. Try not to propagate its use. |
| 365 - (void)layoutSubviews; | 361 - (void)layoutSubviews; |
| 366 | 362 |
| 367 // Called by our view when it is moved to a window. | 363 // Called by our view when it is moved to a window. |
| 368 - (void)viewDidMoveToWindow; | 364 - (void)viewDidMoveToWindow; |
| 369 | 365 |
| 370 // Provide a favicon for a bookmark node, specifying whether or not it's for | 366 // Provide a favicon for a bookmark node. May return nil. |
| 371 // use with a dark window theme. May return nil. | 367 - (NSImage*)faviconForNode:(const bookmarks::BookmarkNode*)node; |
| 372 - (NSImage*)faviconForNode:(const bookmarks::BookmarkNode*)node | |
| 373 forADarkTheme:(BOOL)forADarkTheme; | |
| 374 | 368 |
| 375 // Used for situations where the bookmark bar folder menus should no longer | 369 // Used for situations where the bookmark bar folder menus should no longer |
| 376 // be actively popping up. Called when the window loses focus, a click has | 370 // be actively popping up. Called when the window loses focus, a click has |
| 377 // occured outside the menus or a bookmark has been activated. (Note that this | 371 // occured outside the menus or a bookmark has been activated. (Note that this |
| 378 // differs from the behavior of the -[BookmarkButtonControllerProtocol | 372 // differs from the behavior of the -[BookmarkButtonControllerProtocol |
| 379 // closeAllBookmarkFolders] method in that the latter does not terminate menu | 373 // closeAllBookmarkFolders] method in that the latter does not terminate menu |
| 380 // tracking since it may be being called in response to actions (such as | 374 // tracking since it may be being called in response to actions (such as |
| 381 // dragging) where a 'stale' menu presentation should first be collapsed before | 375 // dragging) where a 'stale' menu presentation should first be collapsed before |
| 382 // presenting a new menu.) | 376 // presenting a new menu.) |
| 383 - (void)closeFolderAndStopTrackingMenus; | 377 - (void)closeFolderAndStopTrackingMenus; |
| 384 | 378 |
| 385 // Checks if operations such as edit or delete are allowed. | 379 // Checks if operations such as edit or delete are allowed. |
| 386 - (BOOL)canEditBookmark:(const bookmarks::BookmarkNode*)node; | 380 - (BOOL)canEditBookmark:(const bookmarks::BookmarkNode*)node; |
| 387 | 381 |
| 388 // Checks if bookmark editing is enabled at all. | 382 // Checks if bookmark editing is enabled at all. |
| 389 - (BOOL)canEditBookmarks; | 383 - (BOOL)canEditBookmarks; |
| 390 | 384 |
| 391 // Actions for manipulating bookmarks. | 385 // Actions for manipulating bookmarks. |
| 392 // Open a normal bookmark or folder from a button, ... | 386 // Open a normal bookmark or folder from a button, ... |
| 393 - (IBAction)openBookmark:(id)sender; | 387 - (IBAction)openBookmark:(id)sender; |
| 394 - (IBAction)openBookmarkFolderFromButton:(id)sender; | 388 - (IBAction)openBookmarkFolderFromButton:(id)sender; |
| 395 // From the "off the side" button, ... | 389 // From the "off the side" button, ... |
| 396 - (IBAction)openOffTheSideFolderFromButton:(id)sender; | 390 - (IBAction)openOffTheSideFolderFromButton:(id)sender; |
| 397 // Import bookmarks from another browser. | 391 // Import bookmarks from another browser. |
| 398 - (IBAction)importBookmarks:(id)sender; | 392 - (IBAction)importBookmarks:(id)sender; |
| 399 | |
| 400 // Returns the "off the side" button (aka the chevron button). | |
| 401 - (NSButton*)offTheSideButton; | |
| 402 | |
| 403 // Returns the "off the side" button image. | |
| 404 - (NSImage*)offTheSideButtonImage:(BOOL)forDarkMode; | |
| 405 | |
| 406 @end | 393 @end |
| 407 | 394 |
| 408 // Redirects from BookmarkBarBridge, the C++ object which glues us to | 395 // Redirects from BookmarkBarBridge, the C++ object which glues us to |
| 409 // the rest of Chromium. Internal to BookmarkBarController. | 396 // the rest of Chromium. Internal to BookmarkBarController. |
| 410 @interface BookmarkBarController(BridgeRedirect) | 397 @interface BookmarkBarController(BridgeRedirect) |
| 411 - (void)loaded:(bookmarks::BookmarkModel*)model; | 398 - (void)loaded:(bookmarks::BookmarkModel*)model; |
| 412 - (void)beingDeleted:(bookmarks::BookmarkModel*)model; | 399 - (void)beingDeleted:(bookmarks::BookmarkModel*)model; |
| 413 - (void)nodeAdded:(bookmarks::BookmarkModel*)model | 400 - (void)nodeAdded:(bookmarks::BookmarkModel*)model |
| 414 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index; | 401 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index; |
| 415 - (void)nodeChanged:(bookmarks::BookmarkModel*)model | 402 - (void)nodeChanged:(bookmarks::BookmarkModel*)model |
| (...skipping 11 matching lines...) Expand all Loading... |
| 427 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model | 414 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model |
| 428 node:(const bookmarks::BookmarkNode*)node; | 415 node:(const bookmarks::BookmarkNode*)node; |
| 429 @end | 416 @end |
| 430 | 417 |
| 431 // These APIs should only be used by unit tests (or used internally). | 418 // These APIs should only be used by unit tests (or used internally). |
| 432 @interface BookmarkBarController(InternalOrTestingAPI) | 419 @interface BookmarkBarController(InternalOrTestingAPI) |
| 433 - (void)openBookmarkFolder:(id)sender; | 420 - (void)openBookmarkFolder:(id)sender; |
| 434 - (void)openOrCloseBookmarkFolderForOffTheSideButton; | 421 - (void)openOrCloseBookmarkFolderForOffTheSideButton; |
| 435 - (BookmarkBarView*)buttonView; | 422 - (BookmarkBarView*)buttonView; |
| 436 - (NSMutableArray*)buttons; | 423 - (NSMutableArray*)buttons; |
| 424 - (NSButton*)offTheSideButton; |
| 437 - (NSButton*)appsPageShortcutButton; | 425 - (NSButton*)appsPageShortcutButton; |
| 438 - (BOOL)offTheSideButtonIsHidden; | 426 - (BOOL)offTheSideButtonIsHidden; |
| 439 - (BOOL)appsPageShortcutButtonIsHidden; | 427 - (BOOL)appsPageShortcutButtonIsHidden; |
| 440 - (BookmarkButton*)otherBookmarksButton; | 428 - (BookmarkButton*)otherBookmarksButton; |
| 441 - (BookmarkBarFolderController*)folderController; | 429 - (BookmarkBarFolderController*)folderController; |
| 442 - (id)folderTarget; | 430 - (id)folderTarget; |
| 443 - (int)displayedButtonCount; | 431 - (int)displayedButtonCount; |
| 444 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; | 432 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; |
| 445 - (void)clearBookmarkBar; | 433 - (void)clearBookmarkBar; |
| 446 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node; | 434 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node; |
| 447 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text | 435 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text |
| 448 image:(NSImage*)image; | 436 image:(NSImage*)image; |
| 449 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; | 437 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; |
| 450 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; | 438 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; |
| 451 - (void)frameDidChange; | 439 - (void)frameDidChange; |
| 452 - (int64_t)nodeIdFromMenuTag:(int32_t)tag; | 440 - (int64_t)nodeIdFromMenuTag:(int32_t)tag; |
| 453 - (int32_t)menuTagFromNodeId:(int64_t)menuid; | 441 - (int32_t)menuTagFromNodeId:(int64_t)menuid; |
| 454 - (void)updateTheme:(const ui::ThemeProvider*)themeProvider; | 442 - (void)updateTheme:(const ui::ThemeProvider*)themeProvider; |
| 455 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; | 443 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; |
| 456 - (BOOL)isEventAnExitEvent:(NSEvent*)event; | 444 - (BOOL)isEventAnExitEvent:(NSEvent*)event; |
| 457 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; | 445 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; |
| 458 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node; | 446 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node; |
| 459 | 447 |
| 460 // The following are for testing purposes only and are not used internally. | 448 // The following are for testing purposes only and are not used internally. |
| 461 - (NSMenu *)menuForFolderNode:(const bookmarks::BookmarkNode*)node; | 449 - (NSMenu *)menuForFolderNode:(const bookmarks::BookmarkNode*)node; |
| 462 @end | 450 @end |
| 463 | 451 |
| 464 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 452 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
| OLD | NEW |