| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tab_loader.h" | 5 #include "chrome/browser/sessions/tab_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/memory_pressure_monitor.h" | 10 #include "base/memory/memory_pressure_monitor.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 | 168 |
| 169 NavigationController* controller = tabs_to_load_.front(); | 169 NavigationController* controller = tabs_to_load_.front(); |
| 170 DCHECK(controller); | 170 DCHECK(controller); |
| 171 tabs_loading_.insert(controller); | 171 tabs_loading_.insert(controller); |
| 172 tabs_to_load_.pop_front(); | 172 tabs_to_load_.pop_front(); |
| 173 controller->LoadIfNecessary(); | 173 controller->LoadIfNecessary(); |
| 174 content::WebContents* contents = controller->GetWebContents(); | 174 content::WebContents* contents = controller->GetWebContents(); |
| 175 if (contents) { | 175 if (contents) { |
| 176 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 176 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 177 if (browser && | 177 bool is_active = browser && |
| 178 browser->tab_strip_model()->GetActiveWebContents() != contents) { | 178 browser->tab_strip_model()->GetActiveWebContents() == contents; |
| 179 // By default tabs are marked as visible. As only the active tab is | 179 |
| 180 // visible we need to explicitly tell non-active tabs they are hidden. | 180 // Background tabs should have been loaded with WebContents::CreateParams |
| 181 // Without this call non-active tabs are not marked as backgrounded. | 181 // initially_hidden = true. Ensure this is reflected in the tab status. |
| 182 // | 182 DCHECK_EQ(is_active, contents->GetRenderWidgetHostView()->IsShowing()); |
| 183 // NOTE: We need to do this here rather than when the tab is added to | |
| 184 // the Browser as at that time not everything has been created, so that | |
| 185 // the call would do nothing. | |
| 186 contents->WasHidden(); | |
| 187 } | |
| 188 } | 183 } |
| 189 } | 184 } |
| 190 | 185 |
| 191 if (!tabs_to_load_.empty()) | 186 if (!tabs_to_load_.empty()) |
| 192 StartTimer(); | 187 StartTimer(); |
| 193 } | 188 } |
| 194 | 189 |
| 195 void TabLoader::StartFirstTimer() { | 190 void TabLoader::StartFirstTimer() { |
| 196 force_load_timer_.Stop(); | 191 force_load_timer_.Stop(); |
| 197 force_load_timer_.Start(FROM_HERE, | 192 force_load_timer_.Start(FROM_HERE, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // memory pressure. | 262 // memory pressure. |
| 268 stats_collector_->DeferTab(tab); | 263 stats_collector_->DeferTab(tab); |
| 269 } | 264 } |
| 270 // By calling |LoadNextTab| explicitly, we make sure that the | 265 // By calling |LoadNextTab| explicitly, we make sure that the |
| 271 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. | 266 // |NOTIFICATION_SESSION_RESTORE_DONE| event gets sent. |
| 272 LoadNextTab(); | 267 LoadNextTab(); |
| 273 } | 268 } |
| 274 | 269 |
| 275 // static | 270 // static |
| 276 TabLoader* TabLoader::shared_tab_loader_ = nullptr; | 271 TabLoader* TabLoader::shared_tab_loader_ = nullptr; |
| OLD | NEW |