Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: chrome/browser/ui/browser_tabrestore.cc

Issue 10850010: Make session restore understand that tabs have multiple SessionStorageNamespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, with test robustified. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 GURL restore_url = navigations.at(selected_navigation).virtual_url(); 44 GURL restore_url = navigations.at(selected_navigation).virtual_url();
45 // TODO(ajwong): Remove the temporary session_storage_namespace_map when
46 // we teach session restore to understand that one tab can have multiple
47 // SessionStorageNamespace objects. Also remove the
48 // session_storage_namespace.h include since we only need that to assign
49 // into the map.
50 content::SessionStorageNamespaceMap session_storage_namespace_map;
51 session_storage_namespace_map[""] = session_storage_namespace;
52 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory( 45 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory(
53 browser->profile(), 46 browser->profile(),
54 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), 47 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url),
55 MSG_ROUTING_NONE, 48 MSG_ROUTING_NONE,
56 chrome::GetActiveWebContents(browser), 49 chrome::GetActiveWebContents(browser),
57 session_storage_namespace_map); 50 storage_namespace_map);
58 WebContents* new_tab = tab_contents->web_contents(); 51 WebContents* new_tab = tab_contents->web_contents();
59 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); 52 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id);
60 std::vector<NavigationEntry*> entries; 53 std::vector<NavigationEntry*> entries;
61 TabNavigation::CreateNavigationEntriesFromTabNavigations( 54 TabNavigation::CreateNavigationEntriesFromTabNavigations(
62 browser->profile(), navigations, &entries); 55 browser->profile(), navigations, &entries);
63 new_tab->GetController().Restore( 56 new_tab->GetController().Restore(
64 selected_navigation, from_last_session, &entries); 57 selected_navigation, from_last_session, &entries);
65 DCHECK_EQ(0u, entries.size()); 58 DCHECK_EQ(0u, entries.size());
66 59
67 int add_types = select ? TabStripModel::ADD_ACTIVE : 60 int add_types = select ? TabStripModel::ADD_ACTIVE :
(...skipping 25 matching lines...) Expand all
93 session_service->TabRestored(tab_contents, pin); 86 session_service->TabRestored(tab_contents, pin);
94 return new_tab; 87 return new_tab;
95 } 88 }
96 89
97 void ReplaceRestoredTab( 90 void ReplaceRestoredTab(
98 Browser* browser, 91 Browser* browser,
99 const std::vector<TabNavigation>& navigations, 92 const std::vector<TabNavigation>& navigations,
100 int selected_navigation, 93 int selected_navigation,
101 bool from_last_session, 94 bool from_last_session,
102 const std::string& extension_app_id, 95 const std::string& extension_app_id,
103 content::SessionStorageNamespace* session_storage_namespace) { 96 const content::SessionStorageNamespaceMap& storage_namespace_map) {
104 GURL restore_url = navigations.at(selected_navigation).virtual_url(); 97 GURL restore_url = navigations.at(selected_navigation).virtual_url();
105 // TODO(ajwong): Remove the temporary session_storage_namespace_map when
106 // we teach session restore to understand that one tab can have multiple
107 // SessionStorageNamespace objects. Also remove the
108 // session_storage_namespace.h include since we only need that to assign
109 // into the map.
110 content::SessionStorageNamespaceMap session_storage_namespace_map;
111 session_storage_namespace_map[""] = session_storage_namespace;
112 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory( 98 TabContents* tab_contents = chrome::TabContentsWithSessionStorageFactory(
113 browser->profile(), 99 browser->profile(),
114 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), 100 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url),
115 MSG_ROUTING_NONE, 101 MSG_ROUTING_NONE,
116 GetActiveWebContents(browser), 102 GetActiveWebContents(browser),
117 session_storage_namespace_map); 103 storage_namespace_map);
118 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id); 104 tab_contents->extension_tab_helper()->SetExtensionAppById(extension_app_id);
119 WebContents* replacement = tab_contents->web_contents(); 105 WebContents* replacement = tab_contents->web_contents();
120 std::vector<NavigationEntry*> entries; 106 std::vector<NavigationEntry*> entries;
121 TabNavigation::CreateNavigationEntriesFromTabNavigations( 107 TabNavigation::CreateNavigationEntriesFromTabNavigations(
122 browser->profile(), navigations, &entries); 108 browser->profile(), navigations, &entries);
123 replacement->GetController().Restore( 109 replacement->GetController().Restore(
124 selected_navigation, from_last_session, &entries); 110 selected_navigation, from_last_session, &entries);
125 DCHECK_EQ(0u, entries.size()); 111 DCHECK_EQ(0u, entries.size());
126 112
127 browser->tab_strip_model()->ReplaceNavigationControllerAt( 113 browser->tab_strip_model()->ReplaceNavigationControllerAt(
128 browser->active_index(), 114 browser->active_index(),
129 tab_contents); 115 tab_contents);
130 } 116 }
131 117
132 } // namespace chrome 118 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698