summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 15:08:12 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-06 15:08:12 +0000
commit902cdf777ff20af9fc5ecc2877781dcb9571df69 (patch)
tree87c24705ad420bf5299402c53a6855259959844b /chrome
parenta727df08d3cff1b48e116ce215a03ed139828bda (diff)
downloadchromium_src-902cdf777ff20af9fc5ecc2877781dcb9571df69.zip
chromium_src-902cdf777ff20af9fc5ecc2877781dcb9571df69.tar.gz
chromium_src-902cdf777ff20af9fc5ecc2877781dcb9571df69.tar.bz2
Reverting 15399.
broke purify Review URL: http://codereview.chromium.org/115026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_provider.cc5
-rw-r--r--chrome/browser/browser.cc7
-rw-r--r--chrome/browser/browser.h4
-rw-r--r--chrome/browser/sessions/tab_restore_service.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc11
-rw-r--r--chrome/browser/tabs/tab_strip_model.h4
-rw-r--r--chrome/browser/tabs/tab_strip_model_order_controller.cc2
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc2
8 files changed, 27 insertions, 12 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 5b8b205..9e87744 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -878,7 +878,7 @@ void AutomationProvider::RemoveLoginHandler(NavigationController* tab) {
int AutomationProvider::GetIndexForNavigationController(
const NavigationController* controller, const Browser* parent) const {
DCHECK(parent);
- return parent->GetIndexOfTabContents(controller->tab_contents());
+ return parent->GetIndexOfController(controller);
}
void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
@@ -1784,8 +1784,7 @@ void AutomationProvider::GetTabIndex(int handle, int* tabstrip_index) {
if (tab_tracker_->ContainsHandle(handle)) {
NavigationController* tab = tab_tracker_->GetResource(handle);
Browser* browser = Browser::GetBrowserForController(tab, NULL);
- *tabstrip_index = browser->tabstrip_model()->GetIndexOfTabContents(
- tab->tab_contents());
+ *tabstrip_index = browser->tabstrip_model()->GetIndexOfController(tab);
}
}
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index e3bd3fe..45c6108 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1179,8 +1179,7 @@ Browser* Browser::GetBrowserForController(
const NavigationController* controller, int* index_result) {
BrowserList::const_iterator it;
for (it = BrowserList::begin(); it != BrowserList::end(); ++it) {
- int index = (*it)->tabstrip_model_.GetIndexOfTabContents(
- controller->tab_contents());
+ int index = (*it)->tabstrip_model_.GetIndexOfController(controller);
if (index != TabStripModel::kNoTab) {
if (index_result)
*index_result = index;
@@ -2273,7 +2272,7 @@ void Browser::ScheduleUIUpdate(const TabContents* source,
// this for any tab so they start & stop quickly, but the source can be
// NULL, so we have to check for that.
tabstrip_model_.UpdateTabContentsStateAt(
- tabstrip_model_.GetIndexOfTabContents(source), true);
+ tabstrip_model_.GetIndexOfController(&source->controller()), true);
}
// If the only updates were synchronously handled above, we're done.
@@ -2347,7 +2346,7 @@ void Browser::ProcessPendingUIUpdates() {
if (flags & TabContents::INVALIDATE_TAB) {
tabstrip_model_.UpdateTabContentsStateAt(
- tabstrip_model_.GetIndexOfTabContents(contents), false);
+ tabstrip_model_.GetIndexOfController(&contents->controller()), false);
window_->UpdateTitleBar();
if (contents == GetSelectedTabContents()) {
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index db5a35f..2a5db13 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -197,8 +197,8 @@ class Browser : public TabStripModelDelegate,
int tab_count() const { return tabstrip_model_.count(); }
int selected_index() const { return tabstrip_model_.selected_index(); }
- int GetIndexOfTabContents(const TabContents* contents) const {
- return tabstrip_model_.GetIndexOfTabContents(contents);
+ int GetIndexOfController(const NavigationController* controller) const {
+ return tabstrip_model_.GetIndexOfController(controller);
}
TabContents* GetTabContentsAt(int index) const {
return tabstrip_model_.GetTabContentsAt(index);
diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc
index 592921e..5399c21 100644
--- a/chrome/browser/sessions/tab_restore_service.cc
+++ b/chrome/browser/sessions/tab_restore_service.cc
@@ -353,8 +353,8 @@ void TabRestoreService::PopulateTab(Tab* tab,
// Browser may be NULL during unit tests.
if (browser) {
tab->browser_id = browser->session_id().id();
- tab->tabstrip_index = browser->tabstrip_model()->GetIndexOfTabContents(
- controller->tab_contents());
+ tab->tabstrip_index =
+ browser->tabstrip_model()->GetIndexOfController(controller);
}
}
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 58b15f5..e1a93f3 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -199,6 +199,17 @@ int TabStripModel::GetIndexOfTabContents(const TabContents* contents) const {
return kNoTab;
}
+int TabStripModel::GetIndexOfController(
+ const NavigationController* controller) const {
+ int index = 0;
+ TabContentsDataVector::const_iterator iter = contents_data_.begin();
+ for (; iter != contents_data_.end(); ++iter, ++index) {
+ if (&(*iter)->contents->controller() == controller)
+ return index;
+ }
+ return kNoTab;
+}
+
void TabStripModel::UpdateTabContentsStateAt(int index, bool loading_only) {
DCHECK(ContainsIndex(index));
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index 266860c..7f496c8 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -306,6 +306,10 @@ class TabStripModel : public NotificationObserver {
// is not in this TabStripModel.
int GetIndexOfTabContents(const TabContents* contents) const;
+ // Returns the index of the specified NavigationController, or -1 if it is
+ // not in this TabStripModel.
+ int GetIndexOfController(const NavigationController* controller) const;
+
// Notify any observers that the TabContents at the specified index has
// changed in some way. Loading only specifies whether only the loading state
// has changed.
diff --git a/chrome/browser/tabs/tab_strip_model_order_controller.cc b/chrome/browser/tabs/tab_strip_model_order_controller.cc
index 70530b0..1db0525 100644
--- a/chrome/browser/tabs/tab_strip_model_order_controller.cc
+++ b/chrome/browser/tabs/tab_strip_model_order_controller.cc
@@ -78,7 +78,7 @@ int TabStripModelOrderController::DetermineNewSelectedIndex(
// If we can't find a subsequent group member, just fall back to the
// parent_opener itself. Note that we use "group" here since opener is
// reset by select operations..
- index = tabstrip_->GetIndexOfTabContents(parent_opener->tab_contents());
+ index = tabstrip_->GetIndexOfController(parent_opener);
if (index != TabStripModel::kNoTab)
return GetValidIndex(index, removing_index);
}
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index 6e2dd80..a5b63a7 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -372,6 +372,8 @@ TEST_F(TabStripModelTest, TestBasicAPI) {
EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1));
EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(contents2));
EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(contents1));
+ EXPECT_EQ(0, tabstrip.GetIndexOfController(&contents2->controller()));
+ EXPECT_EQ(1, tabstrip.GetIndexOfController(&contents1->controller()));
}
// Test UpdateTabContentsStateAt