| 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/ui/browser_tabrestore.h" | 5 #include "chrome/browser/ui/browser_tabrestore.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/tab_helper.h" | 7 #include "chrome/browser/extensions/tab_helper.h" |
| 8 #include "chrome/browser/sessions/session_service.h" | 8 #include "chrome/browser/sessions/session_service.h" |
| 9 #include "chrome/browser/sessions/session_service_factory.h" | 9 #include "chrome/browser/sessions/session_service_factory.h" |
| 10 #include "chrome/browser/tab_contents/tab_util.h" | 10 #include "chrome/browser/tab_contents/tab_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 content::WebContents* AddRestoredTab( | 34 content::WebContents* AddRestoredTab( |
| 35 Browser* browser, | 35 Browser* browser, |
| 36 const std::vector<TabNavigation>& navigations, | 36 const std::vector<TabNavigation>& navigations, |
| 37 int tab_index, | 37 int tab_index, |
| 38 int selected_navigation, | 38 int selected_navigation, |
| 39 const std::string& extension_app_id, | 39 const std::string& extension_app_id, |
| 40 bool select, | 40 bool select, |
| 41 bool pin, | 41 bool pin, |
| 42 bool from_last_session, | 42 bool from_last_session, |
| 43 content::SessionStorageNamespace* session_storage_namespace, | 43 const content::SessionStorageNamespaceMap& storage_namespace_map, |
| 44 const std::string& user_agent_override) { | 44 const std::string& user_agent_override) { |
| 45 GURL restore_url = navigations.at(selected_navigation).virtual_url(); | 45 GURL restore_url = navigations.at(selected_navigation).virtual_url(); |
| 46 // TODO(ajwong): Remove the temporary session_storage_namespace_map when | |
| 47 // we teach session restore to understand that one tab can have multiple | |
| 48 // SessionStorageNamespace objects. Also remove the | |
| 49 // session_storage_namespace.h include since we only need that to assign | |
| 50 // into the map. | |
| 51 content::SessionStorageNamespaceMap session_storage_namespace_map; | |
| 52 session_storage_namespace_map[""] = session_storage_namespace; | |
| 53 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory( | 46 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory( |
| 54 browser->profile(), | 47 browser->profile(), |
| 55 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), | 48 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), |
| 56 MSG_ROUTING_NONE, | 49 MSG_ROUTING_NONE, |
| 57 chrome::GetActiveWebContents(browser), | 50 chrome::GetActiveWebContents(browser), |
| 58 session_storage_namespace_map); | 51 storage_namespace_map); |
| 59 WebContents* new_tab = tab_contents->web_contents(); | 52 WebContents* new_tab = tab_contents->web_contents(); |
| 60 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); | 53 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); |
| 61 std::vector<NavigationEntry*> entries; | 54 std::vector<NavigationEntry*> entries; |
| 62 TabNavigation::CreateNavigationEntriesFromTabNavigations( | 55 TabNavigation::CreateNavigationEntriesFromTabNavigations( |
| 63 browser->profile(), navigations, &entries); | 56 browser->profile(), navigations, &entries); |
| 64 new_tab->SetUserAgentOverride(user_agent_override); | 57 new_tab->SetUserAgentOverride(user_agent_override); |
| 65 new_tab->GetController().Restore( | 58 new_tab->GetController().Restore( |
| 66 selected_navigation, from_last_session, &entries); | 59 selected_navigation, from_last_session, &entries); |
| 67 DCHECK_EQ(0u, entries.size()); | 60 DCHECK_EQ(0u, entries.size()); |
| 68 | 61 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 95 session_service->TabRestored(tab_contents, pin); | 88 session_service->TabRestored(tab_contents, pin); |
| 96 return new_tab; | 89 return new_tab; |
| 97 } | 90 } |
| 98 | 91 |
| 99 void ReplaceRestoredTab( | 92 void ReplaceRestoredTab( |
| 100 Browser* browser, | 93 Browser* browser, |
| 101 const std::vector<TabNavigation>& navigations, | 94 const std::vector<TabNavigation>& navigations, |
| 102 int selected_navigation, | 95 int selected_navigation, |
| 103 bool from_last_session, | 96 bool from_last_session, |
| 104 const std::string& extension_app_id, | 97 const std::string& extension_app_id, |
| 105 content::SessionStorageNamespace* session_storage_namespace, | 98 const content::SessionStorageNamespaceMap& storage_namespace_map, |
| 106 const std::string& user_agent_override) { | 99 const std::string& user_agent_override) { |
| 107 GURL restore_url = navigations.at(selected_navigation).virtual_url(); | 100 GURL restore_url = navigations.at(selected_navigation).virtual_url(); |
| 108 // TODO(ajwong): Remove the temporary session_storage_namespace_map when | |
| 109 // we teach session restore to understand that one tab can have multiple | |
| 110 // SessionStorageNamespace objects. Also remove the | |
| 111 // session_storage_namespace.h include since we only need that to assign | |
| 112 // into the map. | |
| 113 content::SessionStorageNamespaceMap session_storage_namespace_map; | |
| 114 session_storage_namespace_map[""] = session_storage_namespace; | |
| 115 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory( | 101 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory( |
| 116 browser->profile(), | 102 browser->profile(), |
| 117 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), | 103 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), |
| 118 MSG_ROUTING_NONE, | 104 MSG_ROUTING_NONE, |
| 119 GetActiveWebContents(browser), | 105 GetActiveWebContents(browser), |
| 120 session_storage_namespace_map); | 106 storage_namespace_map); |
| 121 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); | 107 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); |
| 122 WebContents* replacement = tab_contents->web_contents(); | 108 WebContents* replacement = tab_contents->web_contents(); |
| 123 replacement->SetUserAgentOverride(user_agent_override); | 109 replacement->SetUserAgentOverride(user_agent_override); |
| 124 std::vector<NavigationEntry*> entries; | 110 std::vector<NavigationEntry*> entries; |
| 125 TabNavigation::CreateNavigationEntriesFromTabNavigations( | 111 TabNavigation::CreateNavigationEntriesFromTabNavigations( |
| 126 browser->profile(), navigations, &entries); | 112 browser->profile(), navigations, &entries); |
| 127 replacement->GetController().Restore( | 113 replacement->GetController().Restore( |
| 128 selected_navigation, from_last_session, &entries); | 114 selected_navigation, from_last_session, &entries); |
| 129 DCHECK_EQ(0u, entries.size()); | 115 DCHECK_EQ(0u, entries.size()); |
| 130 | 116 |
| 131 browser->tab_strip_model()->ReplaceNavigationControllerAt( | 117 browser->tab_strip_model()->ReplaceNavigationControllerAt( |
| 132 browser->active_index(), | 118 browser->active_index(), |
| 133 tab_contents); | 119 tab_contents); |
| 134 } | 120 } |
| 135 | 121 |
| 136 } // namespace chrome | 122 } // namespace chrome |
| OLD | NEW |