| Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
| index 5352ed1ad824e045a1fb6529adb4db81915e9f27..0d44461e32961f0811d3a7ea64bdf55338887de8 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
| @@ -7,10 +7,10 @@ package org.chromium.chrome.browser.contextmenu;
|
| import android.content.Context;
|
| import android.net.MailTo;
|
| import android.support.annotation.IntDef;
|
| +import android.support.annotation.StringRes;
|
| import android.text.TextUtils;
|
| +import android.util.Pair;
|
| import android.view.ContextMenu;
|
| -import android.view.MenuInflater;
|
| -import android.view.MenuItem;
|
| import android.webkit.MimeTypeMap;
|
|
|
| import org.chromium.base.CollectionUtil;
|
| @@ -25,7 +25,10 @@ import org.chromium.chrome.browser.util.UrlUtilities;
|
|
|
| import java.lang.annotation.Retention;
|
| import java.lang.annotation.RetentionPolicy;
|
| +import java.util.ArrayList;
|
| +import java.util.Collections;
|
| import java.util.HashSet;
|
| +import java.util.List;
|
| import java.util.Set;
|
|
|
| /**
|
| @@ -40,9 +43,9 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
| */
|
| @Retention(RetentionPolicy.SOURCE)
|
| @IntDef({
|
| - NORMAL_MODE, /* Default mode */
|
| - CUSTOM_TAB_MODE, /* Custom tab mode */
|
| - FULLSCREEN_TAB_MODE /* Full screen mode */
|
| + NORMAL_MODE, /* Default mode */
|
| + CUSTOM_TAB_MODE, /* Custom tab mode */
|
| + FULLSCREEN_TAB_MODE /* Full screen mode */
|
| })
|
| public @interface ContextMenuMode {}
|
|
|
| @@ -50,32 +53,73 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
| public static final int CUSTOM_TAB_MODE = 1;
|
| public static final int FULLSCREEN_TAB_MODE = 2;
|
|
|
| + /**
|
| + * Defines the Groups of each Context Menu Item
|
| + */
|
| + @Retention(RetentionPolicy.SOURCE)
|
| + @IntDef({LINK, IMAGE, VIDEO})
|
| + public @interface ContextMenuGroup {}
|
| +
|
| + public static final int LINK = 0;
|
| + public static final int IMAGE = 1;
|
| + public static final int VIDEO = 2;
|
| +
|
| // Items that are included in all context menus.
|
| - private static final Set<Integer> BASE_WHITELIST = CollectionUtil.newHashSet(
|
| - R.id.contextmenu_copy_link_address, R.id.contextmenu_call,
|
| - R.id.contextmenu_send_message, R.id.contextmenu_add_to_contacts, R.id.contextmenu_copy,
|
| - R.id.contextmenu_copy_link_text, R.id.contextmenu_load_original_image,
|
| - R.id.contextmenu_save_link_as, R.id.contextmenu_save_image,
|
| - R.id.contextmenu_share_image, R.id.contextmenu_save_video);
|
| + private static final Set<ContextMenuItem> BASE_WHITELIST =
|
| + Collections.unmodifiableSet(CollectionUtil.newHashSet(ContextMenuItem.COPY_LINK_ADDRESS,
|
| + ContextMenuItem.CALL, ContextMenuItem.SEND_MESSAGE,
|
| + ContextMenuItem.ADD_TO_CONTACTS, ContextMenuItem.COPY,
|
| + ContextMenuItem.COPY_LINK_TEXT, ContextMenuItem.LOAD_ORIGINAL_IMAGE,
|
| + ContextMenuItem.SAVE_LINK_AS, ContextMenuItem.SAVE_IMAGE,
|
| + ContextMenuItem.SHARE_IMAGE, ContextMenuItem.SAVE_VIDEO));
|
|
|
| // Items that are included for normal Chrome browser mode.
|
| - private static final Set<Integer> NORMAL_MODE_WHITELIST = CollectionUtil.newHashSet(
|
| - R.id.contextmenu_open_in_new_tab, R.id.contextmenu_open_in_other_window,
|
| - R.id.contextmenu_open_in_incognito_tab, R.id.contextmenu_save_link_as,
|
| - R.id.contextmenu_open_image_in_new_tab, R.id.contextmenu_search_by_image);
|
| + private static final Set<ContextMenuItem> NORMAL_MODE_WHITELIST =
|
| + Collections.unmodifiableSet(CollectionUtil.newHashSet(ContextMenuItem.OPEN_IN_NEW_TAB,
|
| + ContextMenuItem.OPEN_IN_OTHER_WINDOW, ContextMenuItem.OPEN_IN_INCOGNITO_TAB,
|
| + ContextMenuItem.SAVE_LINK_AS, ContextMenuItem.OPEN_IMAGE_IN_NEW_TAB,
|
| + ContextMenuItem.SEARCH_BY_IMAGE));
|
|
|
| // Additional items for custom tabs mode.
|
| - private static final Set<Integer> CUSTOM_TAB_MODE_WHITELIST = CollectionUtil.newHashSet(
|
| - R.id.contextmenu_open_image, R.id.contextmenu_search_by_image,
|
| - R.id.contextmenu_open_in_new_chrome_tab, R.id.contextmenu_open_in_chrome_incognito_tab,
|
| - R.id.contextmenu_open_in_browser_id);
|
| + private static final Set<ContextMenuItem> CUSTOM_TAB_MODE_WHITELIST =
|
| + Collections.unmodifiableSet(CollectionUtil.newHashSet(ContextMenuItem.OPEN_IMAGE,
|
| + ContextMenuItem.SEARCH_BY_IMAGE, ContextMenuItem.OPEN_IN_NEW_CHROME_TAB,
|
| + ContextMenuItem.OPEN_IN_CHROME_INCOGNITO_TAB,
|
| + ContextMenuItem.OPEN_IN_BROWSER_ID));
|
|
|
| // Additional items for fullscreen tabs mode.
|
| - private static final Set<Integer> FULLSCREEN_TAB_MODE_WHITELIST =
|
| - CollectionUtil.newHashSet(R.id.menu_id_open_in_chrome);
|
| + private static final Set<ContextMenuItem> FULLSCREEN_TAB_MODE_WHITELIST =
|
| + Collections.unmodifiableSet(CollectionUtil.newHashSet(ContextMenuItem.OPEN_IN_CHROME));
|
| +
|
| + // The order of the items within each lists determines the order of the context menu.
|
| + private static final List<ContextMenuItem> CUSTOM_TAB_GROUP = Collections.unmodifiableList(
|
| + CollectionUtil.newArrayList(ContextMenuItem.OPEN_IN_NEW_CHROME_TAB,
|
| + ContextMenuItem.OPEN_IN_CHROME_INCOGNITO_TAB,
|
| + ContextMenuItem.OPEN_IN_BROWSER_ID));
|
| +
|
| + private static final List<ContextMenuItem> LINK_GROUP =
|
| + Collections.unmodifiableList(CollectionUtil.newArrayList(
|
| + ContextMenuItem.OPEN_IN_OTHER_WINDOW, ContextMenuItem.OPEN_IN_NEW_TAB,
|
| + ContextMenuItem.OPEN_IN_INCOGNITO_TAB, ContextMenuItem.COPY_LINK_ADDRESS,
|
| + ContextMenuItem.COPY_LINK_TEXT, ContextMenuItem.SAVE_LINK_AS));
|
| +
|
| + private static final List<ContextMenuItem> IMAGE_GROUP =
|
| + Collections.unmodifiableList(CollectionUtil.newArrayList(
|
| + ContextMenuItem.LOAD_ORIGINAL_IMAGE, ContextMenuItem.SAVE_IMAGE,
|
| + ContextMenuItem.OPEN_IMAGE, ContextMenuItem.OPEN_IMAGE_IN_NEW_TAB,
|
| + ContextMenuItem.SEARCH_BY_IMAGE, ContextMenuItem.SHARE_IMAGE));
|
| +
|
| + private static final List<ContextMenuItem> MESSAGE_GROUP = Collections.unmodifiableList(
|
| + CollectionUtil.newArrayList(ContextMenuItem.CALL, ContextMenuItem.SEND_MESSAGE,
|
| + ContextMenuItem.ADD_TO_CONTACTS, ContextMenuItem.COPY));
|
| +
|
| + private static final List<ContextMenuItem> VIDEO_GROUP =
|
| + Collections.unmodifiableList(CollectionUtil.newArrayList(ContextMenuItem.SAVE_VIDEO));
|
| +
|
| + private static final List<ContextMenuItem> OTHER_GROUP = Collections.unmodifiableList(
|
| + CollectionUtil.newArrayList(ContextMenuItem.OPEN_IN_CHROME));
|
|
|
| private final ContextMenuItemDelegate mDelegate;
|
| - private MenuInflater mMenuInflater;
|
| private final int mMode;
|
|
|
| static class ContextMenuUma {
|
| @@ -178,141 +222,223 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
| mDelegate.onDestroy();
|
| }
|
|
|
| - @Override
|
| - public void buildContextMenu(ContextMenu menu, Context context, ContextMenuParams params) {
|
| + /**
|
| + * Gets the link of the item or the alternate text of an image.
|
| + * @return A string with either the link or with the alternate text.
|
| + */
|
| + public static String createHeaderText(ContextMenuParams params) {
|
| + String titleText = "";
|
| if (!TextUtils.isEmpty(params.getLinkUrl())
|
| && !params.getLinkUrl().equals(UrlConstants.ABOUT_BLANK_DISPLAY_URL)) {
|
| - setHeaderText(context, menu, params.getLinkUrl());
|
| + titleText = params.getLinkUrl();
|
| } else if (!TextUtils.isEmpty(params.getTitleText())) {
|
| - setHeaderText(context, menu, params.getTitleText());
|
| + titleText = params.getTitleText();
|
| }
|
| + return titleText;
|
| + }
|
|
|
| - if (params.isFile()) return;
|
| -
|
| - if (mMenuInflater == null) mMenuInflater = new MenuInflater(context);
|
| -
|
| - mMenuInflater.inflate(R.menu.chrome_context_menu, menu);
|
| -
|
| - menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor());
|
| - menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage());
|
| - menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo());
|
| - menu.setGroupVisible(R.id.contextmenu_group_message,
|
| - MailTo.isMailTo(params.getLinkUrl())
|
| - || UrlUtilities.isTelScheme(params.getLinkUrl()));
|
| -
|
| - Set<Integer> supportedOptions = new HashSet<>();
|
| + @Override
|
| + public List<Pair<Integer, List<ContextMenuItem>>> buildContextMenu(
|
| + ContextMenu menu, Context context, ContextMenuParams params) {
|
| + // Add all items in a group
|
| + Set<ContextMenuItem> supportedOptions = new HashSet<>();
|
| supportedOptions.addAll(BASE_WHITELIST);
|
| if (mMode == FULLSCREEN_TAB_MODE) {
|
| supportedOptions.addAll(FULLSCREEN_TAB_MODE_WHITELIST);
|
| } else if (mMode == CUSTOM_TAB_MODE) {
|
| supportedOptions.addAll(CUSTOM_TAB_MODE_WHITELIST);
|
| - if (!ChromePreferenceManager.getInstance().getCachedChromeDefaultBrowser()) {
|
| - menu.findItem(R.id.contextmenu_open_in_browser_id)
|
| - .setTitle(mDelegate.getTitleForOpenTabInExternalApp());
|
| - }
|
| } else {
|
| supportedOptions.addAll(NORMAL_MODE_WHITELIST);
|
| }
|
|
|
| - Set<Integer> disabledOptions = getDisabledOptions(params);
|
| - // Iterate through the entire menu list, if if doesn't exist in the map, don't show it.
|
| - for (int i = 0; i < menu.size(); i++) {
|
| - MenuItem item = menu.getItem(i);
|
| - if (!item.isVisible()) continue;
|
| - item.setVisible(supportedOptions.contains(item.getItemId())
|
| - && !disabledOptions.contains(item.getItemId()));
|
| + Set<ContextMenuItem> disabledOptions = getDisabledOptions(params);
|
| + // Split the items into their respective groups.
|
| + List<Pair<Integer, List<ContextMenuItem>>> groupedItems = new ArrayList<>();
|
| + if (params.isAnchor()) {
|
| + populateItemGroup(LINK, R.string.contextmenu_link_title, groupedItems, supportedOptions,
|
| + disabledOptions);
|
| + }
|
| + if (params.isImage()) {
|
| + populateItemGroup(IMAGE, R.string.contextmenu_image_title, groupedItems,
|
| + supportedOptions, disabledOptions);
|
| + }
|
| + if (params.isVideo()) {
|
| + populateItemGroup(VIDEO, R.string.contextmenu_video_title, groupedItems,
|
| + supportedOptions, disabledOptions);
|
| + }
|
| +
|
| + // If there are no groups there still needs to be a way to add items from the OTHER_GROUP
|
| + // and CUSTOM_TAB_GROUP.
|
| + if (groupedItems.isEmpty()) {
|
| + int titleResId = R.string.contextmenu_link_title;
|
| +
|
| + if (params.isVideo()) {
|
| + titleResId = R.string.contextmenu_video_title;
|
| + } else if (params.isImage()) {
|
| + titleResId = R.string.contextmenu_image_title;
|
| + }
|
| + groupedItems.add(new Pair<Integer, List<ContextMenuItem>>(
|
| + titleResId, new ArrayList<ContextMenuItem>()));
|
| + }
|
| +
|
| + // These items don't belong to any official group so they are added to a possible visible
|
| + // list.
|
| + addValidItems(groupedItems.get(groupedItems.size() - 1).second, OTHER_GROUP,
|
| + supportedOptions, disabledOptions);
|
| + if (mMode == CUSTOM_TAB_MODE) {
|
| + addValidItemsToFront(groupedItems.get(0).second, CUSTOM_TAB_GROUP, supportedOptions,
|
| + disabledOptions);
|
| + }
|
| +
|
| + // If there are no items from the extra items withing OTHER_GROUP and CUSTOM_TAB_GROUP, then
|
| + // it's removed since there is nothing to show at all.
|
| + if (groupedItems.get(0).second.isEmpty()) {
|
| + groupedItems.remove(0);
|
| }
|
|
|
| - // Special case for searching by image element.
|
| - if (supportedOptions.contains(R.id.contextmenu_search_by_image)) {
|
| - menu.findItem(R.id.contextmenu_search_by_image)
|
| - .setTitle(context.getString(R.string.contextmenu_search_web_for_image,
|
| - TemplateUrlService.getInstance()
|
| - .getDefaultSearchEngineTemplateUrl()
|
| - .getShortName()));
|
| + return groupedItems;
|
| + }
|
| +
|
| + private void populateItemGroup(@ContextMenuGroup int contextMenuType, @StringRes int titleResId,
|
| + List<Pair<Integer, List<ContextMenuItem>>> itemGroups,
|
| + Set<ContextMenuItem> supportedOptions, Set<ContextMenuItem> disabledOptions) {
|
| + List<ContextMenuItem> items = new ArrayList<>();
|
| + switch (contextMenuType) {
|
| + case LINK:
|
| + addValidItems(items, LINK_GROUP, supportedOptions, disabledOptions);
|
| + addValidItems(items, MESSAGE_GROUP, supportedOptions, disabledOptions);
|
| + break;
|
| + case IMAGE:
|
| + addValidItems(items, IMAGE_GROUP, supportedOptions, disabledOptions);
|
| + break;
|
| + case VIDEO:
|
| + addValidItems(items, VIDEO_GROUP, supportedOptions, disabledOptions);
|
| + break;
|
| + default:
|
| + return;
|
| + }
|
| +
|
| + if (items.isEmpty()) return;
|
| +
|
| + itemGroups.add(new Pair<>(titleResId, items));
|
| + }
|
| +
|
| + private void addValidItems(List<ContextMenuItem> validItems, List<ContextMenuItem> allItems,
|
| + Set<ContextMenuItem> supportedOptions, Set<ContextMenuItem> disabledOptions) {
|
| + for (int i = 0; i < allItems.size(); i++) {
|
| + ContextMenuItem item = allItems.get(i);
|
| + if (supportedOptions.contains(item) && !disabledOptions.contains(item)) {
|
| + assert !validItems.contains(item);
|
| + validItems.add(item);
|
| + }
|
| + }
|
| + }
|
| +
|
| + private void addValidItemsToFront(List<ContextMenuItem> validItems,
|
| + List<ContextMenuItem> allItems, Set<ContextMenuItem> supportedOptions,
|
| + Set<ContextMenuItem> disabledOptions) {
|
| + for (int i = 0; i < allItems.size(); i++) {
|
| + ContextMenuItem item = allItems.get(i);
|
| + if (supportedOptions.contains(item) && !disabledOptions.contains(item)) {
|
| + assert !validItems.contains(item);
|
| + validItems.add(0, item);
|
| + }
|
| }
|
| }
|
|
|
| /**
|
| * Given a set of params. It creates a list of items that should not be accessible in specific
|
| - * instances. Since it doesn't have access to the menu groups, they need to be filtered outside
|
| - * of this method.
|
| + * instances.
|
| * @param params The parameters used to create a list of items that should not be allowed.
|
| */
|
| - private Set<Integer> getDisabledOptions(ContextMenuParams params) {
|
| - Set<Integer> disabledOptions = new HashSet<>();
|
| + private Set<ContextMenuItem> getDisabledOptions(ContextMenuParams params) {
|
| + Set<ContextMenuItem> disabledOptions = new HashSet<>();
|
| + if (!params.isAnchor()) {
|
| + disabledOptions.addAll(LINK_GROUP);
|
| + }
|
| + if (!params.isImage()) {
|
| + disabledOptions.addAll(IMAGE_GROUP);
|
| + }
|
| + if (!params.isVideo()) {
|
| + disabledOptions.addAll(VIDEO_GROUP);
|
| + }
|
| + if (!MailTo.isMailTo(params.getLinkUrl())
|
| + && !UrlUtilities.isTelScheme(params.getLinkUrl())) {
|
| + disabledOptions.addAll(MESSAGE_GROUP);
|
| + }
|
| +
|
| if (params.isAnchor() && !mDelegate.isOpenInOtherWindowSupported()) {
|
| - disabledOptions.add(R.id.contextmenu_open_in_other_window);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_OTHER_WINDOW);
|
| }
|
|
|
| if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) {
|
| - disabledOptions.add(R.id.contextmenu_open_in_incognito_tab);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_INCOGNITO_TAB);
|
| }
|
|
|
| if (params.getLinkText().trim().isEmpty() || params.isImage()) {
|
| - disabledOptions.add(R.id.contextmenu_copy_link_text);
|
| + disabledOptions.add(ContextMenuItem.COPY_LINK_TEXT);
|
| }
|
|
|
| if (params.isAnchor() && !UrlUtilities.isAcceptedScheme(params.getLinkUrl())) {
|
| - disabledOptions.add(R.id.contextmenu_open_in_other_window);
|
| - disabledOptions.add(R.id.contextmenu_open_in_new_tab);
|
| - disabledOptions.add(R.id.contextmenu_open_in_incognito_tab);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_OTHER_WINDOW);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_NEW_TAB);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_INCOGNITO_TAB);
|
| }
|
|
|
| if (MailTo.isMailTo(params.getLinkUrl())) {
|
| - disabledOptions.add(R.id.contextmenu_copy_link_text);
|
| - disabledOptions.add(R.id.contextmenu_copy_link_address);
|
| + disabledOptions.add(ContextMenuItem.COPY_LINK_TEXT);
|
| + disabledOptions.add(ContextMenuItem.COPY_LINK_ADDRESS);
|
| if (!mDelegate.supportsSendEmailMessage()) {
|
| - disabledOptions.add(R.id.contextmenu_send_message);
|
| + disabledOptions.add(ContextMenuItem.SEND_MESSAGE);
|
| }
|
| if (TextUtils.isEmpty(MailTo.parse(params.getLinkUrl()).getTo())
|
| || !mDelegate.supportsAddToContacts()) {
|
| - disabledOptions.add(R.id.contextmenu_add_to_contacts);
|
| + disabledOptions.add(ContextMenuItem.ADD_TO_CONTACTS);
|
| }
|
| - disabledOptions.add(R.id.contextmenu_call);
|
| + disabledOptions.add(ContextMenuItem.CALL);
|
| } else if (UrlUtilities.isTelScheme(params.getLinkUrl())) {
|
| - disabledOptions.add(R.id.contextmenu_copy_link_text);
|
| - disabledOptions.add(R.id.contextmenu_copy_link_address);
|
| + disabledOptions.add(ContextMenuItem.COPY_LINK_TEXT);
|
| + disabledOptions.add(ContextMenuItem.COPY_LINK_ADDRESS);
|
| if (!mDelegate.supportsCall()) {
|
| - disabledOptions.add(R.id.contextmenu_call);
|
| + disabledOptions.add(ContextMenuItem.CALL);
|
| }
|
| if (!mDelegate.supportsSendTextMessage()) {
|
| - disabledOptions.add(R.id.contextmenu_send_message);
|
| + disabledOptions.add(ContextMenuItem.SEND_MESSAGE);
|
| }
|
| if (!mDelegate.supportsAddToContacts()) {
|
| - disabledOptions.add(R.id.contextmenu_add_to_contacts);
|
| + disabledOptions.add(ContextMenuItem.ADD_TO_CONTACTS);
|
| }
|
| }
|
|
|
| if (!UrlUtilities.isDownloadableScheme(params.getLinkUrl())) {
|
| - disabledOptions.add(R.id.contextmenu_save_link_as);
|
| + disabledOptions.add(ContextMenuItem.SAVE_LINK_AS);
|
| }
|
|
|
| boolean isSrcDownloadableScheme = UrlUtilities.isDownloadableScheme(params.getSrcUrl());
|
| if (params.isVideo()) {
|
| boolean saveableAndDownloadable = params.canSaveMedia() && isSrcDownloadableScheme;
|
| if (!saveableAndDownloadable) {
|
| - disabledOptions.add(R.id.contextmenu_save_video);
|
| + disabledOptions.add(ContextMenuItem.SAVE_VIDEO);
|
| }
|
| } else if (params.isImage() && params.imageWasFetchedLoFi()) {
|
| DataReductionProxyUma.previewsLoFiContextMenuAction(
|
| DataReductionProxyUma.ACTION_LOFI_LOAD_IMAGE_CONTEXT_MENU_SHOWN);
|
| // All image context menu items other than "Load image," "Open original image in
|
| // new tab," and "Copy image URL" should be disabled on Lo-Fi images.
|
| - disabledOptions.add(R.id.contextmenu_save_image);
|
| - disabledOptions.add(R.id.contextmenu_open_image);
|
| - disabledOptions.add(R.id.contextmenu_search_by_image);
|
| - disabledOptions.add(R.id.contextmenu_share_image);
|
| + disabledOptions.add(ContextMenuItem.SAVE_IMAGE);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IMAGE);
|
| + disabledOptions.add(ContextMenuItem.SEARCH_BY_IMAGE);
|
| + disabledOptions.add(ContextMenuItem.SHARE_IMAGE);
|
| } else if (params.isImage() && !params.imageWasFetchedLoFi()) {
|
| - disabledOptions.add(R.id.contextmenu_load_original_image);
|
| + disabledOptions.add(ContextMenuItem.LOAD_ORIGINAL_IMAGE);
|
|
|
| if (!isSrcDownloadableScheme) {
|
| - disabledOptions.add(R.id.contextmenu_save_image);
|
| + disabledOptions.add(ContextMenuItem.SAVE_IMAGE);
|
| }
|
|
|
| // Avoid showing open image option for same image which is already opened.
|
| if (mDelegate.getPageUrl().equals(params.getSrcUrl())) {
|
| - disabledOptions.add(R.id.contextmenu_open_image);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IMAGE);
|
| }
|
| final TemplateUrlService templateUrlServiceInstance = TemplateUrlService.getInstance();
|
| final boolean isSearchByImageAvailable = isSrcDownloadableScheme
|
| @@ -321,26 +447,26 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
| && templateUrlServiceInstance.getDefaultSearchEngineTemplateUrl() != null;
|
|
|
| if (!isSearchByImageAvailable) {
|
| - disabledOptions.add(R.id.contextmenu_search_by_image);
|
| + disabledOptions.add(ContextMenuItem.SEARCH_BY_IMAGE);
|
| }
|
| }
|
|
|
| // Hide all items that could spawn additional tabs until FRE has been completed.
|
| if (!FirstRunStatus.getFirstRunFlowComplete()) {
|
| - disabledOptions.add(R.id.contextmenu_open_image_in_new_tab);
|
| - disabledOptions.add(R.id.contextmenu_open_in_other_window);
|
| - disabledOptions.add(R.id.contextmenu_open_in_new_tab);
|
| - disabledOptions.add(R.id.contextmenu_open_in_incognito_tab);
|
| - disabledOptions.add(R.id.contextmenu_search_by_image);
|
| - disabledOptions.add(R.id.menu_id_open_in_chrome);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IMAGE_IN_NEW_TAB);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_OTHER_WINDOW);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_NEW_TAB);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_INCOGNITO_TAB);
|
| + disabledOptions.add(ContextMenuItem.SEARCH_BY_IMAGE);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_CHROME);
|
| }
|
|
|
| if (mMode == CUSTOM_TAB_MODE) {
|
| if (ChromePreferenceManager.getInstance().getCachedChromeDefaultBrowser()) {
|
| - disabledOptions.add(R.id.contextmenu_open_in_browser_id);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_BROWSER_ID);
|
| } else {
|
| - disabledOptions.add(R.id.contextmenu_open_in_new_chrome_tab);
|
| - disabledOptions.add(R.id.contextmenu_open_in_chrome_incognito_tab);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_NEW_CHROME_TAB);
|
| + disabledOptions.add(ContextMenuItem.OPEN_IN_CHROME_INCOGNITO_TAB);
|
| }
|
| }
|
|
|
| @@ -456,9 +582,4 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
| return params.getLinkUrl();
|
| }
|
| }
|
| -
|
| - private void setHeaderText(Context context, ContextMenu menu, String text) {
|
| - ContextMenuTitleView title = new ContextMenuTitleView(context, text);
|
| - menu.setHeaderView(title);
|
| - }
|
| }
|
|
|