summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tabs/tab_strip_model.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 01:27:13 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 01:27:13 +0000
commitf606747ffb21e9d0c6d55c9b57d42445503728f1 (patch)
treeff33aa2756665de01a8cb608d06fcdbcbb2e0263 /chrome/browser/tabs/tab_strip_model.cc
parent6b2ebf86a61169856aa3e650c294fd3511da5ee3 (diff)
downloadchromium_src-f606747ffb21e9d0c6d55c9b57d42445503728f1.zip
chromium_src-f606747ffb21e9d0c6d55c9b57d42445503728f1.tar.gz
chromium_src-f606747ffb21e9d0c6d55c9b57d42445503728f1.tar.bz2
ad an argument to MoveTabContentsAt() that switches whether the moved tab is set as the selected tab, or if the selected tab is left selected (but possibly moved).
Review URL: http://codereview.chromium.org/63153 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13823 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs/tab_strip_model.cc')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index c4b5ecd..5882705 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -153,7 +153,8 @@ void TabStripModel::SelectTabContentsAt(int index, bool user_gesture) {
ChangeSelectedContentsFrom(GetSelectedTabContents(), index, user_gesture);
}
-void TabStripModel::MoveTabContentsAt(int index, int to_position) {
+void TabStripModel::MoveTabContentsAt(int index, int to_position,
+ bool select_after_move) {
DCHECK(ContainsIndex(index));
if (index == to_position)
return;
@@ -162,7 +163,14 @@ void TabStripModel::MoveTabContentsAt(int index, int to_position) {
contents_data_.erase(contents_data_.begin() + index);
contents_data_.insert(contents_data_.begin() + to_position, moved_data);
- selected_index_ = to_position;
+ // if !select_after_move, keep the same tab selected as was selected before.
+ if (select_after_move || index == selected_index_) {
+ selected_index_ = to_position;
+ } else if (index < selected_index_ && to_position >= selected_index_) {
+ selected_index_--;
+ } else if (index > selected_index_ && to_position <= selected_index_) {
+ selected_index_++;
+ }
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
TabMoved(moved_data->contents, index, to_position));