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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 11823027: [Android WebView] Implement the capture picture API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding findbugs update from 11825002 to make the trybots happy. Created 7 years, 11 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: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 27038d6798e536d1ea791b897a76ef8b924ee27e..af275cb3ab341dc5af1c6c256605fa5a9520e3bb 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -8,6 +8,7 @@ import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Picture;
import android.graphics.Rect;
import android.net.http.SslCertificate;
import android.os.AsyncTask;
@@ -23,6 +24,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.webkit.ValueCallback;
+import org.chromium.android_webview.AwContentsClient; // Required for correct JNI generation.
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
@@ -90,6 +92,9 @@ public class AwContents {
// Must call nativeUpdateLastHitTestData first to update this before use.
private final HitTestData mPossiblyStaleHitTestData;
+ // Instance to be reused across new pictures.
+ private final AwContentsClient.ExternalPictureData mExternalPictureData;
joth 2013/01/10 01:45:39 rather than final I'd be OK lazy initializing this
Leandro Graciá Gil 2013/01/10 18:58:13 Not required any longer. On 2013/01/10 01:45:39,
+
private static final class DestroyRunnable implements Runnable {
private int mNativeAwContents;
private DestroyRunnable(int nativeAwContents) {
@@ -298,6 +303,7 @@ public class AwContents {
setInterceptNavigationDelegate(new InterceptNavigationDelegateImpl());
mPossiblyStaleHitTestData = new HitTestData();
+ mExternalPictureData = new AwContentsClient.ExternalPictureData();
nativeDidInitializeContentViewCore(mNativeAwContents,
mContentViewCore.getNativeContentViewCore());
}
@@ -361,6 +367,20 @@ public class AwContents {
}
}
+ public AwContentsClient.ExternalPictureData capturePicture() {
+ nativeCapturePicture(mNativeAwContents, mExternalPictureData);
+ return mExternalPictureData;
+ }
+
+ /**
+ * Enable the OnNewPicture callback.
+ * @param enabled Flag to enable the callback.
+ * @param invalidationOnly Flag to call back only on invalidation without providing a picture.
+ */
+ public void enableOnNewPicture(boolean enabled, boolean invalidationOnly) {
+ nativeEnableOnNewPicture(mNativeAwContents, enabled, invalidationOnly);
+ }
+
public int findAllSync(String searchString) {
if (mNativeAwContents == 0) return 0;
return nativeFindAllSync(mNativeAwContents, searchString);
@@ -837,6 +857,14 @@ public class AwContents {
mContentsClient.onFindResultReceived(activeMatchOrdinal, numberOfMatches, isDoneCounting);
}
+ @CalledByNative
+ public void onNewPicture(int nativePicture, int width, int height) {
+ mExternalPictureData.nativePicture = nativePicture;
+ mExternalPictureData.width = width;
+ mExternalPictureData.height = height;
joth 2013/01/10 01:45:39 you shouldn't need the find bugs suppression as yo
Leandro Graciá Gil 2013/01/10 18:58:13 Actually, this was replacing the old bugs with new
+ mContentsClient.onNewPicture(mExternalPictureData);
+ }
+
// Called as a result of nativeUpdateLastHitTestData.
@CalledByNative
private void updateHitTestData(
@@ -978,4 +1006,9 @@ public class AwContents {
private native int nativeReleasePopupWebContents(int nativeAwContents);
private native void nativeSetWebContents(int nativeAwContents, int nativeNewWebContents);
private native void nativeFocusFirstNode(int nativeAwContents);
+
+ private native void nativeCapturePicture(int nativeAwContents,
+ AwContentsClient.ExternalPictureData externalPicture);
+ private native void nativeEnableOnNewPicture(int nativeAwContents, boolean enabled,
+ boolean invalidationOnly);
}

Powered by Google App Engine
This is Rietveld 408576698