OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/ui/browser_live_tab_context.h" | 5 #include "chrome/browser/ui/browser_live_tab_context.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/browser_tabrestore.h" | 10 #include "chrome/browser/ui/browser_tabrestore.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "components/sessions/content/content_live_tab.h" | 13 #include "components/sessions/content/content_live_tab.h" |
14 #include "components/sessions/content/content_platform_specific_tab_data.h" | 14 #include "components/sessions/content/content_platform_specific_tab_data.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/session_storage_namespace.h" | 16 #include "content/public/browser/session_storage_namespace.h" |
17 | 17 |
| 18 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 19 #include "chrome/browser/sessions/tab_loader.h" |
| 20 #endif |
| 21 |
18 using content::NavigationController; | 22 using content::NavigationController; |
19 using content::SessionStorageNamespace; | 23 using content::SessionStorageNamespace; |
20 using content::WebContents; | 24 using content::WebContents; |
21 | 25 |
22 void BrowserLiveTabContext::ShowBrowserWindow() { | 26 void BrowserLiveTabContext::ShowBrowserWindow() { |
23 browser_->window()->Show(); | 27 browser_->window()->Show(); |
24 } | 28 } |
25 | 29 |
26 const SessionID& BrowserLiveTabContext::GetSessionID() const { | 30 const SessionID& BrowserLiveTabContext::GetSessionID() const { |
27 return browser_->session_id(); | 31 return browser_->session_id(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 tab_platform_data | 71 tab_platform_data |
68 ? static_cast<const sessions::ContentPlatformSpecificTabData*>( | 72 ? static_cast<const sessions::ContentPlatformSpecificTabData*>( |
69 tab_platform_data) | 73 tab_platform_data) |
70 ->session_storage_namespace() | 74 ->session_storage_namespace() |
71 : nullptr; | 75 : nullptr; |
72 | 76 |
73 WebContents* web_contents = chrome::AddRestoredTab( | 77 WebContents* web_contents = chrome::AddRestoredTab( |
74 browser_, navigations, tab_index, selected_navigation, extension_app_id, | 78 browser_, navigations, tab_index, selected_navigation, extension_app_id, |
75 select, pin, from_last_session, storage_namespace, user_agent_override); | 79 select, pin, from_last_session, storage_namespace, user_agent_override); |
76 | 80 |
| 81 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 82 // The focused tab will be loaded by Browser, and TabLoader will load the |
| 83 // rest. |
| 84 if (!select) { |
| 85 // Regression check: make sure that the tab hasn't started to load |
| 86 // immediately. |
| 87 DCHECK(web_contents->GetController().NeedsReload()); |
| 88 DCHECK(!web_contents->IsLoading()); |
| 89 } |
| 90 std::vector<TabLoader::RestoredTab> restored_tabs; |
| 91 restored_tabs.emplace_back(web_contents, select, !extension_app_id.empty(), |
| 92 pin); |
| 93 TabLoader::RestoreTabs(restored_tabs, base::TimeTicks::Now()); |
| 94 #else // BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 95 // Load the tab manually if there is no TabLoader. |
| 96 web_contents->GetController().LoadIfNecessary(); |
| 97 #endif // BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 98 |
77 return sessions::ContentLiveTab::GetForWebContents(web_contents); | 99 return sessions::ContentLiveTab::GetForWebContents(web_contents); |
78 } | 100 } |
79 | 101 |
80 sessions::LiveTab* BrowserLiveTabContext::ReplaceRestoredTab( | 102 sessions::LiveTab* BrowserLiveTabContext::ReplaceRestoredTab( |
81 const std::vector<sessions::SerializedNavigationEntry>& navigations, | 103 const std::vector<sessions::SerializedNavigationEntry>& navigations, |
82 int selected_navigation, | 104 int selected_navigation, |
83 bool from_last_session, | 105 bool from_last_session, |
84 const std::string& extension_app_id, | 106 const std::string& extension_app_id, |
85 const sessions::PlatformSpecificTabData* tab_platform_data, | 107 const sessions::PlatformSpecificTabData* tab_platform_data, |
86 const std::string& user_agent_override) { | 108 const std::string& user_agent_override) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 148 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
127 return browser ? browser->live_tab_context() : nullptr; | 149 return browser ? browser->live_tab_context() : nullptr; |
128 } | 150 } |
129 | 151 |
130 // static | 152 // static |
131 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( | 153 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( |
132 SessionID::id_type desired_id) { | 154 SessionID::id_type desired_id) { |
133 Browser* browser = chrome::FindBrowserWithID(desired_id); | 155 Browser* browser = chrome::FindBrowserWithID(desired_id); |
134 return browser ? browser->live_tab_context() : nullptr; | 156 return browser ? browser->live_tab_context() : nullptr; |
135 } | 157 } |
OLD | NEW |