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/tabs/tab_strip_model_order_controller.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" |
6 | 6 |
7 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 | 9 |
10 using content::NavigationController; | 10 using content::NavigationController; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // If the tab was in a group, shift selection to the next tab in the group. | 91 // If the tab was in a group, shift selection to the next tab in the group. |
92 int index = tabstrip_->GetIndexOfNextTabContentsOpenedBy(parent_opener, | 92 int index = tabstrip_->GetIndexOfNextTabContentsOpenedBy(parent_opener, |
93 removing_index, | 93 removing_index, |
94 false); | 94 false); |
95 if (index != TabStripModel::kNoTab) | 95 if (index != TabStripModel::kNoTab) |
96 return GetValidIndex(index, removing_index); | 96 return GetValidIndex(index, removing_index); |
97 | 97 |
98 // If we can't find a subsequent group member, just fall back to the | 98 // If we can't find a subsequent group member, just fall back to the |
99 // parent_opener itself. Note that we use "group" here since opener is | 99 // parent_opener itself. Note that we use "group" here since opener is |
100 // reset by select operations.. | 100 // reset by select operations.. |
101 index = tabstrip_->GetIndexOfController(parent_opener); | 101 index = tabstrip_->GetIndexOfWebContents(parent_opener->GetWebContents()); |
102 if (index != TabStripModel::kNoTab) | 102 if (index != TabStripModel::kNoTab) |
103 return GetValidIndex(index, removing_index); | 103 return GetValidIndex(index, removing_index); |
104 } | 104 } |
105 | 105 |
106 // No opener set, fall through to the default handler... | 106 // No opener set, fall through to the default handler... |
107 int selected_index = tabstrip_->active_index(); | 107 int selected_index = tabstrip_->active_index(); |
108 if (selected_index >= (tab_count - 1)) | 108 if (selected_index >= (tab_count - 1)) |
109 return selected_index - 1; | 109 return selected_index - 1; |
110 | 110 |
111 return selected_index; | 111 return selected_index; |
(...skipping 29 matching lines...) Expand all Loading... |
141 | 141 |
142 /////////////////////////////////////////////////////////////////////////////// | 142 /////////////////////////////////////////////////////////////////////////////// |
143 // TabStripModelOrderController, private: | 143 // TabStripModelOrderController, private: |
144 | 144 |
145 int TabStripModelOrderController::GetValidIndex( | 145 int TabStripModelOrderController::GetValidIndex( |
146 int index, int removing_index) const { | 146 int index, int removing_index) const { |
147 if (removing_index < index) | 147 if (removing_index < index) |
148 index = std::max(0, index - 1); | 148 index = std::max(0, index - 1); |
149 return index; | 149 return index; |
150 } | 150 } |
OLD | NEW |