Index: ios/chrome/browser/ui/tools_menu/tools_menu_model.h |
diff --git a/ios/chrome/browser/ui/tools_menu/tools_menu_model.h b/ios/chrome/browser/ui/tools_menu/tools_menu_model.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bce1b3daf4db1a7db2b79f9a434ce775151d7d59 |
--- /dev/null |
+++ b/ios/chrome/browser/ui/tools_menu/tools_menu_model.h |
@@ -0,0 +1,87 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_MODEL_H_ |
+#define IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_MODEL_H_ |
+ |
+#import <Foundation/Foundation.h> |
+ |
+// New Tab item accessibility Identifier. |
+extern NSString* const kToolsMenuNewTabId; |
+// New incognito Tab item accessibility Identifier. |
+extern NSString* const kToolsMenuNewIncognitoTabId; |
+// Close all Tabs item accessibility Identifier. |
+extern NSString* const kToolsMenuCloseAllTabsId; |
+// Close all incognito Tabs item accessibility Identifier. |
+extern NSString* const kToolsMenuCloseAllIncognitoTabsId; |
+// Bookmarks item accessibility Identifier. |
+extern NSString* const kToolsMenuBookmarksId; |
+// Reading List item accessibility Identifier. |
+extern NSString* const kToolsMenuReadingListId; |
+// Other Devices item accessibility Identifier. |
+extern NSString* const kToolsMenuOtherDevicesId; |
+// History item accessibility Identifier. |
+extern NSString* const kToolsMenuHistoryId; |
+// Report an issue item accessibility Identifier. |
+extern NSString* const kToolsMenuReportAnIssueId; |
+// Find in Page item accessibility Identifier. |
+extern NSString* const kToolsMenuFindInPageId; |
+// Reader Mode item accessibility Identifier. |
+extern NSString* const kToolsMenuReaderMode; |
+// Request desktop item accessibility Identifier. |
+extern NSString* const kToolsMenuRequestDesktopId; |
+// Settings item accessibility Identifier. |
+extern NSString* const kToolsMenuSettingsId; |
+// Help item accessibility Identifier. |
+extern NSString* const kToolsMenuHelpId; |
+// Suggestions item accessibility Identifier. |
+extern NSString* const kToolsMenuSuggestionsId; |
edchin
2017/02/22 07:22:29
Not for this CL: Consider moving all these accessi
sczs
2017/02/22 18:05:12
Acknowledged.
|
+ |
+// Total number of possible menu items. |
+const int kToolsMenuNumberOfItems = 15; |
+ |
+// Initialization table for all possible commands to initialize the |
+// tools menu at run time. Data initialized into this structure is not mutable. |
+struct MenuItemInfo { |
+ int title_id; |
+ NSString* accessibility_id; |
+ int command_id; |
+ int toolbar_types; |
+ // |visibility| is applied if a menu item is included for a given |
+ // |toolbar_types|. A value of 0 means the menu item is always visible for |
+ // the given |toolbar_types|. |
+ int visibility; |
+ // Custom class, if any, for the menu item, or |nil|. |
+ Class item_class; |
+}; |
+ |
+// Flags for different toolbar types |
+typedef NS_OPTIONS(NSUInteger, kToolbarType) { |
edchin
2017/02/22 07:22:29
Not for this CL (especially since this is legacy c
marq (ping after 24h)
2017/02/22 11:15:57
Correct, chromium style is MACRO. But no need to f
rohitrao (ping after 24h)
2017/02/22 12:17:33
I don't think we use MACRO style for NS_OPTIONS or
marq (ping after 24h)
2017/02/22 12:29:06
Our style guides are unclear on this point, then.
sczs
2017/02/22 18:05:11
Acknowledged.
|
+ // clang-format off |
+ kToolbarTypeNone = 0, |
+ kToolbarTypeWebiPhone = 1 << 0, |
+ kToolbarTypeWebiPad = 1 << 1, |
+ kToolbarTypeNoTabsiPad = 1 << 2, |
+ kToolbarTypeSwitcheriPhone = 1 << 3, |
+ kToolbarTypeWebAll = kToolbarTypeWebiPhone | kToolbarTypeWebiPad, |
+ kToolbarTypeAll = kToolbarTypeWebAll | |
+ kToolbarTypeSwitcheriPhone | |
+ kToolbarTypeNoTabsiPad, |
+ // clang-format on |
+}; |
+ |
+// All possible items. |
+extern const MenuItemInfo itemInfoList[kToolsMenuNumberOfItems]; |
+ |
+// Class for handling all ToolsMenuVC model related methods or configuration. |
marq (ping after 24h)
2017/02/22 11:15:57
Don't use classes (in either ObjC or C++) just to
rohitrao (ping after 24h)
2017/02/22 12:17:33
Chromium doesn't use namespaces for this either =)
sczs
2017/02/22 18:05:11
Done.
|
+class ToolsMenuModel { |
+ public: |
+ // Returns true if a given item should be visible based on the Toolbar type |
+ // and if incognito mode or not. |
+ static bool ItemShouldBeVisible(const MenuItemInfo& item, |
+ bool incognito, |
+ kToolbarType toolbarType); |
+}; |
+ |
+#endif // IOS_CHROME_BROWSER_UI_TOOLS_MENU_TOOLS_MENU_MODEL_H_ |