OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/debug/alias.h" | 16 #include "base/debug/alias.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 19 #include "base/metrics/field_trial.h" |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
21 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
22 #include "base/task/cancelable_task_tracker.h" | 23 #include "base/task/cancelable_task_tracker.h" |
23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/search/search.h" | 27 #include "chrome/browser/search/search.h" |
27 #include "chrome/browser/sessions/session_restore_delegate.h" | 28 #include "chrome/browser/sessions/session_restore_delegate.h" |
28 #include "chrome/browser/sessions/session_service.h" | 29 #include "chrome/browser/sessions/session_service.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // No tab browsers were created and no URLs were supplied on the command | 292 // No tab browsers were created and no URLs were supplied on the command |
292 // line. Open the new tab page. | 293 // line. Open the new tab page. |
293 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); | 294 urls_to_open_.push_back(GURL(chrome::kChromeUINewTabURL)); |
294 } | 295 } |
295 AppendURLsToBrowser(browser, urls_to_open_); | 296 AppendURLsToBrowser(browser, urls_to_open_); |
296 browser->window()->Show(); | 297 browser->window()->Show(); |
297 } | 298 } |
298 | 299 |
299 if (succeeded) { | 300 if (succeeded) { |
300 // Start Loading tabs. | 301 // Start Loading tabs. |
301 SessionRestoreDelegate::RestoreTabs(contents_created, restore_started_); | 302 bool active_only = SessionRestore::IsLoadingActiveTabsOnly(); |
| 303 SessionRestoreDelegate::RestoreTabs(contents_created, restore_started_, |
| 304 active_only); |
302 } | 305 } |
303 | 306 |
304 if (!synchronous_) { | 307 if (!synchronous_) { |
305 // If we're not synchronous we need to delete ourself. | 308 // If we're not synchronous we need to delete ourself. |
306 // NOTE: we must use DeleteLater here as most likely we're in a callback | 309 // NOTE: we must use DeleteLater here as most likely we're in a callback |
307 // from the history service which doesn't deal well with deleting the | 310 // from the history service which doesn't deal well with deleting the |
308 // object it is notifying. | 311 // object it is notifying. |
309 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 312 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
310 | 313 |
311 // The delete may take a while and at this point we no longer care about | 314 // The delete may take a while and at this point we no longer care about |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 814 } |
812 | 815 |
813 // static | 816 // static |
814 SessionRestore::CallbackSubscription | 817 SessionRestore::CallbackSubscription |
815 SessionRestore::RegisterOnSessionRestoredCallback( | 818 SessionRestore::RegisterOnSessionRestoredCallback( |
816 const base::Callback<void(int)>& callback) { | 819 const base::Callback<void(int)>& callback) { |
817 return on_session_restored_callbacks()->Add(callback); | 820 return on_session_restored_callbacks()->Add(callback); |
818 } | 821 } |
819 | 822 |
820 // static | 823 // static |
| 824 bool SessionRestore::IsLoadingActiveTabsOnly() { |
| 825 base::FieldTrial* trial = |
| 826 base::FieldTrialList::Find("SessionRestoreBackgroundLoading"); |
| 827 if (!trial || trial->group_name() == "Restore") |
| 828 return false; |
| 829 return true; |
| 830 } |
| 831 |
| 832 // static |
821 base::CallbackList<void(int)>* | 833 base::CallbackList<void(int)>* |
822 SessionRestore::on_session_restored_callbacks_ = nullptr; | 834 SessionRestore::on_session_restored_callbacks_ = nullptr; |
OLD | NEW |