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 "components/sessions/content/content_serialized_navigation_builder.h" | 20 #include "components/sessions/content/content_serialized_navigation_builder.h" |
21 #include "components/sessions/core/serialized_navigation_entry.h" | 21 #include "components/sessions/core/serialized_navigation_entry.h" |
22 #include "components/sessions/core/session_command.h" | 22 #include "components/sessions/core/session_command.h" |
23 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
24 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/browser/web_contents_source.h" |
26 #include "jni/TabState_jni.h" | 27 #include "jni/TabState_jni.h" |
27 | 28 |
28 using base::android::ConvertUTF16ToJavaString; | 29 using base::android::ConvertUTF16ToJavaString; |
29 using base::android::ConvertUTF8ToJavaString; | 30 using base::android::ConvertUTF8ToJavaString; |
30 using base::android::ScopedJavaLocalRef; | 31 using base::android::ScopedJavaLocalRef; |
31 using content::NavigationController; | 32 using content::NavigationController; |
32 using content::WebContents; | 33 using content::WebContents; |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 Profile* profile = ProfileManager::GetActiveUserProfile(); | 429 Profile* profile = ProfileManager::GetActiveUserProfile(); |
429 ScopedVector<content::NavigationEntry> scoped_entries = | 430 ScopedVector<content::NavigationEntry> scoped_entries = |
430 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( | 431 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( |
431 navigations, profile); | 432 navigations, profile); |
432 | 433 |
433 if (is_off_the_record) | 434 if (is_off_the_record) |
434 profile = profile->GetOffTheRecordProfile(); | 435 profile = profile->GetOffTheRecordProfile(); |
435 WebContents::CreateParams params(profile); | 436 WebContents::CreateParams params(profile); |
436 params.initially_hidden = initially_hidden; | 437 params.initially_hidden = initially_hidden; |
437 scoped_ptr<WebContents> web_contents(WebContents::Create(params)); | 438 scoped_ptr<WebContents> web_contents(WebContents::Create(params)); |
| 439 WebContentsSource::CreateForWebContentsAndLocation(web_contents.get(), |
| 440 FROM_HERE); |
438 web_contents->GetController().Restore( | 441 web_contents->GetController().Restore( |
439 current_entry_index, | 442 current_entry_index, |
440 NavigationController::RESTORE_CURRENT_SESSION, | 443 NavigationController::RESTORE_CURRENT_SESSION, |
441 &scoped_entries); | 444 &scoped_entries); |
442 return web_contents.release(); | 445 return web_contents.release(); |
443 } | 446 } |
444 | 447 |
445 ScopedJavaLocalRef<jobject> WebContentsState::RestoreContentsFromByteBuffer( | 448 ScopedJavaLocalRef<jobject> WebContentsState::RestoreContentsFromByteBuffer( |
446 JNIEnv* env, | 449 JNIEnv* env, |
447 jclass clazz, | 450 jclass clazz, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 WebContentsState::RestoreContentsFromByteBuffer(env, clazz, state, | 575 WebContentsState::RestoreContentsFromByteBuffer(env, clazz, state, |
573 saved_state_version, true) | 576 saved_state_version, true) |
574 .obj())); | 577 .obj())); |
575 if (web_contents.get()) | 578 if (web_contents.get()) |
576 TabAndroid::CreateHistoricalTabFromContents(web_contents.get()); | 579 TabAndroid::CreateHistoricalTabFromContents(web_contents.get()); |
577 } | 580 } |
578 | 581 |
579 bool RegisterTabState(JNIEnv* env) { | 582 bool RegisterTabState(JNIEnv* env) { |
580 return RegisterNativesImpl(env); | 583 return RegisterNativesImpl(env); |
581 } | 584 } |
OLD | NEW |