| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/tab_state.h" | 5 #include "chrome/browser/android/tab_state.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/pickle.h" | 16 #include "base/pickle.h" |
| 17 #include "chrome/browser/android/tab_android.h" | 17 #include "chrome/browser/android/tab_android.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/common/url_constants.h" |
| 20 #include "components/sessions/content/content_serialized_navigation_builder.h" | 21 #include "components/sessions/content/content_serialized_navigation_builder.h" |
| 21 #include "components/sessions/serialized_navigation_entry.h" | 22 #include "components/sessions/serialized_navigation_entry.h" |
| 22 #include "components/sessions/session_command.h" | 23 #include "components/sessions/session_command.h" |
| 23 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/common/url_constants.h" |
| 26 #include "jni/TabState_jni.h" | 28 #include "jni/TabState_jni.h" |
| 27 | 29 |
| 28 using base::android::ConvertUTF16ToJavaString; | 30 using base::android::ConvertUTF16ToJavaString; |
| 29 using base::android::ConvertUTF8ToJavaString; | 31 using base::android::ConvertUTF8ToJavaString; |
| 30 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
| 31 using content::NavigationController; | 33 using content::NavigationController; |
| 32 using content::WebContents; | 34 using content::WebContents; |
| 33 | 35 |
| 34 namespace { | 36 namespace { |
| 35 | 37 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 jobject state, | 546 jobject state, |
| 545 jint saved_state_version) { | 547 jint saved_state_version) { |
| 546 void* data = env->GetDirectBufferAddress(state); | 548 void* data = env->GetDirectBufferAddress(state); |
| 547 int size = env->GetDirectBufferCapacity(state); | 549 int size = env->GetDirectBufferCapacity(state); |
| 548 ScopedJavaLocalRef<jstring> result = | 550 ScopedJavaLocalRef<jstring> result = |
| 549 WebContentsState::GetVirtualUrlFromByteBuffer( | 551 WebContentsState::GetVirtualUrlFromByteBuffer( |
| 550 env, data, size, saved_state_version); | 552 env, data, size, saved_state_version); |
| 551 return result.Release(); | 553 return result.Release(); |
| 552 } | 554 } |
| 553 | 555 |
| 556 // Creates a historical tab entry from the serialized tab contents contained |
| 557 // within |state|. |
| 558 static void CreateHistoricalTab(JNIEnv* env, |
| 559 jclass clazz, |
| 560 jobject state, |
| 561 jint saved_state_version) { |
| 562 scoped_ptr<WebContents> web_contents( |
| 563 WebContentsState::RestoreContentsFromByteBuffer(env, |
| 564 clazz, |
| 565 state, |
| 566 saved_state_version, |
| 567 true)); |
| 568 if (web_contents.get()) |
| 569 TabAndroid::CreateHistoricalTabFromContents(web_contents.get()); |
| 570 } |
| 571 |
| 554 bool RegisterTabState(JNIEnv* env) { | 572 bool RegisterTabState(JNIEnv* env) { |
| 555 return RegisterNativesImpl(env); | 573 return RegisterNativesImpl(env); |
| 556 } | 574 } |
| OLD | NEW |