Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model_order_controller.cc

Issue 11364196: Remove TabContents from TabStripModelObserver::ActiveTabChanged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /////////////////////////////////////////////////////////////////////////////// 10 ///////////////////////////////////////////////////////////////////////////////
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 // No opener set, fall through to the default handler... 102 // No opener set, fall through to the default handler...
103 int selected_index = tabstrip_->active_index(); 103 int selected_index = tabstrip_->active_index();
104 if (selected_index >= (tab_count - 1)) 104 if (selected_index >= (tab_count - 1))
105 return selected_index - 1; 105 return selected_index - 1;
106 106
107 return selected_index; 107 return selected_index;
108 } 108 }
109 109
110 void TabStripModelOrderController::ActiveTabChanged( 110 void TabStripModelOrderController::ActiveTabChanged(
111 TabContents* old_contents, 111 content::WebContents* old_contents,
112 TabContents* new_contents, 112 content::WebContents* new_contents,
113 int index, 113 int index,
114 bool user_gesture) { 114 bool user_gesture) {
115 content::WebContents* old_opener = NULL; 115 content::WebContents* old_opener = NULL;
116 if (old_contents) { 116 if (old_contents) {
117 int index = tabstrip_->GetIndexOfTabContents(old_contents); 117 int index = tabstrip_->GetIndexOfWebContents(old_contents);
118 if (index != TabStripModel::kNoTab) { 118 if (index != TabStripModel::kNoTab) {
119 old_opener = tabstrip_->GetOpenerOfWebContentsAt(index); 119 old_opener = tabstrip_->GetOpenerOfWebContentsAt(index);
120 120
121 // Forget any group/opener relationships that need to be reset whenever 121 // Forget any group/opener relationships that need to be reset whenever
122 // selection changes (see comment in TabStripModel::AddTabContentsAt). 122 // selection changes (see comment in TabStripModel::AddTabContentsAt).
123 if (tabstrip_->ShouldResetGroupOnSelect(old_contents)) 123 if (tabstrip_->ShouldResetGroupOnSelect(old_contents))
124 tabstrip_->ForgetGroup(old_contents); 124 tabstrip_->ForgetGroup(old_contents);
125 } 125 }
126 } 126 }
127 content::WebContents* new_opener = tabstrip_->GetOpenerOfWebContentsAt(index); 127 content::WebContents* new_opener = tabstrip_->GetOpenerOfWebContentsAt(index);
128 128
129 if (user_gesture && new_opener != old_opener && 129 if (user_gesture && new_opener != old_opener &&
130 ((old_contents == NULL && new_opener == NULL) || 130 ((old_contents == NULL && new_opener == NULL) ||
131 new_opener != old_contents->web_contents()) && 131 new_opener != old_contents) &&
132 ((new_contents == NULL && old_opener == NULL) || 132 ((new_contents == NULL && old_opener == NULL) ||
133 old_opener != new_contents->web_contents())) { 133 old_opener != new_contents)) {
134 tabstrip_->ForgetAllOpeners(); 134 tabstrip_->ForgetAllOpeners();
135 } 135 }
136 } 136 }
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model_order_controller.h ('k') | chrome/browser/ui/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698