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

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: rebasing 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 ed57b76577d27c97529a4f52165d1f168e8b9643..21ff021081d3929f8f00b9b8cdebf5ed8339d94a 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
@@ -18,12 +18,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.ImageDownloadCallback;
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;
/**
@@ -469,6 +472,39 @@ import java.util.UUID;
nativeReloadLoFiImages(mNativeWebContentsAndroid);
}
+ @Override
+ public void downloadImage(String url, boolean isFavicon, int maxBitmapSize,
Ted C 2016/06/03 16:44:09 let's return the id here to match the native signa
Zhiqiang Zhang (Slow) 2016/06/03 18:53:51 Done.
+ boolean bypassCache, ImageDownloadCallback callback) {
Ted C 2016/06/03 16:44:09 indent 8 from the start of the previous line
Zhiqiang Zhang (Slow) 2016/06/03 18:53:51 Done.
+ nativeDownloadImage(mNativeWebContentsAndroid,
+ url, isFavicon, maxBitmapSize, bypassCache, callback);
+ }
+
+ @CalledByNative
+ private void onDownloadImageFinished(ImageDownloadCallback 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 createSizeAndAddToList(List<Rect> sizes, int width, int height) {
+ sizes.add(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);
@@ -530,4 +566,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, ImageDownloadCallback callback);
}

Powered by Google App Engine
This is Rietveld 408576698