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

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

Issue 227043004: Restored tabs should set their initial visibility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests. Created 6 years, 8 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/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sessions/session_service.h" 9 #include "chrome/browser/sessions/session_service.h"
10 #include "chrome/browser/sessions/session_service_factory.h" 10 #include "chrome/browser/sessions/session_service_factory.h"
(...skipping 25 matching lines...) Expand all
36 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY; 36 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY;
37 } 37 }
38 38
39 WebContents* CreateRestoredTab( 39 WebContents* CreateRestoredTab(
40 Browser* browser, 40 Browser* browser,
41 const std::vector<SerializedNavigationEntry>& navigations, 41 const std::vector<SerializedNavigationEntry>& navigations,
42 int selected_navigation, 42 int selected_navigation,
43 const std::string& extension_app_id, 43 const std::string& extension_app_id,
44 bool from_last_session, 44 bool from_last_session,
45 content::SessionStorageNamespace* session_storage_namespace, 45 content::SessionStorageNamespace* session_storage_namespace,
46 const std::string& user_agent_override) { 46 const std::string& user_agent_override,
47 bool initially_hidden) {
47 GURL restore_url = navigations.at(selected_navigation).virtual_url(); 48 GURL restore_url = navigations.at(selected_navigation).virtual_url();
48 // TODO(ajwong): Remove the temporary session_storage_namespace_map when 49 // TODO(ajwong): Remove the temporary session_storage_namespace_map when
49 // we teach session restore to understand that one tab can have multiple 50 // we teach session restore to understand that one tab can have multiple
50 // SessionStorageNamespace objects. Also remove the 51 // SessionStorageNamespace objects. Also remove the
51 // session_storage_namespace.h include since we only need that to assign 52 // session_storage_namespace.h include since we only need that to assign
52 // into the map. 53 // into the map.
53 content::SessionStorageNamespaceMap session_storage_namespace_map; 54 content::SessionStorageNamespaceMap session_storage_namespace_map;
54 session_storage_namespace_map[std::string()] = session_storage_namespace; 55 session_storage_namespace_map[std::string()] = session_storage_namespace;
55 WebContents::CreateParams create_params( 56 WebContents::CreateParams create_params(
56 browser->profile(), 57 browser->profile(),
57 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url)); 58 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url));
59 create_params.initially_hidden = initially_hidden;
58 WebContents* base_web_contents = 60 WebContents* base_web_contents =
59 browser->tab_strip_model()->GetActiveWebContents(); 61 browser->tab_strip_model()->GetActiveWebContents();
60 if (base_web_contents) { 62 if (base_web_contents) {
61 create_params.initial_size = 63 create_params.initial_size =
62 base_web_contents->GetView()->GetContainerSize(); 64 base_web_contents->GetView()->GetContainerSize();
63 } 65 }
64 WebContents* web_contents = content::WebContents::CreateWithSessionStorage( 66 WebContents* web_contents = content::WebContents::CreateWithSessionStorage(
65 create_params, 67 create_params,
66 session_storage_namespace_map); 68 session_storage_namespace_map);
67 extensions::TabHelper::CreateForWebContents(web_contents); 69 extensions::TabHelper::CreateForWebContents(web_contents);
(...skipping 23 matching lines...) Expand all
91 bool pin, 93 bool pin,
92 bool from_last_session, 94 bool from_last_session,
93 content::SessionStorageNamespace* session_storage_namespace, 95 content::SessionStorageNamespace* session_storage_namespace,
94 const std::string& user_agent_override) { 96 const std::string& user_agent_override) {
95 WebContents* web_contents = CreateRestoredTab(browser, 97 WebContents* web_contents = CreateRestoredTab(browser,
96 navigations, 98 navigations,
97 selected_navigation, 99 selected_navigation,
98 extension_app_id, 100 extension_app_id,
99 from_last_session, 101 from_last_session,
100 session_storage_namespace, 102 session_storage_namespace,
101 user_agent_override); 103 user_agent_override,
104 !select);
102 105
103 int add_types = select ? TabStripModel::ADD_ACTIVE 106 int add_types = select ? TabStripModel::ADD_ACTIVE
104 : TabStripModel::ADD_NONE; 107 : TabStripModel::ADD_NONE;
105 if (pin) { 108 if (pin) {
106 int first_mini_tab_idx = 109 int first_mini_tab_idx =
107 browser->tab_strip_model()->IndexOfFirstNonMiniTab(); 110 browser->tab_strip_model()->IndexOfFirstNonMiniTab();
108 tab_index = std::min(tab_index, first_mini_tab_idx); 111 tab_index = std::min(tab_index, first_mini_tab_idx);
109 add_types |= TabStripModel::ADD_PINNED; 112 add_types |= TabStripModel::ADD_PINNED;
110 } 113 }
111 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents, 114 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents,
(...skipping 25 matching lines...) Expand all
137 bool from_last_session, 140 bool from_last_session,
138 const std::string& extension_app_id, 141 const std::string& extension_app_id,
139 content::SessionStorageNamespace* session_storage_namespace, 142 content::SessionStorageNamespace* session_storage_namespace,
140 const std::string& user_agent_override) { 143 const std::string& user_agent_override) {
141 WebContents* web_contents = CreateRestoredTab(browser, 144 WebContents* web_contents = CreateRestoredTab(browser,
142 navigations, 145 navigations,
143 selected_navigation, 146 selected_navigation,
144 extension_app_id, 147 extension_app_id,
145 from_last_session, 148 from_last_session,
146 session_storage_namespace, 149 session_storage_namespace,
147 user_agent_override); 150 user_agent_override,
151 false);
148 152
149 // ReplaceWebContentsAt won't animate in the restoration, so manually do the 153 // ReplaceWebContentsAt won't animate in the restoration, so manually do the
150 // equivalent of ReplaceWebContentsAt. 154 // equivalent of ReplaceWebContentsAt.
151 TabStripModel* tab_strip = browser->tab_strip_model(); 155 TabStripModel* tab_strip = browser->tab_strip_model();
152 int insertion_index = tab_strip->active_index(); 156 int insertion_index = tab_strip->active_index();
153 tab_strip->InsertWebContentsAt(insertion_index + 1, 157 tab_strip->InsertWebContentsAt(insertion_index + 1,
154 web_contents, 158 web_contents,
155 TabStripModel::ADD_ACTIVE | 159 TabStripModel::ADD_ACTIVE |
156 TabStripModel::ADD_INHERIT_GROUP); 160 TabStripModel::ADD_INHERIT_GROUP);
157 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); 161 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE);
158 return web_contents; 162 return web_contents;
159 } 163 }
160 164
161 } // namespace chrome 165 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698