OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/sessions/session_service_factory.h" | 25 #include "chrome/browser/sessions/session_service_factory.h" |
26 #include "chrome/browser/sessions/session_types.h" | 26 #include "chrome/browser/sessions/session_types.h" |
27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
30 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 32 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
33 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
34 #include "content/public/browser/child_process_security_policy.h" | 34 #include "content/public/browser/child_process_security_policy.h" |
| 35 #include "content/public/browser/dom_storage_context.h" |
35 #include "content/public/browser/navigation_controller.h" | 36 #include "content/public/browser/navigation_controller.h" |
36 #include "content/public/browser/notification_registrar.h" | 37 #include "content/public/browser/notification_registrar.h" |
37 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
39 #include "content/public/browser/render_widget_host.h" | 40 #include "content/public/browser/render_widget_host.h" |
40 #include "content/public/browser/render_widget_host_view.h" | 41 #include "content/public/browser/render_widget_host_view.h" |
| 42 #include "content/public/browser/session_storage_namespace.h" |
41 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
42 #include "content/public/browser/web_contents_view.h" | 44 #include "content/public/browser/web_contents_view.h" |
43 #include "net/base/network_change_notifier.h" | 45 #include "net/base/network_change_notifier.h" |
44 #include "webkit/glue/glue_serialize.h" | 46 #include "webkit/glue/glue_serialize.h" |
45 | 47 |
46 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
47 #include "chrome/browser/chromeos/boot_times_loader.h" | 49 #include "chrome/browser/chromeos/boot_times_loader.h" |
48 #endif | 50 #endif |
49 | 51 |
50 using content::NavigationController; | 52 using content::NavigationController; |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 bool schedule_load) { | 870 bool schedule_load) { |
869 DCHECK(!tab.navigations.empty()); | 871 DCHECK(!tab.navigations.empty()); |
870 int selected_index = tab.current_navigation_index; | 872 int selected_index = tab.current_navigation_index; |
871 selected_index = std::max( | 873 selected_index = std::max( |
872 0, | 874 0, |
873 std::min(selected_index, | 875 std::min(selected_index, |
874 static_cast<int>(tab.navigations.size() - 1))); | 876 static_cast<int>(tab.navigations.size() - 1))); |
875 | 877 |
876 RecordAppLaunchForTab(browser, tab, selected_index); | 878 RecordAppLaunchForTab(browser, tab, selected_index); |
877 | 879 |
| 880 // Associate sessionStorage (if any) to the restored tab. |
| 881 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; |
| 882 if (!tab.session_storage_persistent_id.empty()) { |
| 883 session_storage_namespace = |
| 884 content::BrowserContext::GetDOMStorageContext(profile_)-> |
| 885 RecreateSessionStorage(tab.session_storage_persistent_id); |
| 886 } |
| 887 |
878 WebContents* web_contents = | 888 WebContents* web_contents = |
879 browser->AddRestoredTab(tab.navigations, | 889 browser->AddRestoredTab(tab.navigations, |
880 tab_index, | 890 tab_index, |
881 selected_index, | 891 selected_index, |
882 tab.extension_app_id, | 892 tab.extension_app_id, |
883 false, // select | 893 false, // select |
884 tab.pinned, | 894 tab.pinned, |
885 true, | 895 true, |
886 NULL); | 896 session_storage_namespace.get()); |
887 // Regression check: check that the tab didn't start loading right away. The | 897 // Regression check: check that the tab didn't start loading right away. The |
888 // focused tab will be loaded by Browser, and TabLoader will load the rest. | 898 // focused tab will be loaded by Browser, and TabLoader will load the rest. |
889 DCHECK(web_contents->GetController().NeedsReload()); | 899 DCHECK(web_contents->GetController().NeedsReload()); |
890 | 900 |
891 // Set up the file access rights for the selected navigation entry. | 901 // Set up the file access rights for the selected navigation entry. |
892 const int id = web_contents->GetRenderProcessHost()->GetID(); | 902 const int id = web_contents->GetRenderProcessHost()->GetID(); |
893 const int read_file_permissions = | 903 const int read_file_permissions = |
894 base::PLATFORM_FILE_OPEN | | 904 base::PLATFORM_FILE_OPEN | |
895 base::PLATFORM_FILE_READ | | 905 base::PLATFORM_FILE_READ | |
896 base::PLATFORM_FILE_EXCLUSIVE_READ | | 906 base::PLATFORM_FILE_EXCLUSIVE_READ | |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 if (active_session_restorers == NULL) | 1090 if (active_session_restorers == NULL) |
1081 return false; | 1091 return false; |
1082 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1092 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1083 active_session_restorers->begin(); | 1093 active_session_restorers->begin(); |
1084 it != active_session_restorers->end(); ++it) { | 1094 it != active_session_restorers->end(); ++it) { |
1085 if ((*it)->profile() == profile) | 1095 if ((*it)->profile() == profile) |
1086 return true; | 1096 return true; |
1087 } | 1097 } |
1088 return false; | 1098 return false; |
1089 } | 1099 } |
OLD | NEW |