| 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 "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 : TabStripModel::ADD_NONE; | 113 : TabStripModel::ADD_NONE; |
| 114 if (pin) { | 114 if (pin) { |
| 115 int first_mini_tab_idx = | 115 int first_mini_tab_idx = |
| 116 browser->tab_strip_model()->IndexOfFirstNonMiniTab(); | 116 browser->tab_strip_model()->IndexOfFirstNonMiniTab(); |
| 117 tab_index = std::min(tab_index, first_mini_tab_idx); | 117 tab_index = std::min(tab_index, first_mini_tab_idx); |
| 118 add_types |= TabStripModel::ADD_PINNED; | 118 add_types |= TabStripModel::ADD_PINNED; |
| 119 } | 119 } |
| 120 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents, | 120 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents, |
| 121 add_types); | 121 add_types); |
| 122 if (select) { | 122 if (select) { |
| 123 browser->window()->Activate(); | 123 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 124 browser->window()->Activate(false /* user_gesture */); |
| 124 } else { | 125 } else { |
| 125 // We set the size of the view here, before Blink does its initial layout. | 126 // We set the size of the view here, before Blink does its initial layout. |
| 126 // If we don't, the initial layout of background tabs will be performed | 127 // If we don't, the initial layout of background tabs will be performed |
| 127 // with a view width of 0, which may cause script outputs and anchor link | 128 // with a view width of 0, which may cause script outputs and anchor link |
| 128 // location calculations to be incorrect even after a new layout with | 129 // location calculations to be incorrect even after a new layout with |
| 129 // proper view dimensions. TabStripModel::AddWebContents() contains similar | 130 // proper view dimensions. TabStripModel::AddWebContents() contains similar |
| 130 // logic. | 131 // logic. |
| 131 gfx::Size size = browser->window()->GetBounds().size(); | 132 gfx::Size size = browser->window()->GetBounds().size(); |
| 132 // Fallback to the restore bounds if it's empty as the window is not shown | 133 // Fallback to the restore bounds if it's empty as the window is not shown |
| 133 // yet and the bounds may not be available on all platforms. | 134 // yet and the bounds may not be available on all platforms. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 int insertion_index = tab_strip->active_index(); | 167 int insertion_index = tab_strip->active_index(); |
| 167 tab_strip->InsertWebContentsAt(insertion_index + 1, | 168 tab_strip->InsertWebContentsAt(insertion_index + 1, |
| 168 web_contents, | 169 web_contents, |
| 169 TabStripModel::ADD_ACTIVE | | 170 TabStripModel::ADD_ACTIVE | |
| 170 TabStripModel::ADD_INHERIT_GROUP); | 171 TabStripModel::ADD_INHERIT_GROUP); |
| 171 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); | 172 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); |
| 172 return web_contents; | 173 return web_contents; |
| 173 } | 174 } |
| 174 | 175 |
| 175 } // namespace chrome | 176 } // namespace chrome |
| OLD | NEW |