Chromium Code Reviews| Index: android_webview/native/aw_contents.cc |
| diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc |
| index b3d5203149d69c67b790f120f1db17f4fab4b7fd..9deca3867ead08704f10b9c358c192fc875ac53e 100644 |
| --- a/android_webview/native/aw_contents.cc |
| +++ b/android_webview/native/aw_contents.cc |
| @@ -11,11 +11,13 @@ |
| #include "android_webview/native/aw_browser_dependency_factory.h" |
| #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
| #include "android_webview/native/aw_web_contents_delegate.h" |
| +#include "android_webview/native/state_serializer.h" |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_array.h" |
| #include "base/android/jni_string.h" |
| #include "base/bind.h" |
| #include "base/callback.h" |
| +#include "base/pickle.h" |
| #include "base/supports_user_data.h" |
| #include "content/components/navigation_interception/intercept_navigation_delegate.h" |
| #include "content/public/browser/android/content_view_core.h" |
| @@ -457,4 +459,29 @@ void AwContents::OnDetachedFromWindow(JNIEnv* env, jobject obj) { |
| // TODO(joth): Request a DrawGL (kModeProcess) call, to tell the compositor. |
| } |
| +base::android::ScopedJavaLocalRef<jbyteArray> |
| +AwContents::GetOpaqueState(JNIEnv* env, jobject obj) { |
| + Pickle pickle; |
| + if (!WriteToPickle(*web_contents_, &pickle)) { |
| + return ScopedJavaLocalRef<jbyteArray>(); |
| + } else { |
| + return base::android::ToJavaByteArray(env, |
| + reinterpret_cast<const uint8*>(pickle.data()), pickle.size()); |
| + } |
| +} |
| + |
| +jboolean AwContents::RestoreFromOpaqueState( |
| + JNIEnv* env, jobject obj, jbyteArray state) { |
| + // TODO(boliu): This copy can be optimized out if this is a performance |
| + // problem. |
|
joth
2012/11/21 00:56:14
yeah guess this one's not too hard - just need to
boliu
2012/11/21 01:22:03
If I'm reading the jni docs correctly, GetByteArra
|
| + std::vector<uint8> state_vector; |
| + base::android::JavaByteArrayToByteVector(env, state, &state_vector); |
| + |
| + Pickle pickle(reinterpret_cast<const char*>(state_vector.begin()), |
| + state_vector.size()); |
| + PickleIterator iterator(pickle); |
| + |
| + return RestoreFromPickle(&iterator, web_contents_.get()); |
| +} |
| + |
| } // namespace android_webview |