| 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/session_restore_delegate.h" | 5 #include "chrome/browser/sessions/session_restore_delegate.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "chrome/browser/sessions/session_restore_stats_collector.h" | 8 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
| 9 #include "chrome/browser/sessions/tab_loader.h" | 9 #include "chrome/browser/sessions/tab_loader.h" |
| 10 #include "components/favicon/content/content_favicon_driver.h" | 10 #include "components/favicon/content/content_favicon_driver.h" |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 void SessionRestoreDelegate::RestoreTabs( | 13 void SessionRestoreDelegate::RestoreTabs(const std::vector<RestoredTab>& tabs, |
| 14 const std::vector<RestoredTab>& tabs, | 14 const base::TimeTicks& restore_started, |
| 15 const base::TimeTicks& restore_started) { | 15 bool active_only) { |
| 16 // TODO(georgesak): make tests aware of that behavior so that they succeed if | 16 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started, active_only); |
| 17 // tab loading is disabled. | 17 if (!active_only) { |
| 18 base::FieldTrial* trial = | |
| 19 base::FieldTrialList::Find("SessionRestoreBackgroundLoading"); | |
| 20 bool active_only = true; | |
| 21 if (!trial || trial->group_name() == "Restore") { | |
| 22 TabLoader::RestoreTabs(tabs, restore_started); | 18 TabLoader::RestoreTabs(tabs, restore_started); |
| 23 active_only = false; | |
| 24 } else { | 19 } else { |
| 25 // If we are not loading inactive tabs, restore their favicons (title has | 20 // If we are not loading inactive tabs, restore their favicons (title has |
| 26 // already been set by now). | 21 // already been set by now). |
| 27 for (auto& tab : tabs) { | 22 for (auto& tab : tabs) { |
| 28 if (!tab.is_active) { | 23 if (!tab.is_active) { |
| 29 favicon::ContentFaviconDriver* favicon_driver = | 24 favicon::ContentFaviconDriver* favicon_driver = |
| 30 favicon::ContentFaviconDriver::FromWebContents(tab.contents); | 25 favicon::ContentFaviconDriver::FromWebContents(tab.contents); |
| 31 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); | 26 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); |
| 32 } | 27 } |
| 33 } | 28 } |
| 34 } | 29 } |
| 35 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started, active_only); | |
| 36 } | 30 } |
| OLD | NEW |