| OLD | NEW |
| 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 Loading... |
| 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. |
| 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 |
| OLD | NEW |