Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / ios / cru_context_menu_holder.h
blob9ddc8b4f5f5cec36b4917732b71ce48f92d585ca
1 // Copyright 2012 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 UI_BASE_IOS_CRU_CONTEXT_MENU_HOLDER_H_
6 #define UI_BASE_IOS_CRU_CONTEXT_MENU_HOLDER_H_
8 #import <Foundation/Foundation.h>
10 #include "base/ios/block_types.h"
12 // This class simply stores the information necessary to build a menu:
13 // a menu title, a list of item titles and associated actions (blocks).
14 @interface CRUContextMenuHolder : NSObject
16 // Designated initializer.
17 - (instancetype)init;
19 // Menu title; can be nil.
20 @property(nonatomic, copy) NSString* menuTitle;
22 // A list of menu item titles in the order they will appear in the menu.
23 @property(nonatomic, readonly, copy) NSArray* itemTitles;
25 // A number of menu items.
26 @property(nonatomic, readonly) NSUInteger itemCount;
28 // Adds an item at the end of the menu.
29 - (void)appendItemWithTitle:(NSString*)title action:(ProceduralBlock)action;
31 // Adds an item at the end of the menu. If |dismissImmediately| is YES,
32 // then tapping this item will cause the context menu to be dismissed without
33 // any animation.
34 - (void)appendItemWithTitle:(NSString*)title
35 action:(ProceduralBlock)action
36 dismissImmediately:(BOOL)dismissImmediately;
38 // Performs the action for the item at the given index.
39 - (void)performActionAtIndex:(NSUInteger)index;
41 // Returns YES if the action at |index| should cause the context menu to
42 // dismiss without any animation.
43 - (BOOL)shouldDismissImmediatelyOnClickedAtIndex:(NSUInteger)index;
45 @end
47 #endif // UI_BASE_IOS_CRU_CONTEXT_MENU_HOLDER_H_