OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef IOS_CLEAN_CHROME_BROWSER_UI_CONTEXT_MENU_CONTEXT_MENU_CONSUMER_H_ | 5 #ifndef IOS_CLEAN_CHROME_BROWSER_UI_CONTEXT_MENU_CONTEXT_MENU_CONSUMER_H_ |
6 #define IOS_CLEAN_CHROME_BROWSER_UI_CONTEXT_MENU_CONTEXT_MENU_CONSUMER_H_ | 6 #define IOS_CLEAN_CHROME_BROWSER_UI_CONTEXT_MENU_CONTEXT_MENU_CONSUMER_H_ |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_item.h" |
9 | 9 |
10 // Object encapsulating configuration information for an item in a context menu. | 10 @class ContextMenuContext; |
11 @interface ContextMenuItem : NSObject | |
12 | |
13 // Create a new item with |title| and |command|. | |
14 + (instancetype)itemWithTitle:(NSString*)title command:(NSInvocation*)command; | |
15 | |
16 // The title associated with the item. This is usually the text the user will | |
17 // see. | |
18 @property(nonatomic, readonly) NSString* title; | |
19 | |
20 // The selector and parameters that will be called when the item is | |
21 // selected. | |
22 @property(nonatomic, readonly) NSInvocation* command; | |
23 | |
24 @end | |
25 | 11 |
26 // A ContextMenuConsumer (typically a view controller) uses data provided by | 12 // A ContextMenuConsumer (typically a view controller) uses data provided by |
27 // this protocol to display an run a context menu. | 13 // this protocol to display an run a context menu. |
28 @protocol ContextMenuConsumer | 14 @protocol ContextMenuConsumer |
29 | 15 |
| 16 // Sets the context that should be sent with the ContextMenuCommands dispatched |
| 17 // by ContextMenuItems added to this consumer. |
| 18 - (void)setContextMenuContext:(ContextMenuContext*)context; |
| 19 |
30 // Informs the consumer that the overall title of the context menu will be | 20 // Informs the consumer that the overall title of the context menu will be |
31 // |title|. This method should be called only once in the lifetime of the | 21 // |title|. This method should be called only once in the lifetime of the |
32 // consumer. | 22 // consumer. |
33 - (void)setContextMenuTitle:(NSString*)title; | 23 - (void)setContextMenuTitle:(NSString*)title; |
34 | 24 |
35 // Informs the consumer that the context menu should display the items defined | 25 // Informs the consumer that the context menu should display the items defined |
36 // in |items|. This method should be called only once in the lifetime of the | 26 // in |items|. |cancelItem| will be added as the last option in the menu. This |
37 // consumer. | 27 // method should be called only once in the lifetime of the consumer. |
38 - (void)setContextMenuItems:(NSArray<ContextMenuItem*>*)items; | 28 - (void)setContextMenuItems:(NSArray<ContextMenuItem*>*)items |
| 29 cancelItem:(ContextMenuItem*)cancelItem; |
39 | 30 |
40 @end | 31 @end |
41 | 32 |
42 #endif // IOS_CLEAN_CHROME_BROWSER_UI_CONTEXT_MENU_CONTEXT_MENU_CONSUMER_H_ | 33 #endif // IOS_CLEAN_CHROME_BROWSER_UI_CONTEXT_MENU_CONTEXT_MENU_CONSUMER_H_ |
OLD | NEW |