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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 583223002: Open just folder menu on middle clicking chevron button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes addressing comments. Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 // Common function to open a bookmark folder of any type. 709 // Common function to open a bookmark folder of any type.
710 - (void)openBookmarkFolder:(id)sender { 710 - (void)openBookmarkFolder:(id)sender {
711 DCHECK([sender isKindOfClass:[BookmarkButton class]]); 711 DCHECK([sender isKindOfClass:[BookmarkButton class]]);
712 DCHECK([[sender cell] isKindOfClass:[BookmarkButtonCell class]]); 712 DCHECK([[sender cell] isKindOfClass:[BookmarkButtonCell class]]);
713 713
714 // Only record the action if it's the initial folder being opened. 714 // Only record the action if it's the initial folder being opened.
715 if (!showFolderMenus_) 715 if (!showFolderMenus_)
716 RecordBookmarkFolderOpen([self bookmarkLaunchLocation]); 716 RecordBookmarkFolderOpen([self bookmarkLaunchLocation]);
717 showFolderMenus_ = !showFolderMenus_; 717 showFolderMenus_ = !showFolderMenus_;
718 718
719 if (sender == offTheSideButton_) 719 // Middle click on chevron should not open bookmarks under it, instead just
720 // open its folder menu.
721 if (sender == offTheSideButton_) {
720 [[sender cell] setStartingChildIndex:displayedButtonCount_]; 722 [[sender cell] setStartingChildIndex:displayedButtonCount_];
721 723 NSEvent* event = [NSApp currentEvent];
724 if ([event type] == NSOtherMouseUp) {
725 [self openOrCloseBookmarkFolderForOffTheSideButton];
726 return;
727 }
728 }
722 // Toggle presentation of bar folder menus. 729 // Toggle presentation of bar folder menus.
723 [folderTarget_ openBookmarkFolderFromButton:sender]; 730 [folderTarget_ openBookmarkFolderFromButton:sender];
724 } 731 }
725 732
733 - (void)openOrCloseBookmarkFolderForOffTheSideButton {
734 // If clicked on already opened folder, then close it and return.
735 if ([folderController_ parentButton] == offTheSideButton_)
736 [self closeBookmarkFolder:self];
737 else
738 [self addNewFolderControllerWithParentButton:offTheSideButton_];
739 }
740
726 // Click on a bookmark folder button. 741 // Click on a bookmark folder button.
727 - (IBAction)openBookmarkFolderFromButton:(id)sender { 742 - (IBAction)openBookmarkFolderFromButton:(id)sender {
728 [self openBookmarkFolder:sender]; 743 [self openBookmarkFolder:sender];
729 } 744 }
730 745
731 // Click on the "off the side" button (chevron), which opens like a folder 746 // Click on the "off the side" button (chevron), which opens like a folder
732 // button but isn't exactly a parent folder. 747 // button but isn't exactly a parent folder.
733 - (IBAction)openOffTheSideFolderFromButton:(id)sender { 748 - (IBAction)openOffTheSideFolderFromButton:(id)sender {
734 [self openBookmarkFolder:sender]; 749 [self openBookmarkFolder:sender];
735 } 750 }
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
2798 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 2813 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
2799 (const BookmarkNode*)node { 2814 (const BookmarkNode*)node {
2800 // See if it's in the bar, then if it is in the hierarchy of visible 2815 // See if it's in the bar, then if it is in the hierarchy of visible
2801 // folder menus. 2816 // folder menus.
2802 if (bookmarkModel_->bookmark_bar_node() == node) 2817 if (bookmarkModel_->bookmark_bar_node() == node)
2803 return self; 2818 return self;
2804 return [folderController_ controllerForNode:node]; 2819 return [folderController_ controllerForNode:node];
2805 } 2820 }
2806 2821
2807 @end 2822 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698