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/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" |
11 #include "chrome/browser/tab_contents/tab_util.h" | 11 #include "chrome/browser/tab_contents/tab_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/session_storage_namespace.h" | 17 #include "content/public/browser/session_storage_namespace.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/browser/web_contents_view.h" | 19 #include "content/public/browser/web_contents_view.h" |
20 #include "ui/gfx/layout_util.h" | |
20 | 21 |
21 using content::WebContents; | 22 using content::WebContents; |
22 using content::NavigationController; | 23 using content::NavigationController; |
23 using content::NavigationEntry; | 24 using content::NavigationEntry; |
24 using sessions::SerializedNavigationEntry; | 25 using sessions::SerializedNavigationEntry; |
25 | 26 |
26 namespace chrome { | 27 namespace chrome { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 int first_mini_tab_idx = | 107 int first_mini_tab_idx = |
107 browser->tab_strip_model()->IndexOfFirstNonMiniTab(); | 108 browser->tab_strip_model()->IndexOfFirstNonMiniTab(); |
108 tab_index = std::min(tab_index, first_mini_tab_idx); | 109 tab_index = std::min(tab_index, first_mini_tab_idx); |
109 add_types |= TabStripModel::ADD_PINNED; | 110 add_types |= TabStripModel::ADD_PINNED; |
110 } | 111 } |
111 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents, | 112 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents, |
112 add_types); | 113 add_types); |
113 if (select) { | 114 if (select) { |
114 browser->window()->Activate(); | 115 browser->window()->Activate(); |
115 } else { | 116 } else { |
116 // We set the size of the view here, before WebKit does its initial | 117 // We set the size of the view here, before WebKit does its initial |
Avi (use Gerrit)
2014/03/22 04:48:06
While you're in this file, Blink. Heh.
erikchen
2014/03/27 17:51:27
Done.
| |
117 // layout. If we don't, the initial layout of background tabs will be | 118 // layout. If we don't, the initial layout of background tabs will be |
118 // performed with a view width of 0, which may cause script outputs and | 119 // performed with a view width of 0, which may cause script outputs and |
119 // anchor link location calculations to be incorrect even after a new | 120 // anchor link location calculations to be incorrect even after a new |
120 // layout with proper view dimensions. TabStripModel::AddWebContents() | 121 // layout with proper view dimensions. TabStripModel::AddWebContents() |
121 // contains similar logic. | 122 // contains similar logic. |
122 web_contents->GetView()->SizeContents( | 123 gfx::ResizeWebContents(web_contents, |
123 browser->window()->GetRestoredBounds().size()); | 124 browser->window()->GetRestoredBounds().size()); |
124 web_contents->WasHidden(); | 125 web_contents->WasHidden(); |
125 } | 126 } |
126 SessionService* session_service = | 127 SessionService* session_service = |
127 SessionServiceFactory::GetForProfileIfExisting(browser->profile()); | 128 SessionServiceFactory::GetForProfileIfExisting(browser->profile()); |
128 if (session_service) | 129 if (session_service) |
129 session_service->TabRestored(web_contents, pin); | 130 session_service->TabRestored(web_contents, pin); |
130 return web_contents; | 131 return web_contents; |
131 } | 132 } |
132 | 133 |
133 content::WebContents* ReplaceRestoredTab( | 134 content::WebContents* ReplaceRestoredTab( |
(...skipping 18 matching lines...) Expand all Loading... | |
152 int insertion_index = tab_strip->active_index(); | 153 int insertion_index = tab_strip->active_index(); |
153 tab_strip->InsertWebContentsAt(insertion_index + 1, | 154 tab_strip->InsertWebContentsAt(insertion_index + 1, |
154 web_contents, | 155 web_contents, |
155 TabStripModel::ADD_ACTIVE | | 156 TabStripModel::ADD_ACTIVE | |
156 TabStripModel::ADD_INHERIT_GROUP); | 157 TabStripModel::ADD_INHERIT_GROUP); |
157 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); | 158 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); |
158 return web_contents; | 159 return web_contents; |
159 } | 160 } |
160 | 161 |
161 } // namespace chrome | 162 } // namespace chrome |
OLD | NEW |