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

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

Powered by Google App Engine
This is Rietveld 408576698