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

Unified Diff: chrome/browser/cocoa/bookmark_menu_cocoa_controller.mm

Issue 159286: Added menus for bookmark bar folders. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/bookmark_menu_cocoa_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/browser/cocoa/bookmark_menu_cocoa_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698