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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 void TabLoader::LoadNextTab() { | 260 void TabLoader::LoadNextTab() { |
261 if (!tabs_to_load_.empty()) { | 261 if (!tabs_to_load_.empty()) { |
262 NavigationController* tab = tabs_to_load_.front(); | 262 NavigationController* tab = tabs_to_load_.front(); |
263 DCHECK(tab); | 263 DCHECK(tab); |
264 tabs_loading_.insert(tab); | 264 tabs_loading_.insert(tab); |
265 if (tabs_loading_.size() > max_parallel_tab_loads_) | 265 if (tabs_loading_.size() > max_parallel_tab_loads_) |
266 max_parallel_tab_loads_ = tabs_loading_.size(); | 266 max_parallel_tab_loads_ = tabs_loading_.size(); |
267 tabs_to_load_.pop_front(); | 267 tabs_to_load_.pop_front(); |
268 tab->LoadIfNecessary(); | 268 tab->LoadIfNecessary(); |
269 content::WebContents* contents = tab->GetWebContents(); | 269 if (tab->GetWebContents()) { |
270 if (contents) { | 270 int tab_index; |
271 Browser* browser = browser::FindBrowserWithWebContents(contents); | 271 Browser* browser = browser::FindBrowserForController(tab, &tab_index); |
272 if (browser && chrome::GetActiveWebContents(browser) != contents) { | 272 if (browser && browser->active_index() != tab_index) { |
273 // By default tabs are marked as visible. As only the active tab is | 273 // By default tabs are marked as visible. As only the active tab is |
274 // visible we need to explicitly tell non-active tabs they are hidden. | 274 // visible we need to explicitly tell non-active tabs they are hidden. |
275 // Without this call non-active tabs are not marked as backgrounded. | 275 // Without this call non-active tabs are not marked as backgrounded. |
276 // | 276 // |
277 // NOTE: We need to do this here rather than when the tab is added to | 277 // NOTE: We need to do this here rather than when the tab is added to |
278 // the Browser as at that time not everything has been created, so that | 278 // the Browser as at that time not everything has been created, so that |
279 // the call would do nothing. | 279 // the call would do nothing. |
280 contents->WasHidden(); | 280 tab->GetWebContents()->WasHidden(); |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 if (!tabs_to_load_.empty()) { | 285 if (!tabs_to_load_.empty()) { |
286 force_load_timer_.Stop(); | 286 force_load_timer_.Stop(); |
287 // Each time we load a tab we also set a timer to force us to start loading | 287 // Each time we load a tab we also set a timer to force us to start loading |
288 // the next tab if this one doesn't load quickly enough. | 288 // the next tab if this one doesn't load quickly enough. |
289 force_load_timer_.Start(FROM_HERE, | 289 force_load_timer_.Start(FROM_HERE, |
290 base::TimeDelta::FromMilliseconds(force_load_delay_), | 290 base::TimeDelta::FromMilliseconds(force_load_delay_), |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 if (active_session_restorers == NULL) | 1099 if (active_session_restorers == NULL) |
1100 return false; | 1100 return false; |
1101 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1101 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1102 active_session_restorers->begin(); | 1102 active_session_restorers->begin(); |
1103 it != active_session_restorers->end(); ++it) { | 1103 it != active_session_restorers->end(); ++it) { |
1104 if ((*it)->profile() == profile) | 1104 if ((*it)->profile() == profile) |
1105 return true; | 1105 return true; |
1106 } | 1106 } |
1107 return false; | 1107 return false; |
1108 } | 1108 } |
OLD | NEW |