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> |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 | 574 |
575 // Associate sessionStorage (if any) to the restored tab. | 575 // Associate sessionStorage (if any) to the restored tab. |
576 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; | 576 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; |
577 if (!tab.session_storage_persistent_id.empty()) { | 577 if (!tab.session_storage_persistent_id.empty()) { |
578 session_storage_namespace = | 578 session_storage_namespace = |
579 content::BrowserContext::GetDefaultStoragePartition(profile_) | 579 content::BrowserContext::GetDefaultStoragePartition(profile_) |
580 ->GetDOMStorageContext() | 580 ->GetDOMStorageContext() |
581 ->RecreateSessionStorage(tab.session_storage_persistent_id); | 581 ->RecreateSessionStorage(tab.session_storage_persistent_id); |
582 } | 582 } |
583 | 583 |
584 WebContents* web_contents = chrome::AddRestoredTab( | 584 WebContents* web_contents = chrome::AddRestoredTab( |
sky
2015/05/18 15:53:28
Might this set last active time if the tab is sele
Georges Khalil
2015/05/19 19:32:15
True, if the tab is selected, we do not want to ov
| |
585 browser, tab.navigations, tab_index, selected_index, | 585 browser, tab.navigations, tab_index, selected_index, |
586 tab.extension_app_id, | 586 tab.extension_app_id, |
587 false, // select | 587 false, // select |
588 tab.pinned, true, session_storage_namespace.get(), | 588 tab.pinned, true, session_storage_namespace.get(), |
589 tab.user_agent_override); | 589 tab.user_agent_override); |
590 // Regression check: check that the tab didn't start loading right away. The | 590 // Regression check: check that the tab didn't start loading right away. The |
591 // focused tab will be loaded by Browser, and TabLoader will load the rest. | 591 // focused tab will be loaded by Browser, and TabLoader will load the rest. |
592 DCHECK(web_contents->GetController().NeedsReload()); | 592 DCHECK(web_contents->GetController().NeedsReload()); |
593 | 593 |
594 // Restore the saved last active time. By default, the last active time of a | |
595 // WebContent is initially set to the creation time of the tab, which is not | |
596 // necessarly the same as the loading time. This makes sure that the state | |
597 // is preserved between restores. | |
598 web_contents->SetLastActiveTime(tab.last_active_time); | |
599 | |
594 return web_contents; | 600 return web_contents; |
595 } | 601 } |
596 | 602 |
597 Browser* CreateRestoredBrowser(Browser::Type type, | 603 Browser* CreateRestoredBrowser(Browser::Type type, |
598 gfx::Rect bounds, | 604 gfx::Rect bounds, |
599 ui::WindowShowState show_state, | 605 ui::WindowShowState show_state, |
600 const std::string& app_name) { | 606 const std::string& app_name) { |
601 Browser::CreateParams params(type, profile_, host_desktop_type_); | 607 Browser::CreateParams params(type, profile_, host_desktop_type_); |
602 if (!app_name.empty()) { | 608 if (!app_name.empty()) { |
603 const bool trusted_source = true; // We only store trusted app windows. | 609 const bool trusted_source = true; // We only store trusted app windows. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 if (prioritize_tabs == "mru") | 831 if (prioritize_tabs == "mru") |
826 return SMART_RESTORE_MODE_MRU; | 832 return SMART_RESTORE_MODE_MRU; |
827 if (prioritize_tabs == "simple") | 833 if (prioritize_tabs == "simple") |
828 return SMART_RESTORE_MODE_SIMPLE; | 834 return SMART_RESTORE_MODE_SIMPLE; |
829 return SMART_RESTORE_MODE_OFF; | 835 return SMART_RESTORE_MODE_OFF; |
830 } | 836 } |
831 | 837 |
832 // static | 838 // static |
833 base::CallbackList<void(int)>* | 839 base::CallbackList<void(int)>* |
834 SessionRestore::on_session_restored_callbacks_ = nullptr; | 840 SessionRestore::on_session_restored_callbacks_ = nullptr; |
OLD | NEW |