| OLD | NEW |
| 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 "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 @interface WebMenuRunner (PrivateAPI) | 9 @interface WebMenuRunner (PrivateAPI) |
| 10 | 10 |
| 11 // Worker function used during initialization. | 11 // Worker function used during initialization. |
| 12 - (void)addItem:(const WebMenuItem&)item; | 12 - (void)addItem:(const WebMenuItem&)item; |
| 13 | 13 |
| 14 // A callback for the menu controller object to call when an item is selected | 14 // A callback for the menu controller object to call when an item is selected |
| 15 // from the menu. This is not called if the menu is dismissed without a | 15 // from the menu. This is not called if the menu is dismissed without a |
| 16 // selection. | 16 // selection. |
| 17 - (void)menuItemSelected:(id)sender; | 17 - (void)menuItemSelected:(id)sender; |
| 18 | 18 |
| 19 @end // WebMenuRunner (PrivateAPI) | 19 @end // WebMenuRunner (PrivateAPI) |
| 20 | 20 |
| 21 @implementation WebMenuRunner | 21 @implementation WebMenuRunner |
| 22 | 22 |
| 23 - (id)initWithItems:(const std::vector<WebMenuItem>&)items { | 23 - (id)initWithItems:(const std::vector<WebMenuItem>&)items { |
| 24 if ((self = [super init])) { | 24 if ((self = [super init])) { |
| 25 menu_.reset([[NSMenu alloc] initWithTitle:@""]); | 25 menu_.reset([[NSMenu alloc] initWithTitle:@""]); |
| 26 [menu_ setAutoenablesItems:NO]; | 26 [menu_ setAutoenablesItems:NO]; |
| 27 index_ = -1; | 27 index_ = -1; |
| 28 for (int i = 0; i < static_cast<int>(items.size()); ++i) | 28 for (size_t i = 0; i < items.size(); ++i) |
| 29 [self addItem:items[i]]; | 29 [self addItem:items[i]]; |
| 30 } | 30 } |
| 31 return self; | 31 return self; |
| 32 } | 32 } |
| 33 | 33 |
| 34 - (void)addItem:(const WebMenuItem&)item { | 34 - (void)addItem:(const WebMenuItem&)item { |
| 35 if (item.type == WebMenuItem::SEPARATOR) { | 35 if (item.type == WebMenuItem::SEPARATOR) { |
| 36 [menu_ addItem:[NSMenuItem separatorItem]]; | 36 [menu_ addItem:[NSMenuItem separatorItem]]; |
| 37 return; | 37 return; |
| 38 } | 38 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 characters:@"" | 132 characters:@"" |
| 133 charactersIgnoringModifiers:escape_str | 133 charactersIgnoringModifiers:escape_str |
| 134 isARepeat:NO | 134 isARepeat:NO |
| 135 keyCode:0x1B]; | 135 keyCode:0x1B]; |
| 136 } | 136 } |
| 137 | 137 |
| 138 return event; | 138 return event; |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace webkit_glue | 141 } // namespace webkit_glue |
| OLD | NEW |