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. 4 5#ifndef CONTENT_BROWSER_RENDERER_HOST_WEBMENURUNNER_MAC_H_ 6#define CONTENT_BROWSER_RENDERER_HOST_WEBMENURUNNER_MAC_H_ 7 8#import <Cocoa/Cocoa.h> 9 10#include <vector> 11 12#include "base/mac/scoped_nsobject.h" 13#include "content/public/common/menu_item.h" 14 15 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. 21 22@interface WebMenuRunner : NSObject { 23 @private 24 // The native menu control. 25 base::scoped_nsobject<NSMenu> menu_; 26 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_; 30 31 // The index of the selected menu item. 32 int index_; 33 34 // The font size being used for the menu. 35 CGFloat fontSize_; 36 37 // Whether the menu should be displayed right-aligned. 38 BOOL rightAligned_; 39} 40 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; 45 46// Returns YES if an item was selected from the menu, NO if the menu was 47// dismissed. 48- (BOOL)menuItemWasChosen; 49 50// Displays and runs a native popup menu. 51- (void)runMenuInView:(NSView*)view 52 withBounds:(NSRect)bounds 53 initialIndex:(int)index; 54 55// Hides a popup menu if it's visible. 56- (void)hide; 57 58// Returns the index of selected menu item, or its initial value (-1) if no item 59// was selected. 60- (int)indexOfSelectedItem; 61 62@end // @interface WebMenuRunner 63 64#endif // CONTENT_BROWSER_RENDERER_HOST_WEBMENURUNNER_MAC_H_ 65