OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_order_controller.h" | 5 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" |
6 | 6 |
7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
8 | 8 |
9 /////////////////////////////////////////////////////////////////////////////// | 9 /////////////////////////////////////////////////////////////////////////////// |
10 // TabStripModelOrderController, public: | 10 // TabStripModelOrderController, public: |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return selected_index - 1; | 104 return selected_index - 1; |
105 | 105 |
106 return selected_index; | 106 return selected_index; |
107 } | 107 } |
108 | 108 |
109 void TabStripModelOrderController::ActiveTabChanged( | 109 void TabStripModelOrderController::ActiveTabChanged( |
110 TabContentsWrapper* old_contents, | 110 TabContentsWrapper* old_contents, |
111 TabContentsWrapper* new_contents, | 111 TabContentsWrapper* new_contents, |
112 int index, | 112 int index, |
113 bool user_gesture) { | 113 bool user_gesture) { |
114 if (old_contents == new_contents) | |
115 return; | |
116 | |
117 NavigationController* old_opener = NULL; | 114 NavigationController* old_opener = NULL; |
118 if (old_contents) { | 115 if (old_contents) { |
119 int index = tabstrip_->GetIndexOfTabContents(old_contents); | 116 int index = tabstrip_->GetIndexOfTabContents(old_contents); |
120 if (index != TabStripModel::kNoTab) { | 117 if (index != TabStripModel::kNoTab) { |
121 old_opener = tabstrip_->GetOpenerOfTabContentsAt(index); | 118 old_opener = tabstrip_->GetOpenerOfTabContentsAt(index); |
122 | 119 |
123 // Forget any group/opener relationships that need to be reset whenever | 120 // Forget any group/opener relationships that need to be reset whenever |
124 // selection changes (see comment in TabStripModel::AddTabContentsAt). | 121 // selection changes (see comment in TabStripModel::AddTabContentsAt). |
125 if (tabstrip_->ShouldResetGroupOnSelect(old_contents)) | 122 if (tabstrip_->ShouldResetGroupOnSelect(old_contents)) |
126 tabstrip_->ForgetGroup(old_contents); | 123 tabstrip_->ForgetGroup(old_contents); |
(...skipping 10 matching lines...) Expand all Loading... |
137 | 134 |
138 /////////////////////////////////////////////////////////////////////////////// | 135 /////////////////////////////////////////////////////////////////////////////// |
139 // TabStripModelOrderController, private: | 136 // TabStripModelOrderController, private: |
140 | 137 |
141 int TabStripModelOrderController::GetValidIndex( | 138 int TabStripModelOrderController::GetValidIndex( |
142 int index, int removing_index) const { | 139 int index, int removing_index) const { |
143 if (removing_index < index) | 140 if (removing_index < index) |
144 index = std::max(0, index - 1); | 141 index = std::max(0, index - 1); |
145 return index; | 142 return index; |
146 } | 143 } |
OLD | NEW |