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

Unified Diff: chrome/browser/cocoa/bookmark_menu_bridge.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
Index: chrome/browser/cocoa/bookmark_menu_bridge.mm
===================================================================
--- chrome/browser/cocoa/bookmark_menu_bridge.mm (revision 21290)
+++ chrome/browser/cocoa/bookmark_menu_bridge.mm (working copy)
@@ -169,31 +169,10 @@
}
}
-namespace {
-
-// Menus more than this many chars long will get trimmed
-const NSUInteger kMaximumMenuWidthInChars = 65;
-
-// When trimming, use this many chars from each side
-const NSUInteger kMenuTrimSizeInChars = 30;
-
-}
-
void BookmarkMenuBridge::AddNodeToMenu(const BookmarkNode* node, NSMenu* menu) {
for (int i = 0; i < node->GetChildCount(); i++) {
const BookmarkNode* child = node->GetChild(i);
- NSString* full_title = base::SysWideToNSString(child->GetTitle());
- NSString* title = full_title;
- if ([title length] > kMaximumMenuWidthInChars) {
- // TODO(jrg): add a better heuristic? I'd really like to trim this
- // by pixels, not by chars (font is not fixed width).
- // For Safari, it appears that menu names >60 chars get split up to
- // 30char + "..." + 30char.
- title = [NSString stringWithFormat:@"%@…%@",
- [title substringToIndex:kMenuTrimSizeInChars],
- [title substringFromIndex:([title length] -
- kMenuTrimSizeInChars)]];
- }
+ NSString* title = [BookmarkMenuCocoaController menuTitleForNode:child];
NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title
action:nil
keyEquivalent:@""] autorelease];
@@ -208,7 +187,8 @@
[item setTag:child->id()];
// Add a tooltip
std::string url_string = child->GetURL().possibly_invalid_spec();
- NSString* tooltip = [NSString stringWithFormat:@"%@\n%s", full_title,
+ NSString* tooltip = [NSString stringWithFormat:@"%@\n%s",
+ base::SysWideToNSString(child->GetTitle()),
url_string.c_str()];
[item setToolTip:tooltip];
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_view_unittest.mm ('k') | chrome/browser/cocoa/bookmark_menu_cocoa_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698