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/sessions/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (!tabs_to_load_.empty()) { | 270 if (!tabs_to_load_.empty()) { |
271 NavigationController* tab = tabs_to_load_.front(); | 271 NavigationController* tab = tabs_to_load_.front(); |
272 DCHECK(tab); | 272 DCHECK(tab); |
273 tabs_loading_.insert(tab); | 273 tabs_loading_.insert(tab); |
274 if (tabs_loading_.size() > max_parallel_tab_loads_) | 274 if (tabs_loading_.size() > max_parallel_tab_loads_) |
275 max_parallel_tab_loads_ = tabs_loading_.size(); | 275 max_parallel_tab_loads_ = tabs_loading_.size(); |
276 tabs_to_load_.pop_front(); | 276 tabs_to_load_.pop_front(); |
277 tab->LoadIfNecessary(); | 277 tab->LoadIfNecessary(); |
278 content::WebContents* contents = tab->GetWebContents(); | 278 content::WebContents* contents = tab->GetWebContents(); |
279 if (contents) { | 279 if (contents) { |
280 Browser* browser = browser::FindBrowserWithWebContents(contents); | 280 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
281 if (browser && chrome::GetActiveWebContents(browser) != contents) { | 281 if (browser && chrome::GetActiveWebContents(browser) != contents) { |
282 // By default tabs are marked as visible. As only the active tab is | 282 // By default tabs are marked as visible. As only the active tab is |
283 // visible we need to explicitly tell non-active tabs they are hidden. | 283 // visible we need to explicitly tell non-active tabs they are hidden. |
284 // Without this call non-active tabs are not marked as backgrounded. | 284 // Without this call non-active tabs are not marked as backgrounded. |
285 // | 285 // |
286 // NOTE: We need to do this here rather than when the tab is added to | 286 // NOTE: We need to do this here rather than when the tab is added to |
287 // the Browser as at that time not everything has been created, so that | 287 // the Browser as at that time not everything has been created, so that |
288 // the call would do nothing. | 288 // the call would do nothing. |
289 contents->WasHidden(); | 289 contents->WasHidden(); |
290 } | 290 } |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 SessionRestoreImpl restorer(profile, | 1166 SessionRestoreImpl restorer(profile, |
1167 static_cast<Browser*>(NULL), true, false, true, gurls); | 1167 static_cast<Browser*>(NULL), true, false, true, gurls); |
1168 restorer.RestoreForeignSession(begin, end); | 1168 restorer.RestoreForeignSession(begin, end); |
1169 } | 1169 } |
1170 | 1170 |
1171 // static | 1171 // static |
1172 void SessionRestore::RestoreForeignSessionTab( | 1172 void SessionRestore::RestoreForeignSessionTab( |
1173 content::WebContents* source_web_contents, | 1173 content::WebContents* source_web_contents, |
1174 const SessionTab& tab, | 1174 const SessionTab& tab, |
1175 WindowOpenDisposition disposition) { | 1175 WindowOpenDisposition disposition) { |
1176 Browser* browser = browser::FindBrowserWithWebContents(source_web_contents); | 1176 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents); |
1177 Profile* profile = browser->profile(); | 1177 Profile* profile = browser->profile(); |
1178 std::vector<GURL> gurls; | 1178 std::vector<GURL> gurls; |
1179 SessionRestoreImpl restorer(profile, browser, true, false, false, gurls); | 1179 SessionRestoreImpl restorer(profile, browser, true, false, false, gurls); |
1180 restorer.RestoreForeignTab(tab, disposition); | 1180 restorer.RestoreForeignTab(tab, disposition); |
1181 } | 1181 } |
1182 | 1182 |
1183 // static | 1183 // static |
1184 bool SessionRestore::IsRestoring(const Profile* profile) { | 1184 bool SessionRestore::IsRestoring(const Profile* profile) { |
1185 if (active_session_restorers == NULL) | 1185 if (active_session_restorers == NULL) |
1186 return false; | 1186 return false; |
1187 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1187 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1188 active_session_restorers->begin(); | 1188 active_session_restorers->begin(); |
1189 it != active_session_restorers->end(); ++it) { | 1189 it != active_session_restorers->end(); ++it) { |
1190 if ((*it)->profile() == profile) | 1190 if ((*it)->profile() == profile) |
1191 return true; | 1191 return true; |
1192 } | 1192 } |
1193 return false; | 1193 return false; |
1194 } | 1194 } |
OLD | NEW |