| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
|
| index 69fb3b67c42bdc627a941db605785971d648ee73..a46eb7c1e9546e36cae19a4bdb5ad369ae468d99 100644
|
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
|
| @@ -20,7 +20,6 @@
|
| #import "chrome/browser/ui/cocoa/background_gradient_view.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
|
| -#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h"
|
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
|
| @@ -368,18 +367,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| name:NSViewFrameDidChangeNotification
|
| object:[self view]];
|
|
|
| - // Watch for things going to or from fullscreen.
|
| - [[NSNotificationCenter defaultCenter]
|
| - addObserver:self
|
| - selector:@selector(willEnterOrLeaveFullscreen:)
|
| - name:kWillEnterFullscreenNotification
|
| - object:nil];
|
| - [[NSNotificationCenter defaultCenter]
|
| - addObserver:self
|
| - selector:@selector(willEnterOrLeaveFullscreen:)
|
| - name:kWillLeaveFullscreenNotification
|
| - object:nil];
|
| -
|
| // Don't pass ourself along (as 'self') until our init is completely
|
| // done. Thus, this call is (almost) last.
|
| bridge_.reset(new BookmarkBarBridge(self, bookmarkModel_));
|
| @@ -410,23 +397,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| object:[[self view] window]];
|
| }
|
|
|
| -// When going fullscreen we can run into trouble. Our view is removed
|
| -// from the non-fullscreen window before the non-fullscreen window
|
| -// loses key, so our parentDidResignKey: callback never gets called.
|
| -// In addition, a bookmark folder controller needs to be autoreleased
|
| -// (in case it's in the event chain when closed), but the release
|
| -// implicitly needs to happen while it's connected to the original
|
| -// (non-fullscreen) window to "unlock bar visibility". Such a
|
| -// contract isn't honored when going fullscreen with the menu option
|
| -// (not with the keyboard shortcut). We fake it as best we can here.
|
| -// We have a similar problem leaving fullscreen.
|
| -- (void)willEnterOrLeaveFullscreen:(NSNotification*)notification {
|
| - if (folderController_) {
|
| - [self childFolderWillClose:folderController_];
|
| - [self closeFolderAndStopTrackingMenus];
|
| - }
|
| -}
|
| -
|
| // NSNotificationCenter callback.
|
| - (void)parentWindowWillClose:(NSNotification*)notification {
|
| [self closeFolderAndStopTrackingMenus];
|
| @@ -547,79 +517,9 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
|
|
| #pragma mark Actions
|
|
|
| -// Helper methods called on the main thread by runMenuFlashThread.
|
| -
|
| -- (void)setButtonFlashStateOn:(id)sender {
|
| - [sender highlight:YES];
|
| -}
|
| -
|
| -- (void)setButtonFlashStateOff:(id)sender {
|
| - [sender highlight:NO];
|
| -}
|
| -
|
| --(void)cleanupAfterMenuFlashThread:(id)sender {
|
| - [self closeFolderAndStopTrackingMenus];
|
| -
|
| - // Items retained by doMenuFlashOnSeparateThread below.
|
| - [sender release];
|
| - [self release];
|
| -}
|
| -
|
| -// End runMenuFlashThread helper methods.
|
| -
|
| -// This call is invoked only by doMenuFlashOnSeparateThread below.
|
| -// It makes the selected BookmarkButton (which is masquerading as a menu item)
|
| -// flash a few times to give confirmation feedback, then it closes the menu.
|
| -// It spends all its time sleeping or scheduling UI work on the main thread.
|
| -- (void)runMenuFlashThread:(id)sender {
|
| -
|
| - // Check this is not running on the main thread, as it sleeps.
|
| - DCHECK(![NSThread isMainThread]);
|
| -
|
| - // Duration of flash phases and number of flashes designed to evoke a
|
| - // slightly retro "more mac-like than the Mac" feel.
|
| - // Current Cocoa UI has a barely perceptible flash,probably because Apple
|
| - // doesn't fire the action til after the animation and so there's a hurry.
|
| - // As this code is fully asynchronous, it can take its time.
|
| - const float kBBOnFlashTime = 0.08;
|
| - const float kBBOffFlashTime = 0.08;
|
| - const int kBookmarkButtonMenuFlashes = 3;
|
| -
|
| - for (int count = 0 ; count < kBookmarkButtonMenuFlashes ; count++) {
|
| - [self performSelectorOnMainThread:@selector(setButtonFlashStateOn:)
|
| - withObject:sender
|
| - waitUntilDone:NO];
|
| - [NSThread sleepForTimeInterval:kBBOnFlashTime];
|
| - [self performSelectorOnMainThread:@selector(setButtonFlashStateOff:)
|
| - withObject:sender
|
| - waitUntilDone:NO];
|
| - [NSThread sleepForTimeInterval:kBBOffFlashTime];
|
| - }
|
| - [self performSelectorOnMainThread:@selector(cleanupAfterMenuFlashThread:)
|
| - withObject:sender
|
| - waitUntilDone:NO];
|
| -}
|
| -
|
| -// Non-blocking call which starts the process to make the selected menu item
|
| -// flash a few times to give confirmation feedback, after which it closes the
|
| -// menu. The item is of course actually a BookmarkButton masquerading as a menu
|
| -// item).
|
| -- (void)doMenuFlashOnSeparateThread:(id)sender {
|
| -
|
| - // Ensure that self and sender don't go away before the animation completes.
|
| - // These retains are balanced in cleanupAfterMenuFlashThread above.
|
| - [self retain];
|
| - [sender retain];
|
| - [NSThread detachNewThreadSelector:@selector(runMenuFlashThread:)
|
| - toTarget:self
|
| - withObject:sender];
|
| -}
|
| -
|
| - (IBAction)openBookmark:(id)sender {
|
| BOOL isMenuItem = [[sender cell] isFolderButtonCell];
|
| BOOL animate = isMenuItem && [self animationEnabled];
|
| - if (animate)
|
| - [self doMenuFlashOnSeparateThread:sender];
|
| DCHECK([sender respondsToSelector:@selector(bookmarkNode)]);
|
| const BookmarkNode* node = [sender bookmarkNode];
|
| WindowOpenDisposition disposition =
|
| @@ -861,13 +761,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| // Configure the off-the-side button (e.g. specify the node range,
|
| // check if we should enable or disable it, etc).
|
| - (void)configureOffTheSideButtonContentsAndVisibility {
|
| - // If deleting a button while off-the-side is open, buttons may be
|
| - // promoted from off-the-side to the bar. Accomodate.
|
| - if (folderController_ &&
|
| - ([folderController_ parentButton] == offTheSideButton_)) {
|
| - [folderController_ reconfigureMenu];
|
| - }
|
| -
|
| [[offTheSideButton_ cell] setStartingChildIndex:displayedButtonCount_];
|
| [[offTheSideButton_ cell]
|
| setBookmarkNode:bookmarkModel_->bookmark_bar_node()];
|
| @@ -1821,12 +1714,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| if (![hitView isDescendantOf:[self view]] || hitView == buttonView_)
|
| return YES;
|
| }
|
| - // If a click in a bookmark bar folder window and that isn't
|
| - // one of my bookmark bar folders, YES is click outside.
|
| - if (![eventWindow isKindOfClass:[BookmarkBarFolderWindow
|
| - class]]) {
|
| - return YES;
|
| - }
|
| break;
|
| case NSKeyDown: {
|
| // Event hooks often see the same keydown event twice due to the way key
|
| @@ -1838,8 +1725,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| lastKeyDownEventTime = thisTime;
|
| if ([event modifierFlags] & NSCommandKeyMask)
|
| return YES;
|
| - else if (folderController_)
|
| - return [folderController_ handleInputText:[event characters]];
|
| }
|
| return NO;
|
| }
|
| @@ -2196,9 +2081,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| return;
|
| }
|
| }
|
| -
|
| - if (folderController_)
|
| - [folderController_ faviconLoadedForNode:node];
|
| }
|
|
|
| // TODO(jrg): for now this is brute force.
|
| @@ -2307,16 +2189,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| // If already opened, then we exited but re-entered the button, so do nothing.
|
| if ([folderController_ parentButton] == sender)
|
| return;
|
| - // Else open a new one if it makes sense to do so.
|
| - if ([sender bookmarkNode]->is_folder()) {
|
| - // Update |hoverButton_| so that it corresponds to the open folder.
|
| - hoverButton_.reset([sender retain]);
|
| - [folderTarget_ openBookmarkFolderFromButton:sender];
|
| - } else {
|
| - // We're over a non-folder bookmark so close any old folders.
|
| - [folderController_ close];
|
| - folderController_ = nil;
|
| - }
|
| }
|
|
|
| // BookmarkButtonDelegate protocol implementation.
|
| @@ -2358,7 +2230,7 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| // bookmark folders, not a button context menu.
|
| - (void)closeAllBookmarkFolders {
|
| [self watchForExitEvent:NO];
|
| - [folderController_ close];
|
| + [folderController_ closeMenu];
|
| folderController_ = nil;
|
| }
|
|
|
| @@ -2413,17 +2285,9 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| hoverButton_.reset();
|
| }
|
| hoverButton_.reset([button retain]);
|
| - DCHECK([[hoverButton_ target]
|
| - respondsToSelector:@selector(openBookmarkFolderFromButton:)]);
|
| - [[hoverButton_ target]
|
| - performSelector:@selector(openBookmarkFolderFromButton:)
|
| - withObject:hoverButton_
|
| - afterDelay:bookmarks::kDragHoverOpenDelay
|
| - inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
|
| }
|
| if (!button) {
|
| if (hoverButton_) {
|
| - [NSObject cancelPreviousPerformRequestsWithTarget:[hoverButton_ target]];
|
| [[hoverButton_ target] closeBookmarkFolder:hoverButton_];
|
| hoverButton_.reset();
|
| }
|
| @@ -2528,29 +2392,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| return x;
|
| }
|
|
|
| -- (void)childFolderWillShow:(id<BookmarkButtonControllerProtocol>)child {
|
| - // If the bookmarkbar is not in detached mode, lock bar visibility, forcing
|
| - // the overlay to stay open when in fullscreen mode.
|
| - if (![self isInState:bookmarks::kDetachedState] &&
|
| - ![self isAnimatingToState:bookmarks::kDetachedState]) {
|
| - BrowserWindowController* browserController =
|
| - [BrowserWindowController browserWindowControllerForView:[self view]];
|
| - [browserController lockBarVisibilityForOwner:child
|
| - withAnimation:NO
|
| - delay:NO];
|
| - }
|
| -}
|
| -
|
| -- (void)childFolderWillClose:(id<BookmarkButtonControllerProtocol>)child {
|
| - // Release bar visibility, allowing the overlay to close if in fullscreen
|
| - // mode.
|
| - BrowserWindowController* browserController =
|
| - [BrowserWindowController browserWindowControllerForView:[self view]];
|
| - [browserController releaseBarVisibilityForOwner:child
|
| - withAnimation:NO
|
| - delay:NO];
|
| -}
|
| -
|
| // Add a new folder controller as triggered by the given folder button.
|
| - (void)addNewFolderControllerWithParentButton:(BookmarkButton*)parentButton {
|
|
|
| @@ -2570,9 +2411,10 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| // Folder controller, like many window controllers, owns itself.
|
| folderController_ =
|
| [[BookmarkBarFolderController alloc] initWithParentButton:parentButton
|
| - parentController:nil
|
| + bookmarkModel:bookmarkModel_
|
| barController:self];
|
| - [folderController_ showWindow:self];
|
| + [folderController_ autorelease];
|
| + [folderController_ openMenu];
|
|
|
| // Only BookmarkBarController has this; the
|
| // BookmarkBarFolderController does not.
|
| @@ -2617,7 +2459,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| // A button from somewhere else (not the bar) is being moved to the
|
| // off-the-side so insure it gets redrawn if its showing.
|
| [self reconfigureBookmarkBar];
|
| - [folderController_ reconfigureMenu];
|
| }
|
| }
|
|
|
| @@ -2685,7 +2526,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| // while possibly re-laying out the bookmark bar.
|
| [self removeButton:fromIndex animate:NO];
|
| [self reconfigureBookmarkBar];
|
| - [folderController_ reconfigureMenu];
|
| } else if (toIndex < buttonCount) {
|
| // A button is being added to the bar and removed from off-the-side.
|
| // By now the node has already been inserted into the model so the
|
| @@ -2695,11 +2535,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| DCHECK(movedNode);
|
| [self addButtonForNode:movedNode atIndex:toIndex];
|
| [self reconfigureBookmarkBar];
|
| - } else {
|
| - // A button is being moved within the off-the-side.
|
| - fromIndex -= buttonCount;
|
| - toIndex -= buttonCount;
|
| - [folderController_ moveButtonFromIndex:fromIndex toIndex:toIndex];
|
| }
|
| }
|
| }
|
| @@ -2724,12 +2559,6 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| --displayedButtonCount_;
|
| [self resetAllButtonPositionsWithAnimation:YES];
|
| [self reconfigureBookmarkBar];
|
| - } else if (folderController_ &&
|
| - [folderController_ parentButton] == offTheSideButton_) {
|
| - // The button being removed is in the OTS (off-the-side) and the OTS
|
| - // menu is showing so we need to remove the button.
|
| - NSInteger index = buttonIndex - displayedButtonCount_;
|
| - [folderController_ removeButton:index animate:YES];
|
| }
|
| }
|
|
|
| @@ -2739,7 +2568,7 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) {
|
| // folder menus.
|
| if (bookmarkModel_->bookmark_bar_node() == node)
|
| return self;
|
| - return [folderController_ controllerForNode:node];
|
| + return nil;
|
| }
|
|
|
| #pragma mark BookmarkButtonControllerProtocol
|
|
|