diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 03:52:11 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 03:52:11 +0000 |
commit | 1a6b30a619cba771cb9c4ed4da9c3778634567ad (patch) | |
tree | 4ced69ac8eb511a6f9bc7949348551ee62b57989 /chrome/browser/cocoa/bookmark_bar_controller.mm | |
parent | a8815b3277284778247545728bc41a077ff55b43 (diff) | |
download | chromium_src-1a6b30a619cba771cb9c4ed4da9c3778634567ad.zip chromium_src-1a6b30a619cba771cb9c4ed4da9c3778634567ad.tar.gz chromium_src-1a6b30a619cba771cb9c4ed4da9c3778634567ad.tar.bz2 |
This changelist represents the necessary merger of two others:
http://codereview.chromium.org/172082
Create new event_utils.h file for Cocoa-specific event to WindowOpenDisposition
cracking.
Hook this up to BookmarkBarController so that clicks to bookmark items use the
oracle function to determine where the bookmark should be opened.
BUG=17301
TEST=Cmd+Click etc on bookmark items should work. See bug and unit test
attached.
http://codereview.chromium.org/174021
Convert users of the "get last active browser, get selected tab contents, open
url" pattern to just call OpenURL on Browser directly.
Makes GetOrCreateTabbedBrowser public on Browser, and makes it static so it can
be called with a provided profile.
BUG=none
TEST=Try opening links from the bookmark/history menus on mac, with and without
an existing window open, with an active incognito window, etc. The links should
all open in the last active non-incognito window, or create a new non-incognito
window if none is open.
Review URL: http://codereview.chromium.org/173044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 5d25b67..1f64cf4 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -14,14 +14,25 @@ #import "chrome/browser/cocoa/bookmark_editor_controller.h" #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" +#import "chrome/browser/cocoa/event_utils.h" #import "chrome/browser/cocoa/view_resizer.h" #include "chrome/browser/cocoa/nsimage_cache.h" #include "chrome/browser/profile.h" -#import "chrome/common/cocoa_utils.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "skia/ext/skia_utils_mac.h" +// Specialization of NSButton that responds to middle-clicks. By default, +// NSButton ignores them. +@interface BookmarkButton : NSButton +@end + +@implementation BookmarkButton +- (void)otherMouseUp:(NSEvent*) event { + [self performClick:self]; +} +@end + @interface BookmarkBarController(Private) - (void)applyContentAreaOffset:(BOOL)apply immediately:(BOOL)immediately; - (void)showBookmarkBar:(BOOL)enable immediately:(BOOL)immediately; @@ -40,7 +51,8 @@ const int kBookmarkBarHeight = 30; const CGFloat kDefaultBookmarkWidth = 150.0; const CGFloat kBookmarkVerticalPadding = 2.0; const CGFloat kBookmarkHorizontalPadding = 1.0; -}; + +} // namespace @implementation BookmarkBarController @@ -186,9 +198,9 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; - (IBAction)openBookmark:(id)sender { BookmarkNode* node = [self nodeFromButton:sender]; - WindowOpenDisposition disposition = event_utils::DispositionFromEventFlags( - [[NSApp currentEvent] modifierFlags]); - [urlDelegate_ openBookmarkURL:node->GetURL() disposition:disposition]; + [urlDelegate_ openBookmarkURL:node->GetURL() + disposition:event_utils::WindowOpenDispositionFromNSEvent( + [NSApp currentEvent])]; } // Given a NSMenuItem tag, return the appropriate bookmark node id. @@ -501,8 +513,8 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; - (IBAction)openBookmarkMenuItem:(id)sender { int64 tag = [self nodeIdFromMenuTag:[sender tag]]; const BookmarkNode* node = bookmarkModel_->GetNodeByID(tag); - WindowOpenDisposition disposition = event_utils::DispositionFromEventFlags( - [[NSApp currentEvent] modifierFlags]); + WindowOpenDisposition disposition = + event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); [urlDelegate_ openBookmarkURL:node->GetURL() disposition:disposition]; } @@ -523,7 +535,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0; NSCell* cell = [self cellForBookmarkNode:child]; NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&x_offset]; - NSButton* button = [[[NSButton alloc] initWithFrame:frame] + NSButton* button = [[[BookmarkButton alloc] initWithFrame:frame] autorelease]; DCHECK(button); [buttons_ addObject:button]; |