Commit b44a546b authored by qinmin's avatar qinmin Committed by Commit bot

Fix OMA download through context menu

For OMA downloads, chrome doesn't handle it correctly as the file needs to be converted to a .fl file and encrypted on the device.
The android DownloadManager provides such covertion.
As a result, we need to provide a way for us to intercept certain OMA downloads

BUG=382698

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

Cr-Commit-Position: refs/heads/master@{#294676}
parent 7eff2e4b
...@@ -31,10 +31,11 @@ public interface ChromeContextMenuItemDelegate { ...@@ -31,10 +31,11 @@ public interface ChromeContextMenuItemDelegate {
/** /**
* Called when the context menu is trying to start a download. * Called when the context menu is trying to start a download.
* @param url Url of the download item.
* @param isLink Whether or not the download is a link (as opposed to an image/video). * @param isLink Whether or not the download is a link (as opposed to an image/video).
* @return Whether or not a download should actually be started. * @return Whether or not a download should actually be started.
*/ */
boolean startDownload(boolean isLink); boolean startDownload(String url, boolean isLink);
/** /**
* Called when the {@code url} should be opened in a new tab with the same incognito state as * Called when the {@code url} should be opened in a new tab with the same incognito state as
......
...@@ -115,9 +115,13 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator { ...@@ -115,9 +115,13 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
mDelegate.onSaveToClipboard(params.getLinkText(), false); mDelegate.onSaveToClipboard(params.getLinkText(), false);
} else if (itemId == R.id.contextmenu_save_image || } else if (itemId == R.id.contextmenu_save_image ||
itemId == R.id.contextmenu_save_video) { itemId == R.id.contextmenu_save_video) {
if (mDelegate.startDownload(false)) helper.startContextMenuDownload(false); if (mDelegate.startDownload(params.getSrcUrl(), false)) {
helper.startContextMenuDownload(false);
}
} else if (itemId == R.id.contextmenu_save_link_as) { } else if (itemId == R.id.contextmenu_save_link_as) {
if (mDelegate.startDownload(true)) helper.startContextMenuDownload(true); if (mDelegate.startDownload(params.getUnfilteredLinkUrl(), true)) {
helper.startContextMenuDownload(true);
}
} else if (itemId == R.id.contextmenu_search_by_image) { } else if (itemId == R.id.contextmenu_search_by_image) {
mDelegate.onSearchByImageInNewTab(); mDelegate.onSearchByImageInNewTab();
} else if (itemId == R.id.contextmenu_copy_image) { } else if (itemId == R.id.contextmenu_copy_image) {
......
...@@ -27,7 +27,7 @@ public class EmptyChromeContextMenuItemDelegate implements ChromeContextMenuItem ...@@ -27,7 +27,7 @@ public class EmptyChromeContextMenuItemDelegate implements ChromeContextMenuItem
} }
@Override @Override
public boolean startDownload(boolean isLink) { public boolean startDownload(String url, boolean isLink) {
return false; return false;
} }
......
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