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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 11280064: Android WebView save/restoreState Part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo in comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include "android_webview/browser/aw_browser_main_parts.h" 7 #include "android_webview/browser/aw_browser_main_parts.h"
8 #include "android_webview/browser/net_disk_cache_remover.h" 8 #include "android_webview/browser/net_disk_cache_remover.h"
9 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 9 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
10 #include "android_webview/common/aw_hit_test_data.h" 10 #include "android_webview/common/aw_hit_test_data.h"
11 #include "android_webview/native/aw_browser_dependency_factory.h" 11 #include "android_webview/native/aw_browser_dependency_factory.h"
12 #include "android_webview/native/aw_contents_io_thread_client_impl.h" 12 #include "android_webview/native/aw_contents_io_thread_client_impl.h"
13 #include "android_webview/native/aw_web_contents_delegate.h" 13 #include "android_webview/native/aw_web_contents_delegate.h"
14 #include "android_webview/native/state_serializer.h"
14 #include "base/android/jni_android.h" 15 #include "base/android/jni_android.h"
15 #include "base/android/jni_array.h" 16 #include "base/android/jni_array.h"
16 #include "base/android/jni_string.h" 17 #include "base/android/jni_string.h"
17 #include "base/bind.h" 18 #include "base/bind.h"
18 #include "base/callback.h" 19 #include "base/callback.h"
20 #include "base/pickle.h"
19 #include "base/supports_user_data.h" 21 #include "base/supports_user_data.h"
20 #include "content/components/navigation_interception/intercept_navigation_delega te.h" 22 #include "content/components/navigation_interception/intercept_navigation_delega te.h"
21 #include "content/public/browser/android/content_view_core.h" 23 #include "content/public/browser/android/content_view_core.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/cert_store.h" 25 #include "content/public/browser/cert_store.h"
24 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
26 #include "content/public/common/ssl_status.h" 28 #include "content/public/common/ssl_status.h"
27 #include "jni/AwContents_jni.h" 29 #include "jni/AwContents_jni.h"
28 #include "net/base/x509_certificate.h" 30 #include "net/base/x509_certificate.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // passed here are the Java view size, NOT window size (which correctly maps 452 // passed here are the Java view size, NOT window size (which correctly maps
451 // to the Compositor's "window" size). 453 // to the Compositor's "window" size).
452 compositor_->SetWindowBounds(gfx::Size(w, h)); 454 compositor_->SetWindowBounds(gfx::Size(w, h));
453 } 455 }
454 456
455 void AwContents::OnDetachedFromWindow(JNIEnv* env, jobject obj) { 457 void AwContents::OnDetachedFromWindow(JNIEnv* env, jobject obj) {
456 view_visible_ = false; 458 view_visible_ = false;
457 // TODO(joth): Request a DrawGL (kModeProcess) call, to tell the compositor. 459 // TODO(joth): Request a DrawGL (kModeProcess) call, to tell the compositor.
458 } 460 }
459 461
462 base::android::ScopedJavaLocalRef<jbyteArray>
463 AwContents::GetOpaqueState(JNIEnv* env, jobject obj) {
464 Pickle pickle;
465 if (!WriteToPickle(*web_contents_, &pickle)) {
466 return ScopedJavaLocalRef<jbyteArray>();
467 } else {
468 return base::android::ToJavaByteArray(env,
469 reinterpret_cast<const uint8*>(pickle.data()), pickle.size());
470 }
471 }
472
473 jboolean AwContents::RestoreFromOpaqueState(
474 JNIEnv* env, jobject obj, jbyteArray state) {
475 // TODO(boliu): This copy can be optimized out if this is a performance
476 // 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
477 std::vector<uint8> state_vector;
478 base::android::JavaByteArrayToByteVector(env, state, &state_vector);
479
480 Pickle pickle(reinterpret_cast<const char*>(state_vector.begin()),
481 state_vector.size());
482 PickleIterator iterator(pickle);
483
484 return RestoreFromPickle(&iterator, web_contents_.get());
485 }
486
460 } // namespace android_webview 487 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698