Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: ios/chrome/browser/ui/tools_menu/tools_menu_model.mm

Issue 2722693002: [ios] Creates ToolsMenuConstants file (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ios/chrome/browser/ui/tools_menu/tools_menu_model.h" 5 #include "ios/chrome/browser/ui/tools_menu/tools_menu_model.h"
6 6
7 #include "components/reading_list/core/reading_list_switches.h" 7 #include "components/reading_list/core/reading_list_switches.h"
8 #include "components/strings/grit/components_strings.h" 8 #include "components/strings/grit/components_strings.h"
9 #include "ios/chrome/browser/experimental_flags.h" 9 #include "ios/chrome/browser/experimental_flags.h"
10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
11 #import "ios/chrome/browser/ui/tools_menu/reading_list_menu_view_item.h" 11 #import "ios/chrome/browser/ui/tools_menu/reading_list_menu_view_item.h"
12 #include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h"
12 #include "ios/chrome/browser/ui/ui_util.h" 13 #include "ios/chrome/browser/ui/ui_util.h"
13 #include "ios/chrome/grit/ios_strings.h" 14 #include "ios/chrome/grit/ios_strings.h"
14 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 15 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
15 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider .h" 16 #import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider .h"
17 #include "ios/web/public/user_agent.h"
18
19 // TODO(crbug.com/678047) Remove this switch when request mobile site
20 // functionality is implemented.
21 #define HIDE_REQUEST_MOBILE_SITE_CELL
16 22
17 // Menu items can be marked as visible or not when Incognito is enabled. 23 // Menu items can be marked as visible or not when Incognito is enabled.
18 // The following bits are used for |visibility| field in |MenuItemInfo|. 24 // The following bits are used for |visibility| field in |MenuItemInfo|.
19 const NSInteger kVisibleIncognitoOnly = 1 << 0; 25 const NSInteger kVisibleIncognitoOnly = 1 << 0;
20 const NSInteger kVisibleNotIncognitoOnly = 1 << 1; 26 const NSInteger kVisibleNotIncognitoOnly = 1 << 1;
21 27
22 // Declare all the possible items. 28 // Declare all the possible items.
23 const MenuItemInfo itemInfoList[] = { 29 const MenuItemInfo itemInfoList[] = {
24 // clang-format off 30 // clang-format off
25 { IDS_IOS_TOOLS_MENU_NEW_TAB, kToolsMenuNewTabId, 31 { IDS_IOS_TOOLS_MENU_NEW_TAB, kToolsMenuNewTabId,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { IDS_IOS_TOOLS_MENU_SETTINGS, kToolsMenuSettingsId, 71 { IDS_IOS_TOOLS_MENU_SETTINGS, kToolsMenuSettingsId,
66 IDC_OPTIONS, ToolbarTypeAll, 72 IDC_OPTIONS, ToolbarTypeAll,
67 0, nil }, 73 0, nil },
68 { IDS_IOS_TOOLS_MENU_HELP_MOBILE, kToolsMenuHelpId, 74 { IDS_IOS_TOOLS_MENU_HELP_MOBILE, kToolsMenuHelpId,
69 IDC_HELP_PAGE_VIA_MENU, ToolbarTypeWebAll, 75 IDC_HELP_PAGE_VIA_MENU, ToolbarTypeWebAll,
70 0, nil }, 76 0, nil },
71 // clang-format on 77 // clang-format on
72 }; 78 };
73 79
74 bool ToolsMenuItemShouldBeVisible(const MenuItemInfo& item, 80 bool ToolsMenuItemShouldBeVisible(const MenuItemInfo& item,
75 bool incognito, 81 ToolbarType toolbarType,
76 ToolbarType toolbarType) { 82 ToolsMenuConfiguration* configuration) {
77 if (!(item.toolbar_types & toolbarType)) 83 if (!(item.toolbar_types & toolbarType))
78 return false; 84 return false;
79 85
80 if (incognito && (item.visibility & kVisibleNotIncognitoOnly)) 86 if (configuration.inIncognito && (item.visibility & kVisibleNotIncognitoOnly))
81 return false; 87 return false;
82 88
83 if (!incognito && (item.visibility & kVisibleIncognitoOnly)) 89 if (!configuration.inIncognito && (item.visibility & kVisibleIncognitoOnly))
84 return false; 90 return false;
85 91
86 switch (item.title_id) { 92 switch (item.title_id) {
87 case IDS_IOS_TOOLBAR_SHOW_TABS: 93 case IDS_IOS_TOOLBAR_SHOW_TABS:
88 return IsIPadIdiom(); 94 return IsIPadIdiom();
89 case IDS_IOS_TOOLS_MENU_READER_MODE: 95 case IDS_IOS_TOOLS_MENU_READER_MODE:
90 return experimental_flags::IsReaderModeEnabled(); 96 return experimental_flags::IsReaderModeEnabled();
91 case IDS_IOS_TOOLS_MENU_READING_LIST: 97 case IDS_IOS_TOOLS_MENU_READING_LIST:
92 return reading_list::switches::IsReadingListEnabled(); 98 return reading_list::switches::IsReadingListEnabled();
93 case IDS_IOS_TOOLS_MENU_SUGGESTIONS: 99 case IDS_IOS_TOOLS_MENU_SUGGESTIONS:
94 return experimental_flags::IsSuggestionsUIEnabled(); 100 return experimental_flags::IsSuggestionsUIEnabled();
95 case IDS_IOS_OPTIONS_REPORT_AN_ISSUE: 101 case IDS_IOS_OPTIONS_REPORT_AN_ISSUE:
96 return !ios::GetChromeBrowserProvider() 102 return ios::GetChromeBrowserProvider()
97 ->GetUserFeedbackProvider() 103 ->GetUserFeedbackProvider()
98 ->IsUserFeedbackEnabled(); 104 ->IsUserFeedbackEnabled();
105 // TODO(crbug.com/696676): Talk to UI/UX people to decide the correct
106 // behavior of "Requestion Desktop/Mobile Site" (e.g. Whether user agent
107 // flag should stick when going backward and which cell should be visible
108 // when navigating to native pages).
109 case IDS_IOS_TOOLS_MENU_REQUEST_DESKTOP_SITE:
110 #ifdef HIDE_REQUEST_MOBILE_SITE_CELL
111 return true;
112 #else
113 return (configuration.userAgentType != web::UserAgentType::DESKTOP);
114 #endif
115 case IDS_IOS_TOOLS_MENU_REQUEST_MOBILE_SITE:
116 // TODO(crbug.com/678047) Remove this switch when request mobile site
117 // functionality is implemented.
118 #ifdef HIDE_REQUEST_MOBILE_SITE_CELL
119 return false;
120 #else
121 return (configuration.userAgentType == web::UserAgentType::DESKTOP);
122 #endif
99 default: 123 default:
100 return true; 124 return true;
101 } 125 }
102 } 126 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/tools_menu/tools_menu_model.h ('k') | ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698