| 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 55db28700eba0a74ba99b445bc099d227332b8c9..b00e907c297242652b1d613d7685d6f0b2d35094 100644
|
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm
|
| @@ -321,6 +321,33 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| return contextMenuController_.get();
|
| }
|
|
|
| +- (void)loadView {
|
| + // Height is 0 because this is what the superview expects
|
| + [self setView:[[[BookmarkBarToolbarView alloc]
|
| + initWithFrame:NSMakeRect(0, 0, initialWidth_, 0)]
|
| + autorelease]];
|
| + [[self view] setHidden:YES];
|
| + [[self view] setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
|
| + [[self controlledView] setController:self];
|
| + [[self controlledView] setDelegate:self];
|
| +
|
| + buttonView_.reset([[BookmarkBarView alloc]
|
| + initWithController:self
|
| + frame:NSMakeRect(0, -2, 584, 144)]);
|
| + [buttonView_ setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin |
|
| + NSViewMaxXMargin];
|
| + [[buttonView_ importBookmarksButton] setTarget:self];
|
| + [[buttonView_ importBookmarksButton] setAction:@selector(importBookmarks:)];
|
| +
|
| + [self createOffTheSideButton];
|
| + [buttonView_ addSubview:offTheSideButton_];
|
| +
|
| + [self.view addSubview:buttonView_];
|
| + // viewDidLoad became part of the API in 10.10
|
| + if (!base::mac::IsAtLeastOS10_10())
|
| + [self viewDidLoad];
|
| +}
|
| +
|
| - (BookmarkButton*)bookmarkButtonToPulseForNode:(const BookmarkNode*)node {
|
| // Find the closest parent that is visible on the bar.
|
| while (node) {
|
| @@ -380,6 +407,9 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| }
|
|
|
| - (void)dealloc {
|
| + [buttonView_ setController:nil];
|
| + [[self controlledView] setController:nil];
|
| + [[self controlledView] setDelegate:nil];
|
| [self browserWillBeDestroyed];
|
| [super dealloc];
|
| }
|
| @@ -421,36 +451,7 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| browser_ = nullptr;
|
| }
|
|
|
| -- (void)awakeFromNib {
|
| - [self viewDidLoad];
|
| -}
|
| -
|
| - (void)viewDidLoad {
|
| - if (bridge_) {
|
| - // When running on 10.10, expect both -awakeFromNib and -viewDidLoad to be
|
| - // called, but only initialize once.
|
| - DCHECK(base::mac::IsAtLeastOS10_10());
|
| - return;
|
| - }
|
| -
|
| - // We default to NOT open, which means height=0.
|
| - DCHECK([[self view] isHidden]); // Hidden so it's OK to change.
|
| -
|
| - // Set our initial height to zero, since that is what the superview
|
| - // expects. We will resize ourselves open later if needed.
|
| - [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)];
|
| -
|
| - // Complete init of the "off the side" button, as much as we can.
|
| - [offTheSideButton_ setImage:[self offTheSideButtonImage:NO]];
|
| - BookmarkButtonCell* offTheSideCell = [offTheSideButton_ cell];
|
| - [offTheSideCell setTag:kMaterialStandardButtonTypeWithLimitedClickFeedback];
|
| - [offTheSideCell setImagePosition:NSImageOnly];
|
| -
|
| - // The cell is configured in the nib to draw a white highlight when clicked.
|
| - [offTheSideCell setHighlightsBy:NSNoCellMask];
|
| - [offTheSideButton_.draggableButton setDraggable:NO];
|
| - [offTheSideButton_.draggableButton setActsOnMouseDown:YES];
|
| -
|
| // We are enabled by default.
|
| barIsEnabled_ = YES;
|
|
|
| @@ -468,16 +469,6 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| originalImportBookmarksRect_.origin.x += kBookmarksTextfieldOffsetX;
|
| [[buttonView_ importBookmarksButton] setFrame:originalImportBookmarksRect_];
|
|
|
| - // Move the chevron button up 2pts from its position in the xib.
|
| - NSRect chevronButtonFrame = [offTheSideButton_ frame];
|
| - chevronButtonFrame.origin.y -= 2;
|
| - [offTheSideButton_ setFrame:chevronButtonFrame];
|
| -
|
| - // To make life happier when the bookmark bar is floating, the chevron is a
|
| - // child of the button view.
|
| - [offTheSideButton_ removeFromSuperview];
|
| - [buttonView_ addSubview:offTheSideButton_];
|
| -
|
| // When resized we may need to add new buttons, or remove them (if
|
| // no longer visible), or add/remove the "off the side" menu.
|
| [[self view] setPostsFrameChangedNotifications:YES];
|
| @@ -837,7 +828,7 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
|
|
| // Middle click on chevron should not open bookmarks under it, instead just
|
| // open its folder menu.
|
| - if (sender == offTheSideButton_) {
|
| + if (sender == offTheSideButton_.get()) {
|
| [[sender cell] setStartingChildIndex:displayedButtonCount_];
|
| NSEvent* event = [NSApp currentEvent];
|
| if ([event type] == NSOtherMouseUp) {
|
| @@ -858,17 +849,17 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| }
|
|
|
| // Click on a bookmark folder button.
|
| -- (IBAction)openBookmarkFolderFromButton:(id)sender {
|
| +- (void)openBookmarkFolderFromButton:(id)sender {
|
| [self openBookmarkFolder:sender];
|
| }
|
|
|
| // Click on the "off the side" button (chevron), which opens like a folder
|
| // button but isn't exactly a parent folder.
|
| -- (IBAction)openOffTheSideFolderFromButton:(id)sender {
|
| +- (void)openOffTheSideFolderFromButton:(id)sender {
|
| [self openBookmarkFolder:sender];
|
| }
|
|
|
| -- (IBAction)importBookmarks:(id)sender {
|
| +- (void)importBookmarks:(id)sender {
|
| chrome::ShowImportDialog(browser_);
|
| }
|
|
|
| @@ -1423,6 +1414,27 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| [self setAppsPageShortcutButtonVisibility];
|
| }
|
|
|
| +- (void)createOffTheSideButton {
|
| + offTheSideButton_.reset(
|
| + [[BookmarkButton alloc] initWithFrame:NSMakeRect(586, 0, 20, 24)]);
|
| + id offTheSideCell = [BookmarkButtonCell offTheSideButtonCell];
|
| + [offTheSideCell setTag:kMaterialStandardButtonTypeWithLimitedClickFeedback];
|
| + [offTheSideCell setImagePosition:NSImageOnly];
|
| +
|
| + [offTheSideCell setHighlightsBy:NSNoCellMask];
|
| + [offTheSideCell setShowsBorderOnlyWhileMouseInside:YES];
|
| + [offTheSideCell setBezelStyle:NSShadowlessSquareBezelStyle];
|
| + [offTheSideButton_ setCell:offTheSideCell];
|
| + [offTheSideButton_ setImage:[self offTheSideButtonImage:NO]];
|
| + [offTheSideButton_ setButtonType:NSMomentaryLightButton];
|
| +
|
| + [offTheSideButton_ setTarget:self];
|
| + [offTheSideButton_ setAction:@selector(openOffTheSideFolderFromButton:)];
|
| + [offTheSideButton_ setDelegate:self];
|
| + [[offTheSideButton_ draggableButton] setDraggable:NO];
|
| + [[offTheSideButton_ draggableButton] setActsOnMouseDown:YES];
|
| +}
|
| +
|
| - (void)openAppsPage:(id)sender {
|
| WindowOpenDisposition disposition =
|
| ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]);
|
| @@ -1954,7 +1966,8 @@ void RecordAppLaunch(Profile* profile, GURL url) {
|
| [[eventWindow contentView] hitTest:[event locationInWindow]];
|
| if (hitView == [folderController_ parentButton])
|
| return NO;
|
| - if (![hitView isDescendantOf:[self view]] || hitView == buttonView_)
|
| + if (![hitView isDescendantOf:[self view]] ||
|
| + hitView == buttonView_.get())
|
| return YES;
|
| }
|
| // If a click in a bookmark bar folder window and that isn't
|
|
|