| 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 20 matching lines...) Expand all Loading... |
| 31 // NOTE: TabStripModel enforces that all non-mini-tabs occur after mini-tabs, | 31 // NOTE: TabStripModel enforces that all non-mini-tabs occur after mini-tabs, |
| 32 // so we don't have to check here too. | 32 // so we don't have to check here too. |
| 33 if (transition == PageTransition::LINK && tabstrip_->active_index() != -1) { | 33 if (transition == PageTransition::LINK && tabstrip_->active_index() != -1) { |
| 34 int delta = (insertion_policy_ == TabStripModel::INSERT_AFTER) ? 1 : 0; | 34 int delta = (insertion_policy_ == TabStripModel::INSERT_AFTER) ? 1 : 0; |
| 35 if (foreground) { | 35 if (foreground) { |
| 36 // If the page was opened in the foreground by a link click in another | 36 // If the page was opened in the foreground by a link click in another |
| 37 // tab, insert it adjacent to the tab that opened that link. | 37 // tab, insert it adjacent to the tab that opened that link. |
| 38 return tabstrip_->active_index() + delta; | 38 return tabstrip_->active_index() + delta; |
| 39 } | 39 } |
| 40 NavigationController* opener = | 40 NavigationController* opener = |
| 41 &tabstrip_->GetSelectedTabContents()->controller(); | 41 &tabstrip_->GetActiveTabContents()->controller(); |
| 42 // Get the index of the next item opened by this tab, and insert after | 42 // Get the index of the next item opened by this tab, and insert after |
| 43 // it... | 43 // it... |
| 44 int index; | 44 int index; |
| 45 if (insertion_policy_ == TabStripModel::INSERT_AFTER) { | 45 if (insertion_policy_ == TabStripModel::INSERT_AFTER) { |
| 46 index = tabstrip_->GetIndexOfLastTabContentsOpenedBy( | 46 index = tabstrip_->GetIndexOfLastTabContentsOpenedBy( |
| 47 opener, tabstrip_->active_index()); | 47 opener, tabstrip_->active_index()); |
| 48 } else { | 48 } else { |
| 49 index = tabstrip_->GetIndexOfFirstTabContentsOpenedBy( | 49 index = tabstrip_->GetIndexOfFirstTabContentsOpenedBy( |
| 50 opener, tabstrip_->active_index()); | 50 opener, tabstrip_->active_index()); |
| 51 } | 51 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 /////////////////////////////////////////////////////////////////////////////// | 138 /////////////////////////////////////////////////////////////////////////////// |
| 139 // TabStripModelOrderController, private: | 139 // TabStripModelOrderController, private: |
| 140 | 140 |
| 141 int TabStripModelOrderController::GetValidIndex( | 141 int TabStripModelOrderController::GetValidIndex( |
| 142 int index, int removing_index) const { | 142 int index, int removing_index) const { |
| 143 if (removing_index < index) | 143 if (removing_index < index) |
| 144 index = std::max(0, index - 1); | 144 index = std::max(0, index - 1); |
| 145 return index; | 145 return index; |
| 146 } | 146 } |
| OLD | NEW |