OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ |
6 #define IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ | 6 #define IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ |
7 | 7 |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
| 10 @protocol BrowserCommands; |
10 @class ToolsMenuConfiguration; | 11 @class ToolsMenuConfiguration; |
11 | 12 |
12 // TODO(crbug.com/228521): Remove this once the new command/metric handling is | 13 // TODO(crbug.com/228521): Remove this once the new command/metric handling is |
13 // implemented. This is a temporary workaround to allow metrics recording to | 14 // implemented. This is a temporary workaround to allow metrics recording to |
14 // distinguish the action. The value used is in the dynamic range (< | 15 // distinguish the action. The value used is in the dynamic range (< |
15 // IDC_MinimumLabelValue) to avoid collisions. | 16 // IDC_MinimumLabelValue) to avoid collisions. |
16 #define IDC_TEMP_EDIT_BOOKMARK 3900 | 17 #define IDC_TEMP_EDIT_BOOKMARK 3900 |
17 | 18 |
18 // The a11y ID of the tools menu items (used by integration tests). | 19 // The a11y ID of the tools menu items (used by integration tests). |
19 extern NSString* const kToolsMenuNewTabId; | 20 extern NSString* const kToolsMenuNewTabId; |
20 extern NSString* const kToolsMenuNewIncognitoTabId; | 21 extern NSString* const kToolsMenuNewIncognitoTabId; |
21 extern NSString* const kToolsMenuCloseAllTabsId; | 22 extern NSString* const kToolsMenuCloseAllTabsId; |
22 extern NSString* const kToolsMenuCloseAllIncognitoTabsId; | 23 extern NSString* const kToolsMenuCloseAllIncognitoTabsId; |
23 extern NSString* const kToolsMenuBookmarksId; | 24 extern NSString* const kToolsMenuBookmarksId; |
24 extern NSString* const kToolsMenuOtherDevicesId; | 25 extern NSString* const kToolsMenuOtherDevicesId; |
25 extern NSString* const kToolsMenuHistoryId; | 26 extern NSString* const kToolsMenuHistoryId; |
26 extern NSString* const kToolsMenuReportAnIssueId; | 27 extern NSString* const kToolsMenuReportAnIssueId; |
27 extern NSString* const kToolsMenuShareId; | 28 extern NSString* const kToolsMenuShareId; |
28 extern NSString* const kToolsMenuDataSavingsId; | 29 extern NSString* const kToolsMenuDataSavingsId; |
29 extern NSString* const kToolsMenuFindInPageId; | 30 extern NSString* const kToolsMenuFindInPageId; |
30 extern NSString* const kToolsMenuReaderMode; | 31 extern NSString* const kToolsMenuReaderMode; |
31 extern NSString* const kToolsMenuRequestDesktopId; | 32 extern NSString* const kToolsMenuRequestDesktopId; |
32 extern NSString* const kToolsMenuSettingsId; | 33 extern NSString* const kToolsMenuSettingsId; |
33 extern NSString* const kToolsMenuHelpId; | 34 extern NSString* const kToolsMenuHelpId; |
34 extern NSString* const kToolsMenuReadingListId; | 35 extern NSString* const kToolsMenuReadingListId; |
35 extern NSString* const kToolsMenuRequestMobileId; | 36 extern NSString* const kToolsMenuRequestMobileId; |
36 | 37 |
| 38 typedef NS_ENUM(int, ToolsMenuItemID) { |
| 39 // All of these items should be < 0. |
| 40 TOOLS_STOP_ITEM = -1, |
| 41 TOOLS_RELAOD_ITEM = -2, |
| 42 }; |
| 43 |
37 // Tools Popup Table Delegate Protocol | 44 // Tools Popup Table Delegate Protocol |
38 @protocol ToolsPopupTableDelegate<NSObject> | 45 @protocol ToolsPopupTableDelegate<NSObject> |
39 // Called when a menu item for command |commandID| is selected. | 46 // Called when a menu item for command |commandID| is selected. |
40 // TODO(stuartmorgan): This is a temporary shim. Remove it once: | 47 // TODO(stuartmorgan): This is a temporary shim. Remove it once: |
41 // - the automatic command-based metrics system is in place, and | 48 // - the automatic command-based metrics system is in place, and |
42 // - we figure out a better way to dismiss the menu (maybe a provided block?) | 49 // - we figure out a better way to dismiss the menu (maybe a provided block?) |
43 - (void)commandWasSelected:(int)commandID; | 50 - (void)commandWasSelected:(int)commandID; |
44 @end | 51 @end |
45 | 52 |
46 // A table view with two icons in the first row and regular text cells in | 53 // A table view with two icons in the first row and regular text cells in |
47 // subsequent rows. | 54 // subsequent rows. |
48 // For each icon and item in the menu there is a corresponding delegate method. | 55 // For each icon and item in the menu there is a corresponding delegate method. |
49 @interface ToolsMenuViewController : UIViewController | 56 @interface ToolsMenuViewController : UIViewController |
50 // Keeps track of the state (Bookmarked or not) of the current visible page. | 57 // Keeps track of the state (Bookmarked or not) of the current visible page. |
51 // This is used to alter the state of the popup menu (i.e. Add/Edit bookmark). | 58 // This is used to alter the state of the popup menu (i.e. Add/Edit bookmark). |
52 @property(nonatomic, assign) BOOL isCurrentPageBookmarked; | 59 @property(nonatomic, assign) BOOL isCurrentPageBookmarked; |
53 @property(nonatomic, assign) BOOL isTabLoading; | 60 @property(nonatomic, assign) BOOL isTabLoading; |
54 // The tool button to be shown hovering above the popup. | 61 // The tool button to be shown hovering above the popup. |
55 @property(nonatomic, readonly, weak) UIButton* toolsButton; | 62 @property(nonatomic, readonly, weak) UIButton* toolsButton; |
56 | 63 |
57 // Keeps track of the items in tools menu. | 64 // Keeps track of the items in tools menu. |
58 @property(nonatomic, copy) NSArray* menuItems; | 65 @property(nonatomic, copy) NSArray* menuItems; |
59 | 66 |
60 @property(nonatomic, weak) id<ToolsPopupTableDelegate> delegate; | 67 @property(nonatomic, weak) id<ToolsPopupTableDelegate> delegate; |
61 | 68 |
| 69 // Dispatcher for browser commands. |
| 70 @property(nonatomic, weak) id<BrowserCommands> dispatcher; |
| 71 |
62 // Initializes the Tools popup menu. | 72 // Initializes the Tools popup menu. |
63 - (void)initializeMenuWithConfiguration:(ToolsMenuConfiguration*)configuration; | 73 - (void)initializeMenuWithConfiguration:(ToolsMenuConfiguration*)configuration; |
64 | 74 |
65 // Returns the optimal height needed to display the menu items. | 75 // Returns the optimal height needed to display the menu items. |
66 // The height returned is usually less than the |suggestedHeight| unless | 76 // The height returned is usually less than the |suggestedHeight| unless |
67 // the last row of the menu puts the height just over the |suggestedHeight|. | 77 // the last row of the menu puts the height just over the |suggestedHeight|. |
68 // If the Tools menu items is taller than the |suggestedHeight| by at least | 78 // If the Tools menu items is taller than the |suggestedHeight| by at least |
69 // one menu item, the last visible menu item will be shown partially so user | 79 // one menu item, the last visible menu item will be shown partially so user |
70 // can tell that the Tools menu is scrollable. | 80 // can tell that the Tools menu is scrollable. |
71 - (CGFloat)optimalHeight:(CGFloat)suggestedHeight; | 81 - (CGFloat)optimalHeight:(CGFloat)suggestedHeight; |
(...skipping 17 matching lines...) Expand all Loading... |
89 // Informs tools popup menu whether the switch to reader mode is possible. | 99 // Informs tools popup menu whether the switch to reader mode is possible. |
90 - (void)setCanUseReaderMode:(BOOL)enabled; | 100 - (void)setCanUseReaderMode:(BOOL)enabled; |
91 | 101 |
92 - (void)animateContentIn; | 102 - (void)animateContentIn; |
93 | 103 |
94 - (void)hideContent; | 104 - (void)hideContent; |
95 | 105 |
96 @end | 106 @end |
97 | 107 |
98 #endif // IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ | 108 #endif // IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ |
OLD | NEW |