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

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

Issue 11280064: Android WebView save/restoreState Part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename variable Created 8 years, 1 month 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 | android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d1060cf74f5dfdada4c8b92cc16b52459885648d..6ed7e262dd3f4709e4305da5ed3007f93694b302 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -626,6 +626,47 @@ public class AwContents {
}
+ /**
+ * Key for opaque state in bundle. Note this is only public for tests.
+ */
+ public static final String SAVE_RESTORE_STATE_KEY = "WEBVIEW_CHROMIUM_STATE";
+
+ /**
+ * Save the state of this AwContents into provided Bundle.
+ * @return False if saving state failed.
+ */
+ public boolean saveState(Bundle outState) {
+ if (outState == null) {
+ return false;
+ }
+
+ byte[] state = nativeGetOpaqueState(mNativeAwContents);
+ if (state == null) {
+ return false;
+ }
+
+ outState.putByteArray(SAVE_RESTORE_STATE_KEY, state);
+ return true;
+ }
+
+ /**
+ * Restore the state of this AwContents into provided Bundle.
+ * @param inState Must be a bundle returned by saveState.
+ * @return False if restoring state failed.
+ */
+ public boolean restoreState(Bundle inState) {
+ if (inState == null) {
+ return false;
+ }
+
+ byte[] state = inState.getByteArray(SAVE_RESTORE_STATE_KEY);
+ if (state == null) {
+ return false;
+ }
+
+ return nativeRestoreFromOpaqueState(mNativeAwContents, state);
+ }
+
//--------------------------------------------------------------------------------------------
// Methods called from native via JNI
//--------------------------------------------------------------------------------------------
@@ -773,4 +814,10 @@ public class AwContents {
boolean viewVisible);
private native void nativeOnAttachedToWindow(int nativeAwContents, int w, int h);
private native void nativeOnDetachedFromWindow(int nativeAwContents);
+
+ // Returns null if save state fails.
+ private native byte[] nativeGetOpaqueState(int nativeAwContents);
+
+ // Returns false if restore state fails.
+ private native boolean nativeRestoreFromOpaqueState(int nativeAwContents, byte[] state);
}
« no previous file with comments | « no previous file | android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698