Context Menu "Open image" doesn't make sense in a Image URL Tab

When only image is opened then on long press context menu appears.
From context menu on selection of "open image" page reloads which
does not make sense.Added condition to hide option "open image"
if page url and image url for which context menu appears is same.

BUG=270682

Review URL: https://codereview.chromium.org/396063009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283534 0039d316-1c4b-4281-b951-d872f2087c98
parent 74ebe470
......@@ -168,6 +168,11 @@ public class Tab implements NavigationClient {
public void onSaveImageToClipboard(String url) {
mClipboard.setHTMLText("<img src=\"" + url + "\">", url, url);
}
@Override
public String getPageUrl() {
return getUrl();
}
}
/**
......
......@@ -79,4 +79,9 @@ public interface ChromeContextMenuItemDelegate {
* Called when a search by image should be performed in a new tab.
*/
void onSearchByImageInNewTab();
/**
* @return page url.
*/
String getPageUrl();
}
......@@ -75,6 +75,10 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
menu.findItem(R.id.contextmenu_open_original_image_in_new_tab).setVisible(false);
}
// Avoid showing open image option for same image which is already opened.
if (mDelegate.getPageUrl().equals(params.getSrcUrl())) {
menu.findItem(R.id.contextmenu_open_image).setVisible(false);
}
final TemplateUrlService templateUrlServiceInstance = TemplateUrlService.getInstance();
final boolean isSearchByImageAvailable =
UrlUtilities.isDownloadableScheme(params.getSrcUrl()) &&
......
......@@ -58,4 +58,9 @@ public class EmptyChromeContextMenuItemDelegate implements ChromeContextMenuItem
@Override
public void onSearchByImageInNewTab() {
}
@Override
public String getPageUrl() {
return "";
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment