| Index: chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm
|
| ===================================================================
|
| --- chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm (revision 21290)
|
| +++ chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm (working copy)
|
| @@ -2,6 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "app/gfx/text_elider.h"
|
| +#include "base/sys_string_conversions.h"
|
| #include "chrome/browser/browser.h"
|
| #import "chrome/browser/cocoa/bookmark_menu_bridge.h"
|
| #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h"
|
| @@ -9,8 +11,27 @@
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| #include "webkit/glue/window_open_disposition.h" // CURRENT_TAB
|
|
|
| +namespace {
|
| +
|
| +// Menus more than this many pixels wide will get trimmed
|
| +// TODO(jrg): ask UI dudes what a good value is.
|
| +const NSUInteger kMaximumMenuPixelsWide = 300;
|
| +
|
| +}
|
| +
|
| @implementation BookmarkMenuCocoaController
|
|
|
| ++ (NSString*)menuTitleForNode:(const BookmarkNode*)node {
|
| + NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default"
|
| + gfx::Font font = gfx::Font::CreateFont(base::SysNSStringToWide([nsfont
|
| + fontName]),
|
| + (int)[nsfont pointSize]);
|
| + std::wstring title = gfx::ElideText(node->GetTitle(),
|
| + font,
|
| + kMaximumMenuPixelsWide);
|
| + return base::SysWideToNSString(title);
|
| +}
|
| +
|
| - (id)initWithBridge:(BookmarkMenuBridge *)bridge {
|
| if ((self = [super init])) {
|
| bridge_ = bridge;
|
|
|