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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
867 DCHECK(!tab.navigations.empty()); | 869 DCHECK(!tab.navigations.empty()); |
868 int selected_index = tab.current_navigation_index; | 870 int selected_index = tab.current_navigation_index; |
869 selected_index = std::max( | 871 selected_index = std::max( |
870 0, | 872 0, |
871 std::min(selected_index, | 873 std::min(selected_index, |
872 static_cast<int>(tab.navigations.size() - 1))); | 874 static_cast<int>(tab.navigations.size() - 1))); |
873 | 875 |
874 RecordAppLaunchForTab(browser, tab, selected_index); | 876 RecordAppLaunchForTab(browser, tab, selected_index); |
875 | 877 |
876 WebContents* web_contents = | 878 WebContents* web_contents = |
877 browser->AddRestoredTab(tab.navigations, | 879 browser->AddRestoredTab(tab.navigations, |
michaeln
2012/05/30 01:29:19
The last argument to the AddRestoredTab method is
marja
2012/05/31 14:41:34
1. Constructed a SessionStorageNamespace here and
| |
878 tab_index, | 880 tab_index, |
879 selected_index, | 881 selected_index, |
880 tab.extension_app_id, | 882 tab.extension_app_id, |
881 false, // select | 883 false, // select |
882 tab.pinned, | 884 tab.pinned, |
883 true, | 885 true, |
884 NULL); | 886 NULL); |
885 // Regression check: check that the tab didn't start loading right away. The | 887 // Regression check: check that the tab didn't start loading right away. The |
886 // focused tab will be loaded by Browser, and TabLoader will load the rest. | 888 // focused tab will be loaded by Browser, and TabLoader will load the rest. |
887 DCHECK(web_contents->GetController().NeedsReload()); | 889 DCHECK(web_contents->GetController().NeedsReload()); |
888 | 890 |
891 // Associate session storage. | |
892 if (tab.session_storage_real_id_associated) { | |
893 int64 namespace_id = | |
894 web_contents->GetController().GetSessionStorageNamespace()->id(); | |
895 content::DOMStorageContext* dom_storage_context = | |
896 content::BrowserContext::GetDOMStorageContext( | |
897 web_contents->GetBrowserContext()); | |
898 dom_storage_context-> AssociateSessionStorage( | |
899 namespace_id, tab.session_storage_real_id); | |
900 } | |
901 | |
889 // Set up the file access rights for the selected navigation entry. | 902 // Set up the file access rights for the selected navigation entry. |
890 const int id = web_contents->GetRenderProcessHost()->GetID(); | 903 const int id = web_contents->GetRenderProcessHost()->GetID(); |
891 const int read_file_permissions = | 904 const int read_file_permissions = |
892 base::PLATFORM_FILE_OPEN | | 905 base::PLATFORM_FILE_OPEN | |
893 base::PLATFORM_FILE_READ | | 906 base::PLATFORM_FILE_READ | |
894 base::PLATFORM_FILE_EXCLUSIVE_READ | | 907 base::PLATFORM_FILE_EXCLUSIVE_READ | |
895 base::PLATFORM_FILE_ASYNC; | 908 base::PLATFORM_FILE_ASYNC; |
896 const std::string& state = | 909 const std::string& state = |
897 tab.navigations.at(selected_index).state(); | 910 tab.navigations.at(selected_index).state(); |
898 const std::vector<FilePath>& file_paths = | 911 const std::vector<FilePath>& file_paths = |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1078 if (active_session_restorers == NULL) | 1091 if (active_session_restorers == NULL) |
1079 return false; | 1092 return false; |
1080 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1093 for (std::set<SessionRestoreImpl*>::const_iterator it = |
1081 active_session_restorers->begin(); | 1094 active_session_restorers->begin(); |
1082 it != active_session_restorers->end(); ++it) { | 1095 it != active_session_restorers->end(); ++it) { |
1083 if ((*it)->profile() == profile) | 1096 if ((*it)->profile() == profile) |
1084 return true; | 1097 return true; |
1085 } | 1098 } |
1086 return false; | 1099 return false; |
1087 } | 1100 } |
OLD | NEW |