| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/metrics/histogram_macros.h" | 24 #include "base/metrics/histogram_macros.h" |
| 25 #include "base/run_loop.h" | 25 #include "base/run_loop.h" |
| 26 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
| 27 #include "base/task/cancelable_task_tracker.h" | 27 #include "base/task/cancelable_task_tracker.h" |
| 28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
| 32 #include "chrome/browser/lifetime/keep_alive_types.h" | 32 #include "chrome/browser/lifetime/keep_alive_types.h" |
| 33 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 33 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 34 #include "chrome/browser/metrics/first_web_contents_profiler.h" | |
| 35 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/search/search.h" | 35 #include "chrome/browser/search/search.h" |
| 37 #include "chrome/browser/sessions/session_restore_delegate.h" | 36 #include "chrome/browser/sessions/session_restore_delegate.h" |
| 38 #include "chrome/browser/sessions/session_service.h" | 37 #include "chrome/browser/sessions/session_service.h" |
| 39 #include "chrome/browser/sessions/session_service_factory.h" | 38 #include "chrome/browser/sessions/session_service_factory.h" |
| 40 #include "chrome/browser/sessions/session_service_utils.h" | 39 #include "chrome/browser/sessions/session_service_utils.h" |
| 41 #include "chrome/browser/sessions/tab_loader.h" | 40 #include "chrome/browser/sessions/tab_loader.h" |
| 42 #include "chrome/browser/ui/browser.h" | 41 #include "chrome/browser/ui/browser.h" |
| 43 #include "chrome/browser/ui/browser_finder.h" | 42 #include "chrome/browser/ui/browser_finder.h" |
| 44 #include "chrome/browser/ui/browser_navigator.h" | 43 #include "chrome/browser/ui/browser_navigator.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 contents->SetLastActiveTime(now - delta); | 541 contents->SetLastActiveTime(now - delta); |
| 543 | 542 |
| 544 RestoredTab restored_tab(contents, is_selected_tab, | 543 RestoredTab restored_tab(contents, is_selected_tab, |
| 545 tab.extension_app_id.empty(), tab.pinned); | 544 tab.extension_app_id.empty(), tab.pinned); |
| 546 created_contents->push_back(restored_tab); | 545 created_contents->push_back(restored_tab); |
| 547 | 546 |
| 548 // If this isn't the selected tab, there's nothing else to do. | 547 // If this isn't the selected tab, there's nothing else to do. |
| 549 if (!is_selected_tab) | 548 if (!is_selected_tab) |
| 550 continue; | 549 continue; |
| 551 | 550 |
| 552 FirstWebContentsProfiler::WebContentsStarted(contents); | |
| 553 ShowBrowser(browser, browser->tab_strip_model()->GetIndexOfWebContents( | 551 ShowBrowser(browser, browser->tab_strip_model()->GetIndexOfWebContents( |
| 554 contents)); | 552 contents)); |
| 555 // TODO(sky): remove. For debugging 368236. | 553 // TODO(sky): remove. For debugging 368236. |
| 556 CHECK_EQ(browser->tab_strip_model()->GetActiveWebContents(), contents); | 554 CHECK_EQ(browser->tab_strip_model()->GetActiveWebContents(), contents); |
| 557 } | 555 } |
| 558 } else { | 556 } else { |
| 559 // If the browser already has tabs, we want to restore the new ones after | 557 // If the browser already has tabs, we want to restore the new ones after |
| 560 // the existing ones. E.g. this happens in Win8 Metro where we merge | 558 // the existing ones. E.g. this happens in Win8 Metro where we merge |
| 561 // windows or when launching a hosted app from the app launcher. | 559 // windows or when launching a hosted app from the app launcher. |
| 562 int tab_index_offset = initial_tab_count; | 560 int tab_index_offset = initial_tab_count; |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 // static | 836 // static |
| 839 SessionRestore::CallbackSubscription | 837 SessionRestore::CallbackSubscription |
| 840 SessionRestore::RegisterOnSessionRestoredCallback( | 838 SessionRestore::RegisterOnSessionRestoredCallback( |
| 841 const base::Callback<void(int)>& callback) { | 839 const base::Callback<void(int)>& callback) { |
| 842 return on_session_restored_callbacks()->Add(callback); | 840 return on_session_restored_callbacks()->Add(callback); |
| 843 } | 841 } |
| 844 | 842 |
| 845 // static | 843 // static |
| 846 base::CallbackList<void(int)>* | 844 base::CallbackList<void(int)>* |
| 847 SessionRestore::on_session_restored_callbacks_ = nullptr; | 845 SessionRestore::on_session_restored_callbacks_ = nullptr; |
| OLD | NEW |