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 "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Tab with internal web UI like NTP or Settings are good choices to | 50 // Tab with internal web UI like NTP or Settings are good choices to |
51 // defer loading. | 51 // defer loading. |
52 if (is_internal_page_ != right.is_internal_page_) | 52 if (is_internal_page_ != right.is_internal_page_) |
53 return !is_internal_page_; | 53 return !is_internal_page_; |
54 // Pinned tabs should be loaded first. | 54 // Pinned tabs should be loaded first. |
55 if (is_pinned_ != right.is_pinned_) | 55 if (is_pinned_ != right.is_pinned_) |
56 return is_pinned_; | 56 return is_pinned_; |
57 // Apps should be loaded before normal tabs. | 57 // Apps should be loaded before normal tabs. |
58 if (is_app_ != right.is_app_) | 58 if (is_app_ != right.is_app_) |
59 return is_app_; | 59 return is_app_; |
60 // TODO(georgesak): Add criterion based on recency. | 60 // Restore using MRU. Behind an experiment for now. |
| 61 if (SessionRestore::GetSmartRestoreMode() == |
| 62 SessionRestore::SMART_RESTORE_MODE_MRU) |
| 63 return contents_->GetLastActiveTime() > |
| 64 right.contents_->GetLastActiveTime(); |
61 return false; | 65 return false; |
62 } | 66 } |
63 | 67 |
64 // static | 68 // static |
65 void SessionRestoreDelegate::RestoreTabs( | 69 void SessionRestoreDelegate::RestoreTabs( |
66 const std::vector<RestoredTab>& tabs, | 70 const std::vector<RestoredTab>& tabs, |
67 const base::TimeTicks& restore_started) { | 71 const base::TimeTicks& restore_started) { |
68 // This experiment allows us to have comparative numbers for session restore | 72 // This experiment allows us to have comparative numbers for session restore |
69 // metrics. It will be removed once those numbers are obtained. | 73 // metrics. It will be removed once those numbers are obtained. |
70 // TODO(georgesak): Remove this experiment when stats are collected. | 74 // TODO(georgesak): Remove this experiment when stats are collected. |
71 base::FieldTrial* trial = | 75 base::FieldTrial* trial = |
72 base::FieldTrialList::Find("IntelligentSessionRestore"); | 76 base::FieldTrialList::Find("IntelligentSessionRestore"); |
73 if (!trial || trial->group_name() != "DontRestoreBackgroundTabs") { | 77 if (!trial || trial->group_name() != "DontRestoreBackgroundTabs") { |
74 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started); | 78 SessionRestoreStatsCollector::TrackTabs(tabs, restore_started); |
75 TabLoader::RestoreTabs(tabs, restore_started); | 79 TabLoader::RestoreTabs(tabs, restore_started); |
76 } else { | 80 } else { |
77 SessionRestoreStatsCollector::TrackActiveTabs(tabs, restore_started); | 81 SessionRestoreStatsCollector::TrackActiveTabs(tabs, restore_started); |
78 for (auto& restored_tab : tabs) { | 82 for (auto& restored_tab : tabs) { |
79 if (!restored_tab.is_active()) { | 83 if (!restored_tab.is_active()) { |
80 favicon::ContentFaviconDriver* favicon_driver = | 84 favicon::ContentFaviconDriver* favicon_driver = |
81 favicon::ContentFaviconDriver::FromWebContents( | 85 favicon::ContentFaviconDriver::FromWebContents( |
82 restored_tab.contents()); | 86 restored_tab.contents()); |
83 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); | 87 favicon_driver->FetchFavicon(favicon_driver->GetActiveURL()); |
84 } | 88 } |
85 } | 89 } |
86 } | 90 } |
87 } | 91 } |
OLD | NEW |