| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
| 10 #include "android_webview/browser/aw_browser_main_parts.h" | 10 #include "android_webview/browser/aw_browser_main_parts.h" |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 839 } |
| 840 | 840 |
| 841 base::android::ScopedJavaLocalRef<jbyteArray> | 841 base::android::ScopedJavaLocalRef<jbyteArray> |
| 842 AwContents::GetOpaqueState(JNIEnv* env, jobject obj) { | 842 AwContents::GetOpaqueState(JNIEnv* env, jobject obj) { |
| 843 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 843 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 844 // Required optimization in WebViewClassic to not save any state if | 844 // Required optimization in WebViewClassic to not save any state if |
| 845 // there has been no navigations. | 845 // there has been no navigations. |
| 846 if (!web_contents_->GetController().GetEntryCount()) | 846 if (!web_contents_->GetController().GetEntryCount()) |
| 847 return ScopedJavaLocalRef<jbyteArray>(); | 847 return ScopedJavaLocalRef<jbyteArray>(); |
| 848 | 848 |
| 849 Pickle pickle; | 849 base::Pickle pickle; |
| 850 if (!WriteToPickle(*web_contents_, &pickle)) { | 850 if (!WriteToPickle(*web_contents_, &pickle)) { |
| 851 return ScopedJavaLocalRef<jbyteArray>(); | 851 return ScopedJavaLocalRef<jbyteArray>(); |
| 852 } else { | 852 } else { |
| 853 return base::android::ToJavaByteArray(env, | 853 return base::android::ToJavaByteArray(env, |
| 854 reinterpret_cast<const uint8*>(pickle.data()), pickle.size()); | 854 reinterpret_cast<const uint8*>(pickle.data()), pickle.size()); |
| 855 } | 855 } |
| 856 } | 856 } |
| 857 | 857 |
| 858 jboolean AwContents::RestoreFromOpaqueState( | 858 jboolean AwContents::RestoreFromOpaqueState( |
| 859 JNIEnv* env, jobject obj, jbyteArray state) { | 859 JNIEnv* env, jobject obj, jbyteArray state) { |
| 860 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 860 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 861 // TODO(boliu): This copy can be optimized out if this is a performance | 861 // TODO(boliu): This copy can be optimized out if this is a performance |
| 862 // problem. | 862 // problem. |
| 863 std::vector<uint8> state_vector; | 863 std::vector<uint8> state_vector; |
| 864 base::android::JavaByteArrayToByteVector(env, state, &state_vector); | 864 base::android::JavaByteArrayToByteVector(env, state, &state_vector); |
| 865 | 865 |
| 866 Pickle pickle(reinterpret_cast<const char*>(state_vector.data()), | 866 base::Pickle pickle(reinterpret_cast<const char*>(state_vector.data()), |
| 867 state_vector.size()); | 867 state_vector.size()); |
| 868 PickleIterator iterator(pickle); | 868 base::PickleIterator iterator(pickle); |
| 869 | 869 |
| 870 return RestoreFromPickle(&iterator, web_contents_.get()); | 870 return RestoreFromPickle(&iterator, web_contents_.get()); |
| 871 } | 871 } |
| 872 | 872 |
| 873 bool AwContents::OnDraw(JNIEnv* env, | 873 bool AwContents::OnDraw(JNIEnv* env, |
| 874 jobject obj, | 874 jobject obj, |
| 875 jobject canvas, | 875 jobject canvas, |
| 876 jboolean is_hardware_accelerated, | 876 jboolean is_hardware_accelerated, |
| 877 jint scroll_x, | 877 jint scroll_x, |
| 878 jint scroll_y, | 878 jint scroll_y, |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 | 1163 |
| 1164 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env, ports, | 1164 AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env, ports, |
| 1165 GetMessagePortMessageFilter()); | 1165 GetMessagePortMessageFilter()); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { | 1168 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { |
| 1169 g_should_download_favicons = true; | 1169 g_should_download_favicons = true; |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 } // namespace android_webview | 1172 } // namespace android_webview |
| OLD | NEW |