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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <limits> | 11 #include <limits> |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/android/jni_android.h" | 15 #include "base/android/jni_android.h" |
16 #include "base/android/jni_string.h" | 16 #include "base/android/jni_string.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
19 #include "base/pickle.h" | 19 #include "base/pickle.h" |
20 #include "chrome/browser/android/tab_android.h" | 20 #include "chrome/browser/android/tab_android.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "components/sessions/content/content_serialized_navigation_builder.h" | 23 #include "components/sessions/content/content_serialized_navigation_builder.h" |
24 #include "components/sessions/core/serialized_navigation_entry.h" | 24 #include "components/sessions/core/serialized_navigation_entry.h" |
25 #include "components/sessions/core/session_command.h" | 25 #include "components/sessions/core/session_command.h" |
26 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
27 #include "content/public/browser/navigation_entry.h" | 27 #include "content/public/browser/navigation_entry.h" |
| 28 #include "content/public/browser/restore_type.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "jni/TabState_jni.h" | 30 #include "jni/TabState_jni.h" |
30 | 31 |
31 using base::android::ConvertUTF16ToJavaString; | 32 using base::android::ConvertUTF16ToJavaString; |
32 using base::android::ConvertUTF8ToJavaString; | 33 using base::android::ConvertUTF8ToJavaString; |
33 using base::android::JavaParamRef; | 34 using base::android::JavaParamRef; |
34 using base::android::ScopedJavaLocalRef; | 35 using base::android::ScopedJavaLocalRef; |
35 using content::NavigationController; | 36 using content::NavigationController; |
36 using content::WebContents; | 37 using content::WebContents; |
37 | 38 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 std::vector<std::unique_ptr<content::NavigationEntry>> entries = | 434 std::vector<std::unique_ptr<content::NavigationEntry>> entries = |
434 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( | 435 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( |
435 navigations, profile); | 436 navigations, profile); |
436 | 437 |
437 if (is_off_the_record) | 438 if (is_off_the_record) |
438 profile = profile->GetOffTheRecordProfile(); | 439 profile = profile->GetOffTheRecordProfile(); |
439 WebContents::CreateParams params(profile); | 440 WebContents::CreateParams params(profile); |
440 params.initially_hidden = initially_hidden; | 441 params.initially_hidden = initially_hidden; |
441 std::unique_ptr<WebContents> web_contents(WebContents::Create(params)); | 442 std::unique_ptr<WebContents> web_contents(WebContents::Create(params)); |
442 web_contents->GetController().Restore( | 443 web_contents->GetController().Restore( |
443 current_entry_index, NavigationController::RESTORE_CURRENT_SESSION, | 444 current_entry_index, content::RestoreType::CURRENT_SESSION, &entries); |
444 &entries); | |
445 return web_contents.release(); | 445 return web_contents.release(); |
446 } | 446 } |
447 | 447 |
448 ScopedJavaLocalRef<jobject> WebContentsState::RestoreContentsFromByteBuffer( | 448 ScopedJavaLocalRef<jobject> WebContentsState::RestoreContentsFromByteBuffer( |
449 JNIEnv* env, | 449 JNIEnv* env, |
450 jclass clazz, | 450 jclass clazz, |
451 jobject state, | 451 jobject state, |
452 jint saved_state_version, | 452 jint saved_state_version, |
453 jboolean initially_hidden) { | 453 jboolean initially_hidden) { |
454 void* data = env->GetDirectBufferAddress(state); | 454 void* data = env->GetDirectBufferAddress(state); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 std::unique_ptr<WebContents> web_contents(WebContents::FromJavaWebContents( | 573 std::unique_ptr<WebContents> web_contents(WebContents::FromJavaWebContents( |
574 WebContentsState::RestoreContentsFromByteBuffer( | 574 WebContentsState::RestoreContentsFromByteBuffer( |
575 env, clazz, state, saved_state_version, true))); | 575 env, clazz, state, saved_state_version, true))); |
576 if (web_contents.get()) | 576 if (web_contents.get()) |
577 TabAndroid::CreateHistoricalTabFromContents(web_contents.get()); | 577 TabAndroid::CreateHistoricalTabFromContents(web_contents.get()); |
578 } | 578 } |
579 | 579 |
580 bool RegisterTabState(JNIEnv* env) { | 580 bool RegisterTabState(JNIEnv* env) { |
581 return RegisterNativesImpl(env); | 581 return RegisterNativesImpl(env); |
582 } | 582 } |
OLD | NEW |