OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 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_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 @class ToolsMenuContext; |
| 11 |
| 12 // 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 // distinguish the action. The value used is in the dynamic range (< |
| 15 // IDC_MinimumLabelValue) to avoid collisions. |
| 16 #define IDC_TEMP_EDIT_BOOKMARK 3900 |
| 17 |
| 18 // The a11y ID of the tools menu items (used by integration tests). |
| 19 extern NSString* const kToolsMenuNewTabId; |
| 20 extern NSString* const kToolsMenuNewIncognitoTabId; |
| 21 extern NSString* const kToolsMenuCloseAllTabsId; |
| 22 extern NSString* const kToolsMenuCloseAllIncognitoTabsId; |
| 23 extern NSString* const kToolsMenuBookmarksId; |
| 24 extern NSString* const kToolsMenuOtherDevicesId; |
| 25 extern NSString* const kToolsMenuHistoryId; |
| 26 extern NSString* const kToolsMenuReportAnIssueId; |
| 27 extern NSString* const kToolsMenuShareId; |
| 28 extern NSString* const kToolsMenuDataSavingsId; |
| 29 extern NSString* const kToolsMenuFindInPageId; |
| 30 extern NSString* const kToolsMenuReaderMode; |
| 31 extern NSString* const kToolsMenuRequestDesktopId; |
| 32 extern NSString* const kToolsMenuSettingsId; |
| 33 extern NSString* const kToolsMenuHelpId; |
| 34 |
| 35 // Tools Popup Table Delegate Protocol |
| 36 @protocol ToolsPopupTableDelegate<NSObject> |
| 37 // Called when a menu item for command |commandID| is selected. |
| 38 // TODO(stuartmorgan): This is a temporary shim. Remove it once: |
| 39 // - the automatic command-based metrics system is in place, and |
| 40 // - we figure out a better way to dismiss the menu (maybe a provided block?) |
| 41 - (void)commandWasSelected:(int)commandID; |
| 42 @end |
| 43 |
| 44 // A table view with two icons in the first row and regular text cells in |
| 45 // subsequent rows. |
| 46 // For each icon and item in the menu there is a corresponding delegate method. |
| 47 @interface ToolsMenuViewController : UIViewController |
| 48 // Keeps track of the state (Bookmarked or not) of the current visible page. |
| 49 // This is used to alter the state of the popup menu (i.e. Add/Edit bookmark). |
| 50 @property(nonatomic, assign) BOOL isCurrentPageBookmarked; |
| 51 @property(nonatomic, assign) BOOL isTabLoading; |
| 52 // The tool button to be shown hovering above the popup. |
| 53 @property(nonatomic, readonly) UIButton* toolsButton; |
| 54 |
| 55 @property(nonatomic, assign) id<ToolsPopupTableDelegate> delegate; |
| 56 |
| 57 // Initializes the Tools popup menu. |
| 58 - (void)initializeMenu:(ToolsMenuContext*)context; |
| 59 |
| 60 // Returns the optimal height needed to display the menu items. |
| 61 // The height returned is usually less than the |suggestedHeight| unless |
| 62 // the last row of the menu puts the height just over the |suggestedHeight|. |
| 63 // If the Tools menu items is taller than the |suggestedHeight| by at least |
| 64 // one menu item, the last visible menu item will be shown partially so user |
| 65 // can tell that the Tools menu is scrollable. |
| 66 - (CGFloat)optimalHeight:(CGFloat)suggestedHeight; |
| 67 |
| 68 // Enable or disable menu item by IDC value. |
| 69 - (void)setItemEnabled:(BOOL)enabled withTag:(NSInteger)tag; |
| 70 |
| 71 // Called when the current tab loading state changes. |
| 72 - (void)setIsTabLoading:(BOOL)isTabLoading; |
| 73 |
| 74 // TODO(stuartmorgan): Should the set of options that are passed in to the |
| 75 // constructor just have the ability to specify whether commands should be |
| 76 // enabled or disabled rather than having these individual setters? crbug/228506 |
| 77 // Informs tools popup menu whether "Find In Page..." command should be |
| 78 // enabled. |
| 79 - (void)setCanShowFindBar:(BOOL)enabled; |
| 80 |
| 81 // Informs tools popup menu whether "Share..." command should be enabled. |
| 82 - (void)setCanShowShareMenu:(BOOL)enabled; |
| 83 |
| 84 // Informs tools popup menu whether the switch to reader mode is possible. |
| 85 - (void)setCanUseReaderMode:(BOOL)enabled; |
| 86 |
| 87 // Informs tools popup menu whether "Request Desktop Site" can be enabled. |
| 88 - (void)setCanUseDesktopUserAgent:(BOOL)value; |
| 89 |
| 90 - (void)animateContentIn; |
| 91 |
| 92 - (void)hideContent; |
| 93 |
| 94 @end |
| 95 |
| 96 #endif // IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_VIEW_CONTROLLER_H_ |
OLD | NEW |