1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_WEBMENURUNNER_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_WEBMENURUNNER_MAC_H_
8 #import <Cocoa/Cocoa.h>
12 #include "base/mac/scoped_nsobject.h"
13 #include "content/public/common/menu_item.h"
16 // WebMenuRunner ---------------------------------------------------------------
17 // A class for determining whether an item was selected from an HTML select
18 // control, or if the menu was dismissed without making a selection. If a menu
19 // item is selected, MenuDelegate is informed and sets a flag which can be
20 // queried after the menu has finished running.
22 @interface WebMenuRunner
: NSObject
{
24 // The native menu control.
25 base::scoped_nsobject
<NSMenu
> menu_
;
27 // A flag set to YES if a menu item was chosen, or NO if the menu was
28 // dismissed without selecting an item.
29 BOOL menuItemWasChosen_
;
31 // The index of the selected menu item.
34 // The font size being used for the menu.
37 // Whether the menu should be displayed right-aligned.
41 // Initializes the MenuDelegate with a list of items sent from WebKit.
42 - (id
)initWithItems
:(const std::vector
<content::MenuItem
>&)items
43 fontSize
:(CGFloat
)fontSize
44 rightAligned
:(BOOL
)rightAligned
;
46 // Returns YES if an item was selected from the menu, NO if the menu was
48 - (BOOL
)menuItemWasChosen
;
50 // Displays and runs a native popup menu.
51 - (void)runMenuInView
:(NSView
*)view
52 withBounds
:(NSRect
)bounds
53 initialIndex
:(int)index
;
55 // Hides a popup menu if it's visible.
58 // Returns the index of selected menu item, or its initial value (-1) if no item
60 - (int)indexOfSelectedItem
;
62 @end
// @interface WebMenuRunner
64 #endif // CONTENT_BROWSER_RENDERER_HOST_WEBMENURUNNER_MAC_H_