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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java

Issue 2725473002: [Android] 'Open in new Chrome (incognito) tab under context menu does not work for images and videos (Closed)
Patch Set: Update base on Yusuf's comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuParams.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8ab7675e978e3bf3aeaf49704012d48fda65adb9..5352ed1ad824e045a1fb6529adb4db81915e9f27 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
@@ -187,6 +187,8 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
setHeaderText(context, menu, params.getTitleText());
}
+ if (params.isFile()) return;
+
if (mMenuInflater == null) mMenuInflater = new MenuInflater(context);
mMenuInflater.inflate(R.menu.chrome_context_menu, menu);
@@ -430,9 +432,9 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
} else if (itemId == R.id.menu_id_open_in_chrome) {
mDelegate.onOpenInChrome(params.getLinkUrl(), params.getPageUrl());
} else if (itemId == R.id.contextmenu_open_in_new_chrome_tab) {
- mDelegate.onOpenInNewChromeTabFromCCT(params.getLinkUrl(), false);
+ mDelegate.onOpenInNewChromeTabFromCCT(getUrl(params), false);
} else if (itemId == R.id.contextmenu_open_in_chrome_incognito_tab) {
- mDelegate.onOpenInNewChromeTabFromCCT(params.getLinkUrl(), true);
+ mDelegate.onOpenInNewChromeTabFromCCT(getUrl(params), true);
} else if (itemId == R.id.contextmenu_open_in_browser_id) {
mDelegate.onOpenInDefaultBrowser(params.getLinkUrl());
} else {
@@ -442,6 +444,19 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
return true;
}
+ /**
+ * The valid url of a link is stored in the linkUrl of ContextMenuParams while the
+ * valid url of a image or video is stored in the srcUrl of ContextMenuParams.
+ * @param params The parameters used to decide the type of the content.
+ */
+ private String getUrl(ContextMenuParams params) {
+ if (params.isImage() || params.isVideo()) {
+ return params.getSrcUrl();
+ } else {
+ return params.getLinkUrl();
+ }
+ }
+
private void setHeaderText(Context context, ContextMenu menu, String text) {
ContextMenuTitleView title = new ContextMenuTitleView(context, text);
menu.setHeaderView(title);
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuParams.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698