Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h

Issue 7465090: [Mac] Replace the custom bookmark menus with native NSMenus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h
index fae30ab75cc73356b7f090cbb7445af5c86c39c7..a5b2b425709bf65817b4b877730943962cd11c25 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h
@@ -9,224 +9,50 @@
#import <Cocoa/Cocoa.h>
#include "base/memory/scoped_nsobject.h"
-#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
-#import "chrome/browser/ui/cocoa/tracking_area.h"
+#include "base/memory/scoped_ptr.h"
+#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
@class BookmarkBarController;
-@class BookmarkBarFolderView;
-@class BookmarkFolderTarget;
-@class BookmarkBarFolderHoverState;
-@class BookmarkBarFolderWindow;
-@class BookmarkBarFolderWindowContentView;
+@class BookmarkButton;
+class BookmarkMenuBridge;
+class BookmarkModel;
// A controller for the pop-up windows from bookmark folder buttons
// which look sort of like menus.
mrossetti 2011/08/04 02:16:27 Nit: They probably look just like menus now, right
Robert Sesek 2011/08/04 15:37:02 Done.
-@interface BookmarkBarFolderController :
- NSWindowController<BookmarkButtonDelegate,
- BookmarkButtonControllerProtocol,
- NSUserInterfaceValidations> {
+@interface BookmarkBarFolderController : NSObject<BookmarkMenuDelegate> {
@private
// The button whose click opened us.
scoped_nsobject<BookmarkButton> parentButton_;
- // Bookmark bar folder controller chains are torn down in two ways:
- // 1. Clicking "outside" the folder (see use of
- // CrApplicationEventHookProtocol in the bookmark bar controller).
- // 2. Engaging a different folder (via hover over or explicit click).
- //
- // In either case, the BookmarkButtonControllerProtocol method
- // closeAllBookmarkFolders gets called. For bookmark bar folder
- // controllers, this is passed up the chain so we begin with a top
- // level "close".
- // When any bookmark folder window closes, it necessarily tells
- // subcontroller windows to close (down the chain), and autoreleases
- // the controller. (Must autorelease since the controller can still
- // get delegate events such as windowDidClose).
- //
- // Bookmark bar folder controllers own their buttons. When doing
- // drag and drop of a button from one sub-sub-folder to a different
- // sub-sub-folder, we need to make sure the button's pointers stay
- // valid until we've dropped (or cancelled). Note that such a drag
- // causes the source sub-sub-folder (previous parent window) to go
- // away (windows close, controllers autoreleased) since you're
- // hovering over a different folder chain for dropping. To keep
- // things valid (like the button's target, its delegate, the parent
- // cotroller that we have a pointer to below [below], etc), we heep
- // strong pointers to our owning controller, so the entire chain
- // stays owned.
+ // The bookmark bar controller. Weak.
+ BookmarkBarController* barController_;
- // Our parent controller, if we are a nested folder, otherwise nil.
- // Strong to insure the object lives as long as we need it.
- scoped_nsobject<BookmarkBarFolderController> parentController_;
+ // The root menu for this node.
+ scoped_nsobject<NSMenu> menu_;
- // The main bar controller from whence we or a parent sprang.
- BookmarkBarController* barController_; // WEAK: It owns us.
-
- // Our buttons. We do not have buttons for nested folders.
- scoped_nsobject<NSMutableArray> buttons_;
-
- // The scroll view that contains our main button view (below).
- IBOutlet NSScrollView* scrollView_;
-
- // The view defining the visible area in which we draw our content.
- IBOutlet BookmarkBarFolderWindowContentView* visibleView_;
-
- // The main view of this window (where the buttons go) within the scroller.
- IBOutlet BookmarkBarFolderView* folderView_;
-
- // A window used to show the shadow behind the main window when it is
- // scrollable. (A 'shadow' window is needed because the main window, when
- // scrollable in either or both directions, will reach completely to the
- // top and/or bottom edge of the screen in order to support mouse tracking
- // during scrolling operations. In that case, though, the 'visible'
- // window must be inset a bit from the edge of the screen for aesthetics;
- // it will also be inset much more from the bottom of the screen when the
- // Dock is showing. When scrollable, the main window would show a shadow
- // incorrectly positioned, hence the 'shadow' window.)
- IBOutlet BookmarkBarFolderWindow* shadowWindow_;
-
- // The up and down scroll arrow views. These arrows are hidden and shown
- // as necessary (when scrolling is possible) and are contained in the nib
- // as siblings to the scroll view.
- IBOutlet NSView* scrollDownArrowView_; // Positioned at the top.
- IBOutlet NSView* scrollUpArrowView_; // Positioned at the bottom.
-
- // YES if subfolders should grow to the right (the default).
- // Direction switches if we'd grow off the screen.
- BOOL subFolderGrowthToRight_;
-
- // Weak; we keep track to work around a
- // setShowsBorderOnlyWhileMouseInside bug.
- BookmarkButton* buttonThatMouseIsIn_;
-
- // The context menu for a bookmark button which represents an URL.
- IBOutlet NSMenu* buttonMenu_;
-
- // The context menu for a bookmark button which represents a folder.
- IBOutlet NSMenu* folderMenu_;
-
- // We model hover state as a state machine with specific allowable
- // transitions. |hoverState_| is the state of this machine at any
- // given time.
- scoped_nsobject<BookmarkBarFolderHoverState> hoverState_;
-
- // Logic for dealing with a click on a bookmark folder button.
- scoped_nsobject<BookmarkFolderTarget> folderTarget_;
-
- // A controller for a pop-up bookmark folder window (custom menu).
- // We (self) are the parentController_ for our folderController_.
- // This is not a scoped_nsobject because it owns itself (when its
- // window closes the controller gets autoreleased).
- BookmarkBarFolderController* folderController_;
-
- // Implement basic menu scrolling through this tracking area.
- ScopedCrTrackingArea scrollTrackingArea_;
-
- // Timer to continue scrolling as needed. We own the timer but
- // don't release it when done (we invalidate it).
- NSTimer* scrollTimer_;
-
- // Precalculated sum of left and right edge padding of buttons in a
- // folder menu window. This is calculated from the widths of the main
- // folder menu window and the scroll view within.
- CGFloat padding_;
-
- // Amount to scroll by on each timer fire. Can be + or -.
- CGFloat verticalScrollDelta_;
-
- // We need to know the size of the vertical scrolling arrows so we
- // can obscure/unobscure them.
- CGFloat verticalScrollArrowHeight_;
-
- // Set to YES to prevent any node animations. Useful for unit testing so that
- // incomplete animations do not cause valgrind complaints.
- BOOL ignoreAnimations_;
-
- int selectedIndex_;
- NSString* typedPrefix_;
+ // The class that builds the menu.
+ scoped_ptr<BookmarkMenuBridge> menuBridge_;
}
// Designated initializer.
- (id)initWithParentButton:(BookmarkButton*)button
- parentController:(BookmarkBarFolderController*)parentController
+ bookmarkModel:(BookmarkModel*)model
barController:(BookmarkBarController*)barController;
// Return the parent button that owns the bookmark folder we represent.
- (BookmarkButton*)parentButton;
-// Text typed by user, for type-select and arrow key support.
-// Returns YES if the menu should be closed now.
-- (BOOL)handleInputText:(NSString*)newText;
-
-// If you wanted to clear the type-select buffer. Currently only used
-// internally.
-- (void)clearInputText;
-
-// Gets notified when a fav icon asynchronously loads, so we can now use the
-// real icon instead of a generic placeholder.
-- (void)faviconLoadedForNode:(const BookmarkNode*)node;
-
-- (void)setSelectedButtonByIndex:(int)index;
-
-// Offset our folder menu window. This is usually needed in response to a
-// parent folder menu window or the bookmark bar changing position due to
-// the dragging of a bookmark node from the parent into this folder menu.
-- (void)offsetFolderMenuWindow:(NSSize)offset;
+// Opens the menu. This will retain itself before it runs the menu and will
+// release itself when the menu closes.
+- (void)openMenu;
-// Re-layout the window menu in case some buttons were added or removed,
-// specifically as a result of the bookmark bar changing configuration
-// and altering the contents of the off-the-side folder.
-- (void)reconfigureMenu;
-
-// Actions from a context menu over a button or folder.
-- (IBAction)cutBookmark:(id)sender;
-- (IBAction)copyBookmark:(id)sender;
-- (IBAction)pasteBookmark:(id)sender;
-- (IBAction)deleteBookmark:(id)sender;
-
-// Passed up by a child view to tell us of a desire to scroll.
-- (void)scrollWheel:(NSEvent *)theEvent;
-
-- (void)mouseDragged:(NSEvent*)theEvent;
-
-
-// Forwarded to the associated BookmarkBarController.
-- (IBAction)addFolder:(id)sender;
-- (IBAction)addPage:(id)sender;
-- (IBAction)editBookmark:(id)sender;
-- (IBAction)openBookmark:(id)sender;
-- (IBAction)openAllBookmarks:(id)sender;
-- (IBAction)openAllBookmarksIncognitoWindow:(id)sender;
-- (IBAction)openAllBookmarksNewWindow:(id)sender;
-- (IBAction)openBookmarkInIncognitoWindow:(id)sender;
-- (IBAction)openBookmarkInNewForegroundTab:(id)sender;
-- (IBAction)openBookmarkInNewWindow:(id)sender;
-
-@property(assign, nonatomic) BOOL subFolderGrowthToRight;
+// Closes the menu.
+- (void)closeMenu;
@end
-@interface BookmarkBarFolderController(TestingAPI)
-- (NSPoint)windowTopLeftForWidth:(int)windowWidth
- height:(int)windowHeight;
-- (NSArray*)buttons;
-- (BookmarkBarFolderController*)folderController;
-- (id)folderTarget;
-- (void)configureWindowLevel;
-- (void)performOneScroll:(CGFloat)delta;
-- (BookmarkButton*)buttonThatMouseIsIn;
-// Set to YES in order to prevent animations.
-- (void)setIgnoreAnimations:(BOOL)ignore;
-
-// Return YES if the scroll-up or scroll-down arrows are showing.
-- (BOOL)canScrollUp;
-- (BOOL)canScrollDown;
-- (CGFloat)verticalScrollArrowHeight;
-- (NSView*)visibleView;
-- (NSScrollView*)scrollView;
-- (NSView*)folderView;
-
-- (BookmarkButton*)buttonForDroppingOnAtPoint:(NSPoint)point;
+@interface BookmarkBarFolderController (ExposedForTesting)
+- (BookmarkMenuBridge*)menuBridge;
@end
#endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698