| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 BookmarkBarFolderController* folderController_; | 226 BookmarkBarFolderController* folderController_; |
| 227 | 227 |
| 228 // The event tap that allows monitoring of all events, to properly close with | 228 // The event tap that allows monitoring of all events, to properly close with |
| 229 // a click outside the bounds of the window. | 229 // a click outside the bounds of the window. |
| 230 id exitEventTap_; | 230 id exitEventTap_; |
| 231 | 231 |
| 232 base::scoped_nsobject<BookmarkBarView> | 232 base::scoped_nsobject<BookmarkBarView> |
| 233 buttonView_; // Contains 'no items' text fields. | 233 buttonView_; // Contains 'no items' text fields. |
| 234 base::scoped_nsobject<BookmarkButton> offTheSideButton_; // aka the chevron. | 234 base::scoped_nsobject<BookmarkButton> offTheSideButton_; // aka the chevron. |
| 235 | 235 |
| 236 NSRect originalNoItemsRect_; // Original, pre-resized field rect. | |
| 237 NSRect originalImportBookmarksRect_; // Original, pre-resized field rect. | |
| 238 | |
| 239 // "Apps" button on the left side. | 236 // "Apps" button on the left side. |
| 240 base::scoped_nsobject<BookmarkButton> appsPageShortcutButton_; | 237 base::scoped_nsobject<BookmarkButton> appsPageShortcutButton_; |
| 241 | 238 |
| 242 // "Managed bookmarks" button on the left side, next to the apps button. | 239 // "Managed bookmarks" button on the left side, next to the apps button. |
| 243 base::scoped_nsobject<BookmarkButton> managedBookmarksButton_; | 240 base::scoped_nsobject<BookmarkButton> managedBookmarksButton_; |
| 244 | 241 |
| 245 // "Supervised bookmarks" button on the left side, next to the apps button. | 242 // "Supervised bookmarks" button on the left side, next to the apps button. |
| 246 base::scoped_nsobject<BookmarkButton> supervisedBookmarksButton_; | 243 base::scoped_nsobject<BookmarkButton> supervisedBookmarksButton_; |
| 247 | 244 |
| 248 // "Other bookmarks" button on the right side. | 245 // "Other bookmarks" button on the right side. |
| 249 base::scoped_nsobject<BookmarkButton> otherBookmarksButton_; | 246 base::scoped_nsobject<BookmarkButton> otherBookmarksButton_; |
| 250 | 247 |
| 251 // When doing a drag, this is folder button "hovered over" which we | 248 // When doing a drag, this is folder button "hovered over" which we |
| 252 // may want to open after a short delay. There are cases where a | 249 // may want to open after a short delay. There are cases where a |
| 253 // mouse-enter can open a folder (e.g. if the menus are "active") | 250 // mouse-enter can open a folder (e.g. if the menus are "active") |
| 254 // but that doesn't use this variable or need a delay so "hover" is | 251 // but that doesn't use this variable or need a delay so "hover" is |
| 255 // the wrong term. | 252 // the wrong term. |
| 256 base::scoped_nsobject<BookmarkButton> hoverButton_; | 253 base::scoped_nsobject<BookmarkButton> hoverButton_; |
| 257 | 254 |
| 258 // We save the view width when we add bookmark buttons. This lets | 255 // We save the view width when we add bookmark buttons. This lets |
| 259 // us avoid a rebuild until we've grown the window bigger than our | 256 // us avoid a rebuild until we've grown the window bigger than our |
| 260 // initial build. | 257 // initial build. |
| 261 CGFloat savedFrameWidth_; | 258 CGFloat savedFrameWidth_; |
| 262 | 259 |
| 263 // The number of buttons we display in the bookmark bar. This does | |
| 264 // not include the "off the side" chevron or the "Other Bookmarks" | |
| 265 // button. We use this number to determine if we need to display | |
| 266 // the chevron, and to know what to place in the chevron's menu. | |
| 267 // Since we create everything before doing layout we can't be sure | |
| 268 // that all bookmark buttons we create will be visible. Thus, | |
| 269 // [buttons_ count] isn't a definitive check. | |
| 270 int displayedButtonCount_; | |
| 271 | |
| 272 // A state flag which tracks when the bar's folder menus should be shown. | 260 // A state flag which tracks when the bar's folder menus should be shown. |
| 273 // An initial click in any of the folder buttons turns this on and | 261 // An initial click in any of the folder buttons turns this on and |
| 274 // one of the following will turn it off: another click in the button, | 262 // one of the following will turn it off: another click in the button, |
| 275 // the window losing focus, a click somewhere other than in the bar | 263 // the window losing focus, a click somewhere other than in the bar |
| 276 // or a folder menu. | 264 // or a folder menu. |
| 277 BOOL showFolderMenus_; | 265 BOOL showFolderMenus_; |
| 278 | 266 |
| 279 // If YES then state changes (for example, from hidden to shown) are animated. | 267 // If YES then state changes (for example, from hidden to shown) are animated. |
| 280 // This is turned off for unit tests. | 268 // This is turned off for unit tests. |
| 281 BOOL stateAnimationsEnabled_; | 269 BOOL stateAnimationsEnabled_; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 395 |
| 408 // Returns the "off the side" button image. | 396 // Returns the "off the side" button image. |
| 409 - (NSImage*)offTheSideButtonImage:(BOOL)forDarkMode; | 397 - (NSImage*)offTheSideButtonImage:(BOOL)forDarkMode; |
| 410 | 398 |
| 411 @end | 399 @end |
| 412 | 400 |
| 413 // Redirects from BookmarkBarBridge, the C++ object which glues us to | 401 // Redirects from BookmarkBarBridge, the C++ object which glues us to |
| 414 // the rest of Chromium. Internal to BookmarkBarController. | 402 // the rest of Chromium. Internal to BookmarkBarController. |
| 415 @interface BookmarkBarController(BridgeRedirect) | 403 @interface BookmarkBarController(BridgeRedirect) |
| 416 - (void)loaded:(bookmarks::BookmarkModel*)model; | 404 - (void)loaded:(bookmarks::BookmarkModel*)model; |
| 417 - (void)beingDeleted:(bookmarks::BookmarkModel*)model; | |
| 418 - (void)nodeAdded:(bookmarks::BookmarkModel*)model | 405 - (void)nodeAdded:(bookmarks::BookmarkModel*)model |
| 419 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index; | 406 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index; |
| 420 - (void)nodeChanged:(bookmarks::BookmarkModel*)model | 407 - (void)nodeChanged:(bookmarks::BookmarkModel*)model |
| 421 node:(const bookmarks::BookmarkNode*)node; | 408 node:(const bookmarks::BookmarkNode*)node; |
| 422 - (void)nodeMoved:(bookmarks::BookmarkModel*)model | 409 - (void)nodeMoved:(bookmarks::BookmarkModel*)model |
| 423 oldParent:(const bookmarks::BookmarkNode*)oldParent | 410 oldParent:(const bookmarks::BookmarkNode*)oldParent |
| 424 oldIndex:(int)oldIndex | 411 oldIndex:(int)oldIndex |
| 425 newParent:(const bookmarks::BookmarkNode*)newParent | 412 newParent:(const bookmarks::BookmarkNode*)newParent |
| 426 newIndex:(int)newIndex; | 413 newIndex:(int)newIndex; |
| 427 - (void)nodeRemoved:(bookmarks::BookmarkModel*)model | 414 - (void)nodeRemoved:(bookmarks::BookmarkModel*)model |
| 428 parent:(const bookmarks::BookmarkNode*)oldParent | 415 parent:(const bookmarks::BookmarkNode*)oldParent |
| 429 index:(int)index; | 416 index:(int)index; |
| 430 - (void)nodeFaviconLoaded:(bookmarks::BookmarkModel*)model | 417 - (void)nodeFaviconLoaded:(bookmarks::BookmarkModel*)model |
| 431 node:(const bookmarks::BookmarkNode*)node; | 418 node:(const bookmarks::BookmarkNode*)node; |
| 432 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model | 419 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model |
| 433 node:(const bookmarks::BookmarkNode*)node; | 420 node:(const bookmarks::BookmarkNode*)node; |
| 434 @end | 421 @end |
| 435 | 422 |
| 436 // These APIs should only be used by unit tests (or used internally). | 423 // These APIs should only be used by unit tests (or used internally). |
| 437 @interface BookmarkBarController(InternalOrTestingAPI) | 424 @interface BookmarkBarController(InternalOrTestingAPI) |
| 438 - (void)openBookmarkFolder:(id)sender; | 425 - (void)openBookmarkFolder:(id)sender; |
| 439 - (void)openOrCloseBookmarkFolderForOffTheSideButton; | 426 - (void)openOrCloseBookmarkFolderForOffTheSideButton; |
| 440 - (BookmarkBarView*)buttonView; | 427 - (BookmarkBarView*)buttonView; |
| 441 - (NSMutableArray*)buttons; | 428 - (NSMutableArray*)buttons; |
| 442 - (BOOL)offTheSideButtonIsHidden; | 429 - (BOOL)offTheSideButtonIsHidden; |
| 443 - (BOOL)appsPageShortcutButtonIsHidden; | 430 - (BOOL)appsPageShortcutButtonIsHidden; |
| 444 - (BookmarkButton*)otherBookmarksButton; | 431 - (BookmarkButton*)otherBookmarksButton; |
| 445 - (BookmarkBarFolderController*)folderController; | 432 - (BookmarkBarFolderController*)folderController; |
| 446 - (id)folderTarget; | 433 - (id)folderTarget; |
| 447 - (int)displayedButtonCount; | |
| 448 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; | 434 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; |
| 449 - (void)clearBookmarkBar; | 435 - (void)clearBookmarkBar; |
| 450 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node; | 436 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node; |
| 451 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text | 437 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text |
| 452 image:(NSImage*)image; | 438 image:(NSImage*)image; |
| 453 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; | 439 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; |
| 454 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; | 440 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; |
| 455 - (void)frameDidChange; | 441 - (void)frameDidChange; |
| 456 - (int64_t)nodeIdFromMenuTag:(int32_t)tag; | 442 - (int64_t)nodeIdFromMenuTag:(int32_t)tag; |
| 457 - (int32_t)menuTagFromNodeId:(int64_t)menuid; | 443 - (int32_t)menuTagFromNodeId:(int64_t)menuid; |
| 458 - (void)updateTheme:(const ui::ThemeProvider*)themeProvider; | 444 - (void)updateTheme:(const ui::ThemeProvider*)themeProvider; |
| 459 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; | 445 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; |
| 460 - (BOOL)isEventAnExitEvent:(NSEvent*)event; | 446 - (BOOL)isEventAnExitEvent:(NSEvent*)event; |
| 461 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; | 447 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; |
| 462 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node; | 448 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node; |
| 463 | 449 |
| 464 @end | 450 @end |
| 465 | 451 |
| 466 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 452 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
| OLD | NEW |