| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tabs/tab_strip_model.h" | 5 #include "chrome/browser/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (foreground) { | 100 if (foreground) { |
| 101 // Forget any existing relationships, we don't want to make things too | 101 // Forget any existing relationships, we don't want to make things too |
| 102 // confusing by having multiple groups active at the same time. | 102 // confusing by having multiple groups active at the same time. |
| 103 ForgetAllOpeners(); | 103 ForgetAllOpeners(); |
| 104 } | 104 } |
| 105 // Anything opened by a link we deem to have an opener. | 105 // Anything opened by a link we deem to have an opener. |
| 106 data->SetGroup(&selected_contents->controller()); | 106 data->SetGroup(&selected_contents->controller()); |
| 107 } | 107 } |
| 108 contents_data_.insert(contents_data_.begin() + index, data); | 108 contents_data_.insert(contents_data_.begin() + index, data); |
| 109 | 109 |
| 110 if (index <= selected_index_) { |
| 111 // If a tab is inserted before the current selected index, |
| 112 // then |selected_index| needs to be incremented. |
| 113 ++selected_index_; |
| 114 } |
| 115 |
| 110 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 116 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 111 TabInsertedAt(contents, index, foreground)); | 117 TabInsertedAt(contents, index, foreground)); |
| 112 | 118 |
| 113 if (foreground) { | 119 if (foreground) { |
| 114 ChangeSelectedContentsFrom(selected_contents, index, false); | 120 ChangeSelectedContentsFrom(selected_contents, index, false); |
| 115 } else if (index <= selected_index_) { | |
| 116 // If a tab is inserted before the current selected index that is not | |
| 117 // foreground, |selected_index| needs to be incremented. | |
| 118 ++selected_index_; | |
| 119 } | 121 } |
| 120 } | 122 } |
| 121 | 123 |
| 122 void TabStripModel::ReplaceNavigationControllerAt( | 124 void TabStripModel::ReplaceNavigationControllerAt( |
| 123 int index, NavigationController* controller) { | 125 int index, NavigationController* controller) { |
| 124 // This appears to be OK with no flicker since no redraw event | 126 // This appears to be OK with no flicker since no redraw event |
| 125 // occurs between the call to add an aditional tab and one to close | 127 // occurs between the call to add an aditional tab and one to close |
| 126 // the previous tab. | 128 // the previous tab. |
| 127 InsertTabContentsAt(index + 1, controller->tab_contents(), true, true); | 129 InsertTabContentsAt(index + 1, controller->tab_contents(), true, true); |
| 128 std::vector<int> closing_tabs; | 130 std::vector<int> closing_tabs; |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 int index = GetIndexOfTabContents(contents); | 738 int index = GetIndexOfTabContents(contents); |
| 737 contents_data_.at(index)->opener = &opener->controller(); | 739 contents_data_.at(index)->opener = &opener->controller(); |
| 738 } | 740 } |
| 739 | 741 |
| 740 // static | 742 // static |
| 741 bool TabStripModel::OpenerMatches(const TabContentsData* data, | 743 bool TabStripModel::OpenerMatches(const TabContentsData* data, |
| 742 const NavigationController* opener, | 744 const NavigationController* opener, |
| 743 bool use_group) { | 745 bool use_group) { |
| 744 return data->opener == opener || (use_group && data->group == opener); | 746 return data->opener == opener || (use_group && data->group == opener); |
| 745 } | 747 } |
| OLD | NEW |