summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tabs
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-18 19:52:40 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-18 19:52:40 +0000
commit1ef5ad42064c8ef0d1503b68a7fbac01887ca093 (patch)
tree34a32b11a9db6f69fef27e7e81863d82a29bcd2d /chrome/browser/tabs
parent59b49a66c3cd959fcf9d7b4bd9c6d88c70b39919 (diff)
downloadchromium_src-1ef5ad42064c8ef0d1503b68a7fbac01887ca093.zip
chromium_src-1ef5ad42064c8ef0d1503b68a7fbac01887ca093.tar.gz
chromium_src-1ef5ad42064c8ef0d1503b68a7fbac01887ca093.tar.bz2
Reverting 14005.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc26
-rw-r--r--chrome/browser/tabs/tab_strip_model_order_controller.cc8
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc24
3 files changed, 31 insertions, 27 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 0470efa..2fc7e51 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -94,7 +94,7 @@ void TabStripModel::InsertTabContentsAt(int index,
ForgetAllOpeners();
}
// Anything opened by a link we deem to have an opener.
- data->SetGroup(&selected_contents->controller());
+ data->SetGroup(selected_contents->controller());
}
contents_data_.insert(contents_data_.begin() + index, data);
@@ -198,7 +198,7 @@ int TabStripModel::GetIndexOfController(
int index = 0;
TabContentsDataVector::const_iterator iter = contents_data_.begin();
for (; iter != contents_data_.end(); ++iter, ++index) {
- if (&(*iter)->contents->controller() == controller)
+ if ((*iter)->contents->controller() == controller)
return index;
}
return kNoTab;
@@ -403,8 +403,10 @@ bool TabStripModel::IsContextMenuCommandEnabled(
case CommandCloseTabsToRight:
return context_index < (count() - 1);
case CommandCloseTabsOpenedBy: {
- int next_index = GetIndexOfNextTabContentsOpenedBy(
- &GetTabContentsAt(context_index)->controller(), context_index, true);
+ NavigationController* opener =
+ GetTabContentsAt(context_index)->controller();
+ int next_index =
+ GetIndexOfNextTabContentsOpenedBy(opener, context_index, true);
return next_index != kNoTab;
}
case CommandDuplicate:
@@ -427,7 +429,7 @@ void TabStripModel::ExecuteContextMenuCommand(
break;
case CommandReload:
UserMetrics::RecordAction(L"TabContextMenu_Reload", profile_);
- GetContentsAt(context_index)->controller().Reload(true);
+ GetContentsAt(context_index)->controller()->Reload(true);
break;
case CommandDuplicate:
UserMetrics::RecordAction(L"TabContextMenu_Duplicate", profile_);
@@ -455,7 +457,7 @@ void TabStripModel::ExecuteContextMenuCommand(
case CommandCloseTabsOpenedBy: {
UserMetrics::RecordAction(L"TabContextMenu_CloseTabsOpenedBy", profile_);
NavigationController* opener =
- &GetTabContentsAt(context_index)->controller();
+ GetTabContentsAt(context_index)->controller();
for (int i = count() - 1; i >= 0; --i) {
if (OpenerMatches(contents_data_.at(i), opener, true))
@@ -476,7 +478,7 @@ void TabStripModel::ExecuteContextMenuCommand(
std::vector<int> TabStripModel::GetIndexesOpenedBy(int index) const {
std::vector<int> indices;
- NavigationController* opener = &GetTabContentsAt(index)->controller();
+ NavigationController* opener = GetTabContentsAt(index)->controller();
for (int i = count() - 1; i >= 0; --i) {
if (OpenerMatches(contents_data_.at(i), opener, true))
indices.push_back(i);
@@ -509,7 +511,7 @@ bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const {
return LowerCaseEqualsASCII(contents->GetURL().spec(),
chrome::kChromeUINewTabURL) &&
contents == GetContentsAt(count() - 1) &&
- contents->controller().entry_count() == 1;
+ contents->controller()->entry_count() == 1;
}
bool TabStripModel::InternalCloseTabContentsAt(int index,
@@ -532,9 +534,9 @@ bool TabStripModel::InternalCloseTabContentsAt(int index,
if (create_historical_tab)
delegate_->CreateHistoricalTab(detached_contents);
- // Deleting the TabContents will call back to us via NotificationObserver
- // and detach it.
- delete detached_contents;
+ detached_contents->CloseContents();
+ // Closing the TabContents will later call back to us via
+ // NotificationObserver and detach it.
}
return true;
}
@@ -562,7 +564,7 @@ void TabStripModel::ChangeSelectedContentsFrom(
void TabStripModel::SetOpenerForContents(TabContents* contents,
TabContents* opener) {
int index = GetIndexOfTabContents(contents);
- contents_data_.at(index)->opener = &opener->controller();
+ contents_data_.at(index)->opener = opener->controller();
}
// static
diff --git a/chrome/browser/tabs/tab_strip_model_order_controller.cc b/chrome/browser/tabs/tab_strip_model_order_controller.cc
index 1db0525..0c6326a 100644
--- a/chrome/browser/tabs/tab_strip_model_order_controller.cc
+++ b/chrome/browser/tabs/tab_strip_model_order_controller.cc
@@ -36,7 +36,7 @@ int TabStripModelOrderController::DetermineInsertionIndex(
return tabstrip_->selected_index() + 1;
}
NavigationController* opener =
- &tabstrip_->GetSelectedTabContents()->controller();
+ tabstrip_->GetSelectedTabContents()->controller();
// Get the index of the next item opened by this tab, and insert before
// it...
int index = tabstrip_->GetIndexOfLastTabContentsOpenedBy(
@@ -60,7 +60,7 @@ int TabStripModelOrderController::DetermineNewSelectedIndex(
// want to select the first in that child group, not the next tab in the same
// group of the removed tab.
NavigationController* removed_controller =
- &tabstrip_->GetTabContentsAt(removing_index)->controller();
+ tabstrip_->GetTabContentsAt(removing_index)->controller();
int index = tabstrip_->GetIndexOfNextTabContentsOpenedBy(removed_controller,
removing_index,
false);
@@ -109,8 +109,8 @@ void TabStripModelOrderController::TabSelectedAt(TabContents* old_contents,
NavigationController* new_opener =
tabstrip_->GetOpenerOfTabContentsAt(index);
if (user_gesture && new_opener != old_opener &&
- new_opener != &old_contents->controller() &&
- old_opener != &new_contents->controller()) {
+ new_opener != old_contents->controller() &&
+ old_opener != new_contents->controller()) {
tabstrip_->ForgetAllOpeners();
}
}
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index 656cba1..6b1f3d0 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -68,21 +68,23 @@ class TabStripDummyDelegate : public TabStripModelDelegate {
class TabStripModelTest : public RenderViewHostTestHarness {
public:
TabContents* CreateTabContents() {
- return new WebContents(profile(), NULL, 0, NULL);
+ WebContents* con = new WebContents(profile(), NULL, 0, NULL);
+ con->SetupController(profile());
+ return con;
}
// Forwards a URL "load" request through to our dummy TabContents
// implementation.
void LoadURL(TabContents* con, const std::wstring& url) {
- controller().LoadURL(GURL(url), GURL(), PageTransition::LINK);
+ controller()->LoadURL(GURL(url), GURL(), PageTransition::LINK);
}
void GoBack(TabContents* contents) {
- controller().GoBack();
+ controller()->GoBack();
}
void GoForward(TabContents* contents) {
- controller().GoForward();
+ controller()->GoForward();
}
void SwitchTabTo(TabContents* contents) {
@@ -358,8 +360,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()));
+ EXPECT_EQ(0, tabstrip.GetIndexOfController(contents2->controller()));
+ EXPECT_EQ(1, tabstrip.GetIndexOfController(contents1->controller()));
}
// Test UpdateTabContentsStateAt
@@ -412,7 +414,7 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
// background with opener_contents set as their opener.
TabContents* opener_contents = CreateTabContents();
- NavigationController* opener = &opener_contents->controller();
+ NavigationController* opener = opener_contents->controller();
tabstrip.AppendTabContents(opener_contents, true);
TabContents* contents1 = CreateTabContents();
TabContents* contents2 = CreateTabContents();
@@ -445,7 +447,7 @@ TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
// For a tab that has opened no other tabs, the return value should always be
// -1...
- NavigationController* o1 = &contents1->controller();
+ NavigationController* o1 = contents1->controller();
EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(o1, 3, false));
EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(o1, 3));
@@ -511,7 +513,7 @@ TEST_F(TabStripModelTest, TestInsertionIndexDetermination) {
EXPECT_TRUE(tabstrip.empty());
TabContents* opener_contents = CreateTabContents();
- NavigationController* opener = &opener_contents->controller();
+ NavigationController* opener = opener_contents->controller();
tabstrip.AppendTabContents(opener_contents, true);
// Open some other random unrelated tab in the background to monkey with our
@@ -590,7 +592,7 @@ TEST_F(TabStripModelTest, TestSelectOnClose) {
EXPECT_TRUE(tabstrip.empty());
TabContents* opener_contents = CreateTabContents();
- NavigationController* opener = &opener_contents->controller();
+ NavigationController* opener = opener_contents->controller();
tabstrip.AppendTabContents(opener_contents, true);
TabContents* contents1 = CreateTabContents();
@@ -668,7 +670,7 @@ TEST_F(TabStripModelTest, TestContextMenuCloseCommands) {
EXPECT_TRUE(tabstrip.empty());
TabContents* opener_contents = CreateTabContents();
- NavigationController* opener = &opener_contents->controller();
+ NavigationController* opener = opener_contents->controller();
tabstrip.AppendTabContents(opener_contents, true);
TabContents* contents1 = CreateTabContents();