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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java

Issue 2014553002: Implement WebContents.downloadImage() on Java side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
index 0300463191fad9a70cb7a570b5d9ee5728c95518..82dcdb2836d204bfde37fe9beb9f6cff5f585861 100644
--- a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
+++ b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java
@@ -19,12 +19,15 @@ import org.chromium.base.annotations.JNINamespace;
import org.chromium.content_public.browser.AccessibilitySnapshotCallback;
import org.chromium.content_public.browser.AccessibilitySnapshotNode;
import org.chromium.content_public.browser.ContentBitmapCallback;
+import org.chromium.content_public.browser.DownloadImageCallback;
import org.chromium.content_public.browser.JavaScriptCallback;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver;
import org.chromium.ui.accessibility.AXTextStyle;
+import java.util.ArrayList;
+import java.util.List;
import java.util.UUID;
/**
@@ -473,6 +476,44 @@ import java.util.UUID;
nativeReloadLoFiImages(mNativeWebContentsAndroid);
}
+ @Override
+ public void downloadImage(String url, boolean isFavicon, int maxBitmapSize,
+ boolean bypassCache, DownloadImageCallback callback) {
+ nativeDownloadImage(mNativeWebContentsAndroid,
+ url, isFavicon, maxBitmapSize, bypassCache, callback);
+ }
+
+ @CalledByNative
+ private void onDownloadImageFinished(DownloadImageCallback callback, int id, int httpStatusCode,
+ String imageUrl, List<Bitmap> bitmaps, List<Rect> sizes) {
+ callback.onFinishDownloadImage(id, httpStatusCode, imageUrl, bitmaps, sizes);
+ }
+
+ @CalledByNative
+ private static List<Bitmap> createBitmapList() {
+ return new ArrayList<Bitmap>();
+ }
+
+ @CalledByNative
+ private static void addToBitmapList(List<Bitmap> bitmaps, Bitmap bitmap) {
+ bitmaps.add(bitmap);
+ }
+
+ @CalledByNative
+ private static List<Rect> createSizeList() {
+ return new ArrayList<Rect>();
+ }
+
+ @CalledByNative
+ private static void addToSizeList(List<Rect> sizes, Rect size) {
+ sizes.add(size);
+ }
+
+ @CalledByNative
+ private static Rect createSize(int width, int height) {
+ return new Rect(0, 0, width, height);
+ }
+
// This is static to avoid exposing a public destroy method on the native side of this class.
private static native void nativeDestroyWebContents(long webContentsAndroidPtr);
@@ -534,4 +575,7 @@ import java.util.UUID;
float x, float y, float width, float height);
private native void nativeOnContextMenuClosed(long nativeWebContentsAndroid);
private native void nativeReloadLoFiImages(long nativeWebContentsAndroid);
+ private native void nativeDownloadImage(long nativeWebContentsAndroid,
+ String url, boolean isFavicon, int maxBitmapSize,
+ boolean bypassCache, DownloadImageCallback callback);
}

Powered by Google App Engine
This is Rietveld 408576698