| 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 <map> | 9 #include <map> |
| 10 | 10 |
| 11 #import "base/mac/cocoa_protocols.h" | 11 #import "base/mac/cocoa_protocols.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" | 14 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h" |
| 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_state.h" | 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_state.h" |
| 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" |
| 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 19 #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 19 #include "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" |
| 20 #include "ui/base/window_open_disposition.h" | 20 #include "ui/base/window_open_disposition.h" |
| 21 | 21 |
| 22 @class BookmarkBarController; | 22 @class BookmarkBarController; |
| 23 @class BookmarkBarFolderController; | 23 @class BookmarkBarFolderController; |
| 24 @class BookmarkBarView; | 24 @class BookmarkBarView; |
| 25 @class BookmarkButtonCell; | 25 @class BookmarkButtonCell; |
| 26 @class BookmarkFolderTarget; | 26 @class BookmarkFolderTarget; |
| 27 @class BookmarkContextMenuCocoaController; | 27 @class BookmarkContextMenuCocoaController; |
| 28 class BookmarkNode; | |
| 29 class Browser; | 28 class Browser; |
| 30 class ChromeBookmarkClient; | 29 class ChromeBookmarkClient; |
| 31 class GURL; | 30 class GURL; |
| 32 namespace ui { | 31 namespace ui { |
| 33 class ThemeProvider; | 32 class ThemeProvider; |
| 34 } | 33 } |
| 35 | 34 |
| 36 namespace bookmarks { | 35 namespace bookmarks { |
| 37 | 36 |
| 38 class BookmarkModel; | 37 class BookmarkModel; |
| 38 class BookmarkNode; |
| 39 | 39 |
| 40 // Magic numbers from Cole | 40 // Magic numbers from Cole |
| 41 // TODO(jrg): create an objc-friendly version of bookmark_bar_constants.h? | 41 // TODO(jrg): create an objc-friendly version of bookmark_bar_constants.h? |
| 42 | 42 |
| 43 // Used as a maximum width for buttons on the bar. | 43 // Used as a maximum width for buttons on the bar. |
| 44 const CGFloat kDefaultBookmarkWidth = 150.0; | 44 const CGFloat kDefaultBookmarkWidth = 150.0; |
| 45 | 45 |
| 46 // Horizontal frame inset for buttons in the bookmark bar. | 46 // Horizontal frame inset for buttons in the bookmark bar. |
| 47 const CGFloat kBookmarkHorizontalPadding = 1.0; | 47 const CGFloat kBookmarkHorizontalPadding = 1.0; |
| 48 | 48 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 332 |
| 333 // Updates the sizes and positions of the subviews. | 333 // Updates the sizes and positions of the subviews. |
| 334 // TODO(viettrungluu): I'm not convinced this should be public, but I currently | 334 // TODO(viettrungluu): I'm not convinced this should be public, but I currently |
| 335 // need it for animations. Try not to propagate its use. | 335 // need it for animations. Try not to propagate its use. |
| 336 - (void)layoutSubviews; | 336 - (void)layoutSubviews; |
| 337 | 337 |
| 338 // Called by our view when it is moved to a window. | 338 // Called by our view when it is moved to a window. |
| 339 - (void)viewDidMoveToWindow; | 339 - (void)viewDidMoveToWindow; |
| 340 | 340 |
| 341 // Provide a favicon for a bookmark node. May return nil. | 341 // Provide a favicon for a bookmark node. May return nil. |
| 342 - (NSImage*)faviconForNode:(const BookmarkNode*)node; | 342 - (NSImage*)faviconForNode:(const bookmarks::BookmarkNode*)node; |
| 343 | 343 |
| 344 // Used for situations where the bookmark bar folder menus should no longer | 344 // Used for situations where the bookmark bar folder menus should no longer |
| 345 // be actively popping up. Called when the window loses focus, a click has | 345 // be actively popping up. Called when the window loses focus, a click has |
| 346 // occured outside the menus or a bookmark has been activated. (Note that this | 346 // occured outside the menus or a bookmark has been activated. (Note that this |
| 347 // differs from the behavior of the -[BookmarkButtonControllerProtocol | 347 // differs from the behavior of the -[BookmarkButtonControllerProtocol |
| 348 // closeAllBookmarkFolders] method in that the latter does not terminate menu | 348 // closeAllBookmarkFolders] method in that the latter does not terminate menu |
| 349 // tracking since it may be being called in response to actions (such as | 349 // tracking since it may be being called in response to actions (such as |
| 350 // dragging) where a 'stale' menu presentation should first be collapsed before | 350 // dragging) where a 'stale' menu presentation should first be collapsed before |
| 351 // presenting a new menu.) | 351 // presenting a new menu.) |
| 352 - (void)closeFolderAndStopTrackingMenus; | 352 - (void)closeFolderAndStopTrackingMenus; |
| 353 | 353 |
| 354 // Checks if operations such as edit or delete are allowed. | 354 // Checks if operations such as edit or delete are allowed. |
| 355 - (BOOL)canEditBookmark:(const BookmarkNode*)node; | 355 - (BOOL)canEditBookmark:(const bookmarks::BookmarkNode*)node; |
| 356 | 356 |
| 357 // Checks if bookmark editing is enabled at all. | 357 // Checks if bookmark editing is enabled at all. |
| 358 - (BOOL)canEditBookmarks; | 358 - (BOOL)canEditBookmarks; |
| 359 | 359 |
| 360 // Actions for manipulating bookmarks. | 360 // Actions for manipulating bookmarks. |
| 361 // Open a normal bookmark or folder from a button, ... | 361 // Open a normal bookmark or folder from a button, ... |
| 362 - (IBAction)openBookmark:(id)sender; | 362 - (IBAction)openBookmark:(id)sender; |
| 363 - (IBAction)openBookmarkFolderFromButton:(id)sender; | 363 - (IBAction)openBookmarkFolderFromButton:(id)sender; |
| 364 // From the "off the side" button, ... | 364 // From the "off the side" button, ... |
| 365 - (IBAction)openOffTheSideFolderFromButton:(id)sender; | 365 - (IBAction)openOffTheSideFolderFromButton:(id)sender; |
| 366 // Import bookmarks from another browser. | 366 // Import bookmarks from another browser. |
| 367 - (IBAction)importBookmarks:(id)sender; | 367 - (IBAction)importBookmarks:(id)sender; |
| 368 @end | 368 @end |
| 369 | 369 |
| 370 // Redirects from BookmarkBarBridge, the C++ object which glues us to | 370 // Redirects from BookmarkBarBridge, the C++ object which glues us to |
| 371 // the rest of Chromium. Internal to BookmarkBarController. | 371 // the rest of Chromium. Internal to BookmarkBarController. |
| 372 @interface BookmarkBarController(BridgeRedirect) | 372 @interface BookmarkBarController(BridgeRedirect) |
| 373 - (void)loaded:(bookmarks::BookmarkModel*)model; | 373 - (void)loaded:(bookmarks::BookmarkModel*)model; |
| 374 - (void)beingDeleted:(bookmarks::BookmarkModel*)model; | 374 - (void)beingDeleted:(bookmarks::BookmarkModel*)model; |
| 375 - (void)nodeAdded:(bookmarks::BookmarkModel*)model | 375 - (void)nodeAdded:(bookmarks::BookmarkModel*)model |
| 376 parent:(const BookmarkNode*)oldParent index:(int)index; | 376 parent:(const bookmarks::BookmarkNode*)oldParent index:(int)index; |
| 377 - (void)nodeChanged:(bookmarks::BookmarkModel*)model | 377 - (void)nodeChanged:(bookmarks::BookmarkModel*)model |
| 378 node:(const BookmarkNode*)node; | 378 node:(const bookmarks::BookmarkNode*)node; |
| 379 - (void)nodeMoved:(bookmarks::BookmarkModel*)model | 379 - (void)nodeMoved:(bookmarks::BookmarkModel*)model |
| 380 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex | 380 oldParent:(const bookmarks::BookmarkNode*)oldParent |
| 381 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex; | 381 oldIndex:(int)oldIndex |
| 382 newParent:(const bookmarks::BookmarkNode*)newParent |
| 383 newIndex:(int)newIndex; |
| 382 - (void)nodeRemoved:(bookmarks::BookmarkModel*)model | 384 - (void)nodeRemoved:(bookmarks::BookmarkModel*)model |
| 383 parent:(const BookmarkNode*)oldParent index:(int)index; | 385 parent:(const bookmarks::BookmarkNode*)oldParent |
| 386 index:(int)index; |
| 384 - (void)nodeFaviconLoaded:(bookmarks::BookmarkModel*)model | 387 - (void)nodeFaviconLoaded:(bookmarks::BookmarkModel*)model |
| 385 node:(const BookmarkNode*)node; | 388 node:(const bookmarks::BookmarkNode*)node; |
| 386 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model | 389 - (void)nodeChildrenReordered:(bookmarks::BookmarkModel*)model |
| 387 node:(const BookmarkNode*)node; | 390 node:(const bookmarks::BookmarkNode*)node; |
| 388 @end | 391 @end |
| 389 | 392 |
| 390 // These APIs should only be used by unit tests (or used internally). | 393 // These APIs should only be used by unit tests (or used internally). |
| 391 @interface BookmarkBarController(InternalOrTestingAPI) | 394 @interface BookmarkBarController(InternalOrTestingAPI) |
| 392 - (void)openBookmarkFolder:(id)sender; | 395 - (void)openBookmarkFolder:(id)sender; |
| 393 - (void)openOrCloseBookmarkFolderForOffTheSideButton; | 396 - (void)openOrCloseBookmarkFolderForOffTheSideButton; |
| 394 - (BookmarkBarView*)buttonView; | 397 - (BookmarkBarView*)buttonView; |
| 395 - (NSMutableArray*)buttons; | 398 - (NSMutableArray*)buttons; |
| 396 - (NSButton*)offTheSideButton; | 399 - (NSButton*)offTheSideButton; |
| 397 - (NSButton*)appsPageShortcutButton; | 400 - (NSButton*)appsPageShortcutButton; |
| 398 - (BOOL)offTheSideButtonIsHidden; | 401 - (BOOL)offTheSideButtonIsHidden; |
| 399 - (BOOL)appsPageShortcutButtonIsHidden; | 402 - (BOOL)appsPageShortcutButtonIsHidden; |
| 400 - (BookmarkButton*)otherBookmarksButton; | 403 - (BookmarkButton*)otherBookmarksButton; |
| 401 - (BookmarkBarFolderController*)folderController; | 404 - (BookmarkBarFolderController*)folderController; |
| 402 - (id)folderTarget; | 405 - (id)folderTarget; |
| 403 - (int)displayedButtonCount; | 406 - (int)displayedButtonCount; |
| 404 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; | 407 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; |
| 405 - (void)clearBookmarkBar; | 408 - (void)clearBookmarkBar; |
| 406 - (BookmarkButtonCell*)cellForBookmarkNode:(const BookmarkNode*)node; | 409 - (BookmarkButtonCell*)cellForBookmarkNode:(const bookmarks::BookmarkNode*)node; |
| 407 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text | 410 - (BookmarkButtonCell*)cellForCustomButtonWithText:(NSString*)text |
| 408 image:(NSImage*)image; | 411 image:(NSImage*)image; |
| 409 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; | 412 - (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset; |
| 410 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; | 413 - (void)checkForBookmarkButtonGrowth:(NSButton*)button; |
| 411 - (void)frameDidChange; | 414 - (void)frameDidChange; |
| 412 - (int64)nodeIdFromMenuTag:(int32)tag; | 415 - (int64)nodeIdFromMenuTag:(int32)tag; |
| 413 - (int32)menuTagFromNodeId:(int64)menuid; | 416 - (int32)menuTagFromNodeId:(int64)menuid; |
| 414 - (void)updateTheme:(ui::ThemeProvider*)themeProvider; | 417 - (void)updateTheme:(ui::ThemeProvider*)themeProvider; |
| 415 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; | 418 - (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point; |
| 416 - (BOOL)isEventAnExitEvent:(NSEvent*)event; | 419 - (BOOL)isEventAnExitEvent:(NSEvent*)event; |
| 417 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; | 420 - (BOOL)shrinkOrHideView:(NSView*)view forMaxX:(CGFloat)maxViewX; |
| 418 - (void)unhighlightBookmark:(const BookmarkNode*)node; | 421 - (void)unhighlightBookmark:(const bookmarks::BookmarkNode*)node; |
| 419 | 422 |
| 420 // The following are for testing purposes only and are not used internally. | 423 // The following are for testing purposes only and are not used internally. |
| 421 - (NSMenu *)menuForFolderNode:(const BookmarkNode*)node; | 424 - (NSMenu *)menuForFolderNode:(const bookmarks::BookmarkNode*)node; |
| 422 @end | 425 @end |
| 423 | 426 |
| 424 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ | 427 #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_CONTROLLER_H_ |
| OLD | NEW |