OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
7 #include "chrome/browser/ui/android/tab_model/android_live_tab_context.h" | 7 #include "chrome/browser/ui/android/tab_model/android_live_tab_context.h" |
8 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 8 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
9 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 9 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
10 #include "components/sessions/content/content_live_tab.h" | 10 #include "components/sessions/content/content_live_tab.h" |
11 #include "components/sessions/content/content_serialized_navigation_builder.h" | 11 #include "components/sessions/content/content_serialized_navigation_builder.h" |
12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
| 14 #include "content/public/browser/restore_type.h" |
14 | 15 |
15 AndroidLiveTabContext::AndroidLiveTabContext(TabModel* tab_model) | 16 AndroidLiveTabContext::AndroidLiveTabContext(TabModel* tab_model) |
16 : tab_model_(tab_model) {} | 17 : tab_model_(tab_model) {} |
17 | 18 |
18 // Called in tab restore service, but expected to do nothing on Android. | 19 // Called in tab restore service, but expected to do nothing on Android. |
19 void AndroidLiveTabContext::ShowBrowserWindow() { | 20 void AndroidLiveTabContext::ShowBrowserWindow() { |
20 } | 21 } |
21 | 22 |
22 const SessionID& AndroidLiveTabContext::GetSessionID() const { | 23 const SessionID& AndroidLiveTabContext::GetSessionID() const { |
23 return tab_model_->SessionId(); | 24 return tab_model_->SessionId(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 73 |
73 // Prepare navigation history. | 74 // Prepare navigation history. |
74 std::vector<std::unique_ptr<content::NavigationEntry>> nav_entries = | 75 std::vector<std::unique_ptr<content::NavigationEntry>> nav_entries = |
75 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( | 76 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( |
76 navigations, profile); | 77 navigations, profile); |
77 | 78 |
78 // Restore web contents with navigation history. | 79 // Restore web contents with navigation history. |
79 content::WebContents* web_contents = content::WebContents::Create( | 80 content::WebContents* web_contents = content::WebContents::Create( |
80 content::WebContents::CreateParams(profile)); | 81 content::WebContents::CreateParams(profile)); |
81 web_contents->GetController().Restore( | 82 web_contents->GetController().Restore( |
82 selected_navigation, | 83 selected_navigation, content::RestoreType::CURRENT_SESSION, &nav_entries); |
83 content::NavigationController::RESTORE_CURRENT_SESSION, | |
84 &nav_entries); | |
85 | 84 |
86 // Create new tab. | 85 // Create new tab. |
87 tab_model_->CreateTab(nullptr, web_contents, -1); | 86 tab_model_->CreateTab(nullptr, web_contents, -1); |
88 return sessions::ContentLiveTab::GetForWebContents(web_contents); | 87 return sessions::ContentLiveTab::GetForWebContents(web_contents); |
89 } | 88 } |
90 | 89 |
91 // Currently does nothing. | 90 // Currently does nothing. |
92 sessions::LiveTab* AndroidLiveTabContext::ReplaceRestoredTab( | 91 sessions::LiveTab* AndroidLiveTabContext::ReplaceRestoredTab( |
93 const std::vector<sessions::SerializedNavigationEntry>& navigations, | 92 const std::vector<sessions::SerializedNavigationEntry>& navigations, |
94 int selected_navigation, | 93 int selected_navigation, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 for (auto it = TabModelList::begin(); it != TabModelList::end(); ++it) { | 128 for (auto it = TabModelList::begin(); it != TabModelList::end(); ++it) { |
130 TabModel* model = *it; | 129 TabModel* model = *it; |
131 if (!model->IsOffTheRecord()) { | 130 if (!model->IsOffTheRecord()) { |
132 return model->GetLiveTabContext(); | 131 return model->GetLiveTabContext(); |
133 } | 132 } |
134 } | 133 } |
135 } | 134 } |
136 | 135 |
137 return tab_model ? tab_model->GetLiveTabContext() : nullptr; | 136 return tab_model ? tab_model->GetLiveTabContext() : nullptr; |
138 } | 137 } |
OLD | NEW |