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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/bookmark_menu_cocoa_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "app/gfx/text_elider.h"
6 #include "base/sys_string_conversions.h"
5 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
6 #import "chrome/browser/cocoa/bookmark_menu_bridge.h" 8 #import "chrome/browser/cocoa/bookmark_menu_bridge.h"
7 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" 9 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h"
8 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "webkit/glue/window_open_disposition.h" // CURRENT_TAB 12 #include "webkit/glue/window_open_disposition.h" // CURRENT_TAB
11 13
14 namespace {
15
16 // Menus more than this many pixels wide will get trimmed
17 // TODO(jrg): ask UI dudes what a good value is.
18 const NSUInteger kMaximumMenuPixelsWide = 300;
19
20 }
21
12 @implementation BookmarkMenuCocoaController 22 @implementation BookmarkMenuCocoaController
13 23
24 + (NSString*)menuTitleForNode:(const BookmarkNode*)node {
25 NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default"
26 gfx::Font font = gfx::Font::CreateFont(base::SysNSStringToWide([nsfont
27 fontName]),
28 (int)[nsfont pointSize]);
29 std::wstring title = gfx::ElideText(node->GetTitle(),
30 font,
31 kMaximumMenuPixelsWide);
32 return base::SysWideToNSString(title);
33 }
34
14 - (id)initWithBridge:(BookmarkMenuBridge *)bridge { 35 - (id)initWithBridge:(BookmarkMenuBridge *)bridge {
15 if ((self = [super init])) { 36 if ((self = [super init])) {
16 bridge_ = bridge; 37 bridge_ = bridge;
17 DCHECK(bridge_); 38 DCHECK(bridge_);
18 } 39 }
19 return self; 40 return self;
20 } 41 }
21 42
22 // Return the a BookmarkNode that has the given id (called 43 // Return the a BookmarkNode that has the given id (called
23 // "identifier" here to avoid conflict with objc's concept of "id"). 44 // "identifier" here to avoid conflict with objc's concept of "id").
(...skipping 24 matching lines...) Expand all
48 const BookmarkNode* node = [self nodeForIdentifier:identifier]; 69 const BookmarkNode* node = [self nodeForIdentifier:identifier];
49 DCHECK(node); 70 DCHECK(node);
50 if (!node) 71 if (!node)
51 return; // shouldn't be reached 72 return; // shouldn't be reached
52 73
53 [self openURLForNode:node]; 74 [self openURLForNode:node];
54 } 75 }
55 76
56 @end // BookmarkMenuCocoaController 77 @end // BookmarkMenuCocoaController
57 78
OLDNEW
« 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