OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/webmenurunner_mac.h" | 5 #include "webkit/glue/webmenurunner_mac.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 | 8 |
9 #if !defined(MAC_OS_X_VERSION_10_6) || \ | 9 #if !defined(MAC_OS_X_VERSION_10_6) || \ |
10 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | 10 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 - (void)addItem:(const WebMenuItem&)item { | 59 - (void)addItem:(const WebMenuItem&)item { |
60 if (item.type == WebMenuItem::SEPARATOR) { | 60 if (item.type == WebMenuItem::SEPARATOR) { |
61 [menu_ addItem:[NSMenuItem separatorItem]]; | 61 [menu_ addItem:[NSMenuItem separatorItem]]; |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 NSString* title = base::SysUTF16ToNSString(item.label); | 65 NSString* title = base::SysUTF16ToNSString(item.label); |
66 NSMenuItem* menuItem = [menu_ addItemWithTitle:title | 66 NSMenuItem* menuItem = [menu_ addItemWithTitle:title |
67 action:@selector(menuItemSelected:) | 67 action:@selector(menuItemSelected:) |
68 keyEquivalent:@""]; | 68 keyEquivalent:@""]; |
| 69 if (!item.toolTip.empty()) { |
| 70 NSString* toolTip = base::SysUTF16ToNSString(item.toolTip); |
| 71 [menuItem setToolTip:toolTip]; |
| 72 } |
69 [menuItem setEnabled:(item.enabled && item.type != WebMenuItem::GROUP)]; | 73 [menuItem setEnabled:(item.enabled && item.type != WebMenuItem::GROUP)]; |
70 [menuItem setTarget:self]; | 74 [menuItem setTarget:self]; |
71 | 75 |
72 // Set various alignment/language attributes. Note that many (if not most) of | 76 // Set various alignment/language attributes. Note that many (if not most) of |
73 // these attributes are functional only on 10.6 and above. | 77 // these attributes are functional only on 10.6 and above. |
74 scoped_nsobject<NSMutableDictionary> attrs( | 78 scoped_nsobject<NSMutableDictionary> attrs( |
75 [[NSMutableDictionary alloc] initWithCapacity:3]); | 79 [[NSMutableDictionary alloc] initWithCapacity:3]); |
76 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | 80 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( |
77 [[NSMutableParagraphStyle alloc] init]); | 81 [[NSMutableParagraphStyle alloc] init]); |
78 [paragraphStyle setAlignment:rightAligned_ ? NSRightTextAlignment | 82 [paragraphStyle setAlignment:rightAligned_ ? NSRightTextAlignment |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 characters:@"" | 210 characters:@"" |
207 charactersIgnoringModifiers:escape_str | 211 charactersIgnoringModifiers:escape_str |
208 isARepeat:NO | 212 isARepeat:NO |
209 keyCode:0x1B]; | 213 keyCode:0x1B]; |
210 } | 214 } |
211 | 215 |
212 return event; | 216 return event; |
213 } | 217 } |
214 | 218 |
215 } // namespace webkit_glue | 219 } // namespace webkit_glue |
OLD | NEW |