OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/bookmark_menu_cocoa_controller.h" | 5 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" |
6 | 6 |
7 #include "app/text_elider.h" | 7 #include "app/text_elider.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/app/chrome_dll_resource.h" // IDC_BOOKMARK_MENU | 9 #include "chrome/app/chrome_dll_resource.h" // IDC_BOOKMARK_MENU |
10 #import "chrome/browser/app_controller_mac.h" | 10 #import "chrome/browser/app_controller_mac.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // Menus more than this many pixels wide will get trimmed | 21 // Menus more than this many pixels wide will get trimmed |
22 // TODO(jrg): ask UI dudes what a good value is. | 22 // TODO(jrg): ask UI dudes what a good value is. |
23 const NSUInteger kMaximumMenuPixelsWide = 300; | 23 const NSUInteger kMaximumMenuPixelsWide = 300; |
24 | 24 |
25 } | 25 } |
26 | 26 |
27 @implementation BookmarkMenuCocoaController | 27 @implementation BookmarkMenuCocoaController |
28 | 28 |
29 + (NSString*)menuTitleForNode:(const BookmarkNode*)node { | 29 + (NSString*)menuTitleForNode:(const BookmarkNode*)node { |
30 NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default" | 30 NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default" |
31 gfx::Font font = gfx::Font::CreateFont(base::SysNSStringToWide([nsfont | 31 gfx::Font font(base::SysNSStringToWide([nsfont fontName]), |
32 fontName]), | 32 static_cast<int>([nsfont pointSize])); |
33 (int)[nsfont pointSize]); | |
34 std::wstring title = gfx::ElideText(node->GetTitle(), | 33 std::wstring title = gfx::ElideText(node->GetTitle(), |
35 font, | 34 font, |
36 kMaximumMenuPixelsWide, | 35 kMaximumMenuPixelsWide, |
37 false); | 36 false); |
38 return base::SysWideToNSString(title); | 37 return base::SysWideToNSString(title); |
39 } | 38 } |
40 | 39 |
41 - (id)initWithBridge:(BookmarkMenuBridge *)bridge { | 40 - (id)initWithBridge:(BookmarkMenuBridge *)bridge { |
42 if ((self = [super init])) { | 41 if ((self = [super init])) { |
43 bridge_ = bridge; | 42 bridge_ = bridge; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const BookmarkNode* node = [self nodeForIdentifier:identifier]; | 87 const BookmarkNode* node = [self nodeForIdentifier:identifier]; |
89 DCHECK(node); | 88 DCHECK(node); |
90 if (!node) | 89 if (!node) |
91 return; // shouldn't be reached | 90 return; // shouldn't be reached |
92 | 91 |
93 [self openURLForNode:node]; | 92 [self openURLForNode:node]; |
94 } | 93 } |
95 | 94 |
96 @end // BookmarkMenuCocoaController | 95 @end // BookmarkMenuCocoaController |
97 | 96 |
OLD | NEW |