| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_COCOA_MENU_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_COCOA_MENU_CONTROLLER_H_ |
| 7 |
| 8 #import <Cocoa/Cocoa.h> |
| 9 |
| 10 #include "base/scoped_nsobject.h" |
| 11 #include "base/scoped_ptr.h" |
| 12 |
| 13 namespace menus { |
| 14 class MenuModel; |
| 15 } |
| 16 |
| 17 // A controller for the cross-platform menu model. The menu that's created |
| 18 // has the tag and represented object set for each menu item. The object is a |
| 19 // NSValue holding a pointer to the model for that level of the menu (to |
| 20 // allow for hierarchical menus). The tag is the index into that model for |
| 21 // that particular item. It is important that the model outlives this object |
| 22 // as it only maintains weak references. |
| 23 // TODO(pinkerton): Handle changes to the model. SimpleMenuModel doesn't yet |
| 24 // notify when changes are made. |
| 25 @interface MenuController : NSObject { |
| 26 @private |
| 27 scoped_nsobject<NSMenu> menu_; |
| 28 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank |
| 29 } |
| 30 |
| 31 // Builds a NSMenu from the pre-built model (must not be nil). Changes made |
| 32 // to the contents of the model after calling this will not be noticed. If |
| 33 // the menu will be displayed by a NSPopUpButtonCell, it needs to be of a |
| 34 // slightly different form (0th item is empty). Note this attribute of the menu |
| 35 // cannot be changed after it has been created. |
| 36 - (id)initWithModel:(menus::MenuModel*)model |
| 37 useWithPopUpButtonCell:(BOOL)useWithCell; |
| 38 |
| 39 // Access to the constructed menu. |
| 40 - (NSMenu*)menu; |
| 41 |
| 42 @end |
| 43 |
| 44 // Exposed only for unit testing, do not call directly. |
| 45 @interface MenuController(PrivateExposedForTesting) |
| 46 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item; |
| 47 @end |
| 48 |
| 49 #endif // CHROME_BROWSER_COCOA_MENU_CONTROLLER_H_ |
| OLD | NEW |