OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.appmenu; | 5 package org.chromium.chrome.browser.appmenu; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.pm.ResolveInfo; | 8 import android.content.pm.ResolveInfo; |
9 import android.graphics.PorterDuff; | 9 import android.graphics.PorterDuff; |
10 import android.graphics.drawable.Drawable; | 10 import android.graphics.drawable.Drawable; |
(...skipping 12 matching lines...) Expand all Loading... | |
23 import org.chromium.chrome.browser.UrlConstants; | 23 import org.chromium.chrome.browser.UrlConstants; |
24 import org.chromium.chrome.browser.banners.AppBannerManager; | 24 import org.chromium.chrome.browser.banners.AppBannerManager; |
25 import org.chromium.chrome.browser.bookmarks.BookmarkBridge; | 25 import org.chromium.chrome.browser.bookmarks.BookmarkBridge; |
26 import org.chromium.chrome.browser.download.DownloadUtils; | 26 import org.chromium.chrome.browser.download.DownloadUtils; |
27 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 27 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
28 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; | 28 import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; |
29 import org.chromium.chrome.browser.preferences.ManagedPreferencesUtils; | 29 import org.chromium.chrome.browser.preferences.ManagedPreferencesUtils; |
30 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 30 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
31 import org.chromium.chrome.browser.share.ShareHelper; | 31 import org.chromium.chrome.browser.share.ShareHelper; |
32 import org.chromium.chrome.browser.tab.Tab; | 32 import org.chromium.chrome.browser.tab.Tab; |
33 import org.chromium.chrome.browser.util.FeatureUtilities; | |
33 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; | 34 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; |
34 import org.chromium.ui.base.DeviceFormFactor; | 35 import org.chromium.ui.base.DeviceFormFactor; |
35 import org.chromium.webapk.lib.client.WebApkValidator; | 36 import org.chromium.webapk.lib.client.WebApkValidator; |
36 | 37 |
37 import java.util.concurrent.TimeUnit; | 38 import java.util.concurrent.TimeUnit; |
38 | 39 |
39 /** | 40 /** |
40 * App Menu helper that handles hiding and showing menu items based on activity state. | 41 * App Menu helper that handles hiding and showing menu items based on activity state. |
41 */ | 42 */ |
42 public class AppMenuPropertiesDelegate { | 43 public class AppMenuPropertiesDelegate { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 menu.findItem(R.id.close_all_incognito_tabs_menu_id).setEnabled( true); | 196 menu.findItem(R.id.close_all_incognito_tabs_menu_id).setEnabled( true); |
196 } else { | 197 } else { |
197 // Hide close incognito tabs item. | 198 // Hide close incognito tabs item. |
198 menu.findItem(R.id.close_all_incognito_tabs_menu_id).setVisible( false); | 199 menu.findItem(R.id.close_all_incognito_tabs_menu_id).setVisible( false); |
199 // Enable close all tabs if there are normal tabs or incognito t abs. | 200 // Enable close all tabs if there are normal tabs or incognito t abs. |
200 menu.findItem(R.id.close_all_tabs_menu_id).setEnabled( | 201 menu.findItem(R.id.close_all_tabs_menu_id).setEnabled( |
201 mActivity.getTabModelSelector().getTotalTabCount() > 0); | 202 mActivity.getTabModelSelector().getTotalTabCount() > 0); |
202 } | 203 } |
203 } | 204 } |
204 | 205 |
206 if (FeatureUtilities.isChromeHomeEnabled()) { | |
mdjones
2017/03/14 20:08:36
Can you make sure this works in custom tabs?
Theresa
2017/03/14 20:40:02
None of these menu items are shown in custom tabs
| |
207 menu.findItem(R.id.open_history_menu_id).setVisible(false); | |
208 menu.findItem(R.id.downloads_menu_id).setVisible(false); | |
209 menu.findItem(R.id.all_bookmarks_menu_id).setVisible(false); | |
210 } | |
211 | |
205 // Disable new incognito tab when it is blocked (e.g. by a policy). | 212 // Disable new incognito tab when it is blocked (e.g. by a policy). |
206 // findItem(...).setEnabled(...)" is not enough here, because of the inf lated | 213 // findItem(...).setEnabled(...)" is not enough here, because of the inf lated |
207 // main_menu.xml contains multiple items with the same id in different g roups | 214 // main_menu.xml contains multiple items with the same id in different g roups |
208 // e.g.: new_incognito_tab_menu_id. | 215 // e.g.: new_incognito_tab_menu_id. |
209 disableEnableMenuItem(menu, R.id.new_incognito_tab_menu_id, | 216 disableEnableMenuItem(menu, R.id.new_incognito_tab_menu_id, |
210 true, | 217 true, |
211 PrefServiceBridge.getInstance().isIncognitoModeEnabled(), | 218 PrefServiceBridge.getInstance().isIncognitoModeEnabled(), |
212 PrefServiceBridge.getInstance().isIncognitoModeManaged()); | 219 PrefServiceBridge.getInstance().isIncognitoModeManaged()); |
213 mActivity.prepareMenu(menu); | 220 mActivity.prepareMenu(menu); |
214 } | 221 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 String url = currentTab.getUrl(); | 338 String url = currentTab.getUrl(); |
332 boolean isChromeScheme = url.startsWith(UrlConstants.CHROME_URL_PREFIX) | 339 boolean isChromeScheme = url.startsWith(UrlConstants.CHROME_URL_PREFIX) |
333 || url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX); | 340 || url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX); |
334 requstMenuItem.setVisible(!isChromeScheme || currentTab.isNativePage()); | 341 requstMenuItem.setVisible(!isChromeScheme || currentTab.isNativePage()); |
335 requstMenuItem.setChecked(currentTab.getUseDesktopUserAgent()); | 342 requstMenuItem.setChecked(currentTab.getUseDesktopUserAgent()); |
336 requstMenuItem.setTitleCondensed(requstMenuItem.isChecked() | 343 requstMenuItem.setTitleCondensed(requstMenuItem.isChecked() |
337 ? mActivity.getString(R.string.menu_request_desktop_site_on) | 344 ? mActivity.getString(R.string.menu_request_desktop_site_on) |
338 : mActivity.getString(R.string.menu_request_desktop_site_off)); | 345 : mActivity.getString(R.string.menu_request_desktop_site_off)); |
339 } | 346 } |
340 } | 347 } |
OLD | NEW |