| 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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 bool schedule_load) { | 873 bool schedule_load) { |
| 872 DCHECK(!tab.navigations.empty()); | 874 DCHECK(!tab.navigations.empty()); |
| 873 int selected_index = tab.current_navigation_index; | 875 int selected_index = tab.current_navigation_index; |
| 874 selected_index = std::max( | 876 selected_index = std::max( |
| 875 0, | 877 0, |
| 876 std::min(selected_index, | 878 std::min(selected_index, |
| 877 static_cast<int>(tab.navigations.size() - 1))); | 879 static_cast<int>(tab.navigations.size() - 1))); |
| 878 | 880 |
| 879 RecordAppLaunchForTab(browser, tab, selected_index); | 881 RecordAppLaunchForTab(browser, tab, selected_index); |
| 880 | 882 |
| 883 // Associate sessionStorage (if any) to the restored tab. |
| 884 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; |
| 885 if (!tab.session_storage_persistent_id.empty()) { |
| 886 session_storage_namespace = |
| 887 content::BrowserContext::GetDOMStorageContext(profile_)-> |
| 888 RecreateSessionStorage(tab.session_storage_persistent_id); |
| 889 } |
| 890 |
| 881 WebContents* web_contents = | 891 WebContents* web_contents = |
| 882 browser->AddRestoredTab(tab.navigations, | 892 browser->AddRestoredTab(tab.navigations, |
| 883 tab_index, | 893 tab_index, |
| 884 selected_index, | 894 selected_index, |
| 885 tab.extension_app_id, | 895 tab.extension_app_id, |
| 886 false, // select | 896 false, // select |
| 887 tab.pinned, | 897 tab.pinned, |
| 888 true, | 898 true, |
| 889 NULL); | 899 session_storage_namespace.get()); |
| 890 // Regression check: check that the tab didn't start loading right away. The | 900 // Regression check: check that the tab didn't start loading right away. The |
| 891 // focused tab will be loaded by Browser, and TabLoader will load the rest. | 901 // focused tab will be loaded by Browser, and TabLoader will load the rest. |
| 892 DCHECK(web_contents->GetController().NeedsReload()); | 902 DCHECK(web_contents->GetController().NeedsReload()); |
| 893 | 903 |
| 894 // Set up the file access rights for the selected navigation entry. | 904 // Set up the file access rights for the selected navigation entry. |
| 895 const int id = web_contents->GetRenderProcessHost()->GetID(); | 905 const int id = web_contents->GetRenderProcessHost()->GetID(); |
| 896 const int read_file_permissions = | 906 const int read_file_permissions = |
| 897 base::PLATFORM_FILE_OPEN | | 907 base::PLATFORM_FILE_OPEN | |
| 898 base::PLATFORM_FILE_READ | | 908 base::PLATFORM_FILE_READ | |
| 899 base::PLATFORM_FILE_EXCLUSIVE_READ | | 909 base::PLATFORM_FILE_EXCLUSIVE_READ | |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 if (active_session_restorers == NULL) | 1093 if (active_session_restorers == NULL) |
| 1084 return false; | 1094 return false; |
| 1085 for (std::set<SessionRestoreImpl*>::const_iterator it = | 1095 for (std::set<SessionRestoreImpl*>::const_iterator it = |
| 1086 active_session_restorers->begin(); | 1096 active_session_restorers->begin(); |
| 1087 it != active_session_restorers->end(); ++it) { | 1097 it != active_session_restorers->end(); ++it) { |
| 1088 if ((*it)->profile() == profile) | 1098 if ((*it)->profile() == profile) |
| 1089 return true; | 1099 return true; |
| 1090 } | 1100 } |
| 1091 return false; | 1101 return false; |
| 1092 } | 1102 } |
| OLD | NEW |